diff --git a/bot.py b/bot.py index 1c4fdd5354..e5008d51d1 100644 --- a/bot.py +++ b/bot.py @@ -1013,20 +1013,20 @@ async def trigger_auto_triggers(self, message, channel, *, cls=commands.Context) alias = self.auto_triggers[trigger] ctxs = [] + if alias is not None: ctxs = [] aliases = normalize_alias(alias) if not aliases: logger.warning("Alias %s is invalid as called in autotrigger.", invoker) - for alias in aliases: - view = StringView(invoked_prefix + alias) - ctx_ = cls(prefix=self.prefix, view=view, bot=self, message=message) - ctx_.thread = thread - discord.utils.find(view.skip_string, await self.get_prefix()) - ctx_.invoked_with = view.get_word().lower() - ctx_.command = self.all_commands.get(ctx_.invoked_with) - ctxs += [ctx_] + message.author = thread.recipient # Allow for get_contexts to work + + for alias in aliases: + message.content = invoked_prefix + alias + ctxs += await self.get_contexts(message) + + message.author = self.modmail_guild.me # Fix message so commands execute properly for ctx in ctxs: if ctx.command: diff --git a/cogs/modmail.py b/cogs/modmail.py index 0e41b76677..367c30f3c8 100644 --- a/cogs/modmail.py +++ b/cogs/modmail.py @@ -818,7 +818,9 @@ async def reply(self, ctx, *, msg: str = ""): Supports attachments and images as well as automatically embedding image URLs. """ + ctx.message.content = msg + async with ctx.typing(): await ctx.thread.reply(ctx.message) diff --git a/cogs/utility.py b/cogs/utility.py index 759b573748..59e5d507dd 100644 --- a/cogs/utility.py +++ b/cogs/utility.py @@ -1751,6 +1751,13 @@ async def autotrigger_add(self, ctx, keyword, *, command): valid = True break + if not valid and self.bot.aliases: + for n in range(1, len(split_cmd) + 1): + if self.bot.aliases.get(" ".join(split_cmd[0:n])): + print(self.bot.aliases.get(" ".join(split_cmd[0:n]))) + valid = True + break + if valid: self.bot.auto_triggers[keyword] = command await self.bot.config.update() @@ -1764,7 +1771,7 @@ async def autotrigger_add(self, ctx, keyword, *, command): embed = discord.Embed( title="Error", color=self.bot.error_color, - description="Invalid command. Note that autotriggers do not work with aliases.", + description="Invalid command. Please provide a valid command or alias.", ) await ctx.send(embed=embed) @@ -1784,6 +1791,14 @@ async def autotrigger_edit(self, ctx, keyword, *, command): valid = True break + if not valid and self.bot.aliases: + for n in range(1, len(split_cmd) + 1): + print(" ".join(split_cmd[0:n]), self.bot.aliases.get(" ".join(split_cmd[0:n]))) + if self.bot.aliases.get(" ".join(split_cmd[0:n])): + print(self.bot.aliases.get(" ".join(split_cmd[0:n]))) + valid = True + break + if valid: self.bot.auto_triggers[keyword] = command await self.bot.config.update() @@ -1797,7 +1812,7 @@ async def autotrigger_edit(self, ctx, keyword, *, command): embed = discord.Embed( title="Error", color=self.bot.error_color, - description="Invalid command. Note that autotriggers do not work with aliases.", + description="Invalid command. Please provide a valid command or alias.", ) await ctx.send(embed=embed) diff --git a/core/thread.py b/core/thread.py index 41d2cd96ba..a494891965 100644 --- a/core/thread.py +++ b/core/thread.py @@ -241,6 +241,7 @@ class Author: async def activate_auto_triggers(): if initial_message: message = DummyMessage(copy.copy(initial_message)) + try: return await self.bot.trigger_auto_triggers(message, channel) except RuntimeError: diff --git a/plugins/registry.json b/plugins/registry.json index a9f565a013..b39ac345bd 100644 --- a/plugins/registry.json +++ b/plugins/registry.json @@ -1,4 +1,31 @@ { + "close_message": { + "repository": "python-discord/modmail-plugins", + "branch": "main", + "description": "Add a ?closemessage command that will close the thread after 15 minutes with a default message.", + "bot_version": "2.20.1", + "title": "Close message", + "icon_url": "https://i.imgur.com/ev7BFMz.png", + "thumbnail_url": "https://i.imgur.com/ev7BFMz.png" + }, + "mdlink": { + "repository": "python-discord/modmail-plugins", + "branch": "main", + "description": "Generate a ready to paste link to the thread logs.", + "bot_version": "2.20.1", + "title": "MDLink", + "icon_url": "https://i.imgur.com/JA2E63R.png", + "thumbnail_url": "https://i.imgur.com/JA2E63R.png" + }, + "reply_cooldown": { + "repository": "python-discord/modmail-plugins", + "branch": "main", + "description": "Forbid you from sending the same message twice in ten seconds.", + "bot_version": "2.20.1", + "title": "Reply cooldown", + "icon_url": "https://i.imgur.com/FtRQveT.png", + "thumbnail_url": "https://i.imgur.com/FtRQveT.png" + }, "dragory-migrate": { "repository": "kyb3r/modmail-plugins", "branch": "master", @@ -154,7 +181,7 @@ "suggest": { "repository": "realcyguy/modmail-plugins", "branch": "master", - "description": "Send suggestions to a selected server! It even has moderation...", + "description": "Send suggestions to a selected server! It has accepting, denying, and moderation-ing.", "bot_version": "3.4.1", "title": "Suggest stuff.", "icon_url": "https://i.imgur.com/qtE7AH8.png",