Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,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 @@ -1593,9 +1593,16 @@ async def process_commands(self, message):
or self.config.get("anon_reply_without_command")
or self.config.get("plain_reply_without_command")
):
# When replying without a command in a thread channel, use the raw content
# from the sent message as reply text while still preserving attachments.
await thread.reply(message, message.content, anonymous=anonymous, plain=plain)
# Check to see if the message starts with the ignore prefix
if not message.content.startswith(self.config.get("ignore_prefix")):
# When replying without a command in a thread channel, use the raw content
# from the sent message as reply text while still preserving attachments.
await thread.reply(message, message.content, anonymous=anonymous, plain=plain)
else:
logger.debug(f"Message {message.id} ignored because it started with the ignore_prefix.")
await self.api.append_log(message, type_="internal")
else:
await self.api.append_log(message, type_="internal")
elif ctx.invoked_with:
exc = commands.CommandNotFound(f'Command "{ctx.invoked_with}" is not found')
self.dispatch("command_error", ctx, exc)
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
Loading