Skip to content

Commit

Permalink
Add ignore_prefix config option
Browse files Browse the repository at this point in the history
When reply_without_command is enabled, a message starting with this character (or string) will not be sent as a reply
  • Loading branch information
khakers committed Nov 11, 2023
1 parent 2fa1310 commit d9f8927
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ async def on_message(self, message):

await self.process_commands(message)

async def process_commands(self, message):
async def process_commands(self, message: discord.Message):
if message.author.bot:
return

Expand Down Expand Up @@ -1231,7 +1231,8 @@ async def process_commands(self, message):
or self.config.get("anon_reply_without_command")
or self.config.get("plain_reply_without_command")
):
await thread.reply(message, anonymous=anonymous, plain=plain)
if not message.content.startswith(self.config.get("ignore_prefix")):
await thread.reply(message, anonymous=anonymous, plain=plain)
else:
await self.api.append_log(message, type_="internal")
elif ctx.invoked_with:
Expand Down
1 change: 1 addition & 0 deletions core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ConfigManager:
"reply_without_command": False,
"anon_reply_without_command": False,
"plain_reply_without_command": False,
"ignore_prefix": "\0",
# logging
"log_channel_id": None,
"mention_channel_id": None,
Expand Down
10 changes: 10 additions & 0 deletions core/config_help.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@
"See also: `anon_reply_without_command`, `plain_reply_without_command`."
]
},
"ignore_prefix": {
"default": "\\0",
"description": "Messages that start with this prefix will be ignored by Modmail.",
"examples": [
"`{prefix}config set ignore_prefix .`"
],
"notes": [
"`reply_without_command` must be enabled"
]
},
"anon_reply_without_command": {
"default": "Disabled",
"description": "Setting this configuration will make all non-command messages sent in the thread channel to be anonymously forwarded to the recipient without the need of `{prefix}reply`.",
Expand Down

0 comments on commit d9f8927

Please sign in to comment.