From 684ba106d4679d754d7b11138fe8d0e812e9fcdb Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Fri, 13 Jun 2025 17:18:05 -0400 Subject: [PATCH] add automatic help message --- nomen/main.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/nomen/main.py b/nomen/main.py index e68b441..b6c146e 100644 --- a/nomen/main.py +++ b/nomen/main.py @@ -1,3 +1,4 @@ +import datetime import io import logging import os @@ -7,6 +8,7 @@ import textwrap import traceback from contextlib import redirect_stdout +import disnake from disnake import Embed, Guild, Intents, Message, Thread from disnake.ext import commands from disnake.ext.commands import Bot, Paginator @@ -189,6 +191,51 @@ async def on_error(event, *args, **kwargs): log.error(f"Error in event {event}.\nargs={pargs}\nkwargs={pkwargs}", exc_info=sys.exc_info()) +help_timeouts = {} + + +@bot.listen() +async def on_message(message: Message): + if message.author == bot.user: + return + + ctx = await bot.get_context(message) + if ctx.valid: + return + + now = disnake.utils.utcnow() + if timeout := help_timeouts.get(ctx.channel.id, None): + if now < timeout: + return + + c = message.content.lower() + prefix = await bot.get_guild_prefix(ctx.guild) or "@nomen " + + if "help" in c and "nomen" in c: + help_timeouts[ctx.channel.id] = now + datetime.timedelta(minutes=5) + await message.reply(f"""\ +Heya! + +- To add a keyword, use the command `{prefix}keyword add ` + (`{prefix}keyword` can be shortened to `{prefix}kw`) +- To remove a keyword, use `{prefix}keyword remove ` +- To view all of your keywords, use `{prefix}keyword list` +- To ignore a person/channel/category, use `{prefix}keyword ignore ` + To unignore, `{prefix}keyword unignore ` +- To block a person across all servers, `{prefix}keyword block ` + To unblock, `{prefix}keyword unblock ` +- To pause/unpause notifications in a server, use `{prefix}keyword pause`/`{prefix}keyword unpause` + +For other commands, see `{prefix}help`. Use `{prefix}help ` for detailed help. + +If you are familiar with the Dusty bot (almost) all commands for Dusty work with Nomen, just replace `>` with `{prefix}`. +If you already have keywords in Dusty, you can import them into Nomen easily by: +1. Use `>notif list` to get your list of keywords from Dusty +2. Copy the list (**without the header/title**) +3. Run `{prefix}nomen import ` + """) + + @bot.command(hidden=True) @commands.is_owner() async def echo(ctx, arg):