Skip to content

Commit

Permalink
Added alert_on_mention, resolve #2833
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Nov 5, 2020
1 parent 90e11ca commit 9f8d874
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ however, insignificant breaking changes do not guarantee a major version bump, s
- Added `thread_move_notify_mods` to mention all mods again after moving thread. ([GH #215](https://github.com/kyb3r/modmail/issues/215))
- Added `transfer_reactions` to link reactions between mods and users. ([GH #2763](https://github.com/kyb3r/modmail/issues/2763))
- Added `close_on_leave` to automatically close threads upon recipient leaving the server. ([GH #2757](https://github.com/kyb3r/modmail/issues/2757))
- Added `alert_on_mention` to mention mods upon a bot mention. ([GH #2833](https://github.com/kyb3r/modmail/issues/2833))

### Fixed

Expand Down
18 changes: 18 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,24 @@ async def on_message(self, message):
await self.wait_for_connected()
if message.type == discord.MessageType.pins_add and message.author == self.user:
await message.delete()

if (
(f"<@{self.user.id}" in message.content or f"<@!{self.user.id}" in message.content)
and self.config["alert_on_mention"]
and not message.author.bot
):
if len(message.content) > 50:
extra = "..."
else:
extra = ""
em = discord.Embed(
title="Bot mention",
description=f"[Jump URL]({message.jump_url})\n{message.content[:50]}{extra}",
color=self.main_color,
timestamp=datetime.utcnow(),
)
await self.log_channel.send(content=self.config["mention"], embed=em)

await self.process_commands(message)

async def process_commands(self, message):
Expand Down
2 changes: 2 additions & 0 deletions core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ConfigManager:
"disabled_current_thread_footer": "Please try again later...",
"transfer_reactions": True,
"close_on_leave": False,
"alert_on_mention": False,
# moderation
"recipient_color": str(discord.Color.gold()),
"mod_color": str(discord.Color.green()),
Expand Down Expand Up @@ -144,6 +145,7 @@ class ConfigManager:
"thread_move_notify_mods",
"transfer_reactions",
"close_on_leave",
"alert_on_mention",
"enable_plugins",
"enable_eval",
}
Expand Down
10 changes: 10 additions & 0 deletions core/config_help.json
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,16 @@
],
"notes": []
},
"alert_on_mention": {
"default": "No",
"description": "Mentions all mods (mention) in logs channel when bot is mentioned",
"examples":[
"`{prefix}config set alert_on_mention yes"
],
"notes": [
"See also: `mention`"
]
},
"modmail_guild_id": {
"default": "Fallback on `GUILD_ID`",
"description": "The ID of the discord server where the threads channels should be created (receiving server).",
Expand Down

0 comments on commit 9f8d874

Please sign in to comment.