Skip to content

Commit

Permalink
TrackReact: do not react in the support channel (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacG authored Sep 21, 2023
1 parent 3441194 commit 3593c70
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cogs/track_react.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ def __init__(
self,
aliases: dict[str, str],
case_sensitive: set[str],
no_react_channels: list[str],
**kwargs,
) -> None:
super().__init__(**kwargs)
self.reacts: dict[re.Pattern, discord.Emoji] = {}
self.messages: dict[int, discord.Message] = {}
self.aliases = aliases
self.case_sensitive = case_sensitive
self.no_react_channels = [c.removeprefix("#") for c in no_react_channels]

@commands.Cog.listener()
async def on_ready(self) -> None:
Expand Down Expand Up @@ -93,6 +95,17 @@ async def add_reacts(self, message: discord.Message, content: str) -> None:
"""Add reactions to a Message object based on content."""
if not message.guild:
return
if isinstance(message.channel, discord.TextChannel):
channel_name = message.channel.name
elif isinstance(message.channel, discord.Thread) and isinstance(
message.channel.parent, discord.TextChannel
):
channel_name = message.channel.parent.name
else:
channel_name = "Unhandled"
logger.debug("Adding reacts to message in channel %s", channel_name)
if channel_name in self.no_react_channels:
logger.debug("Not reacting to message in %s", channel_name)
if not message.channel.permissions_for(message.guild.me).add_reactions:
logger.warning(
"Missing add_reactions permission for %s in %s.",
Expand Down
1 change: 1 addition & 0 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"elisp": "emacs_lisp",
"cl": "common_lisp",
}
NO_REACT_CHANNELS = ["support"]

# mentor_requests.py
MENTOR_REQUEST_CHANNEL = 1091036025737986098
Expand Down
1 change: 1 addition & 0 deletions exercism_discord_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def get_cogs(self) -> dict[commands.CogMeta, dict[str, Any]]:
cogs.TrackReact: {
"aliases": conf.ALIASES,
"case_sensitive": conf.CASE_SENSITIVE,
"no_react_channels": conf.NO_REACT_CHANNELS,
},
}
# Optionally filter Cogs.
Expand Down

0 comments on commit 3593c70

Please sign in to comment.