aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/holidays/holidayreact.py
diff options
context:
space:
mode:
authorGravatar Thurisatic <[email protected]>2023-01-17 15:59:40 -0500
committerGravatar Thurisatic <[email protected]>2023-01-17 16:03:33 -0500
commitb1470e9a88232d7b769f6c70f969c8e3e6723b0d (patch)
tree74edb80ad9719a5e9ffd00bc48ad7e25b3302467 /bot/exts/holidays/holidayreact.py
parentAdd non-Christmas holiday reaction capabilities (diff)
Perform small fixes, incl requested: sorting, typo, redundancies, mood
- Fixes misspelling of hanukkah regex - Move `_check_message` docstring to imperative mood - Remove redundant `_short_circuit_check` from `_check_message` - Remove redundant comma from `EarthDay`'s reaction list - Sort triggers for Halloween and Christmas
Diffstat (limited to 'bot/exts/holidays/holidayreact.py')
-rw-r--r--bot/exts/holidays/holidayreact.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/bot/exts/holidays/holidayreact.py b/bot/exts/holidays/holidayreact.py
index 535e22ec..9a8e0526 100644
--- a/bot/exts/holidays/holidayreact.py
+++ b/bot/exts/holidays/holidayreact.py
@@ -38,7 +38,7 @@ Easter = Holiday([Month.APRIL], {
}
)
EarthDay = Holiday([Month.FEBRUARY], {
- "earth": Trigger(r"\bearth|planet\b", ["\U0001F30E", "\U0001F30D", "\U0001F30F",]),
+ "earth": Trigger(r"\bearth|planet\b", ["\U0001F30E", "\U0001F30D", "\U0001F30F"]),
}
)
Pride = Holiday([Month.JUNE], {
@@ -46,26 +46,26 @@ Pride = Holiday([Month.JUNE], {
}
)
Halloween = Holiday([Month.OCTOBER], {
- "spooky": Trigger(r"\bspo{2,}[k|p][i|y](er|est)?\b", ["\U0001F47B"]),
- "skeleton": Trigger(r"\bskeleton\b", ["\U0001F480"]),
+ "bat": Trigger(r"\bbat((wo)?m[ae]n|persons?|people|s)?\b", ["\U0001F987"]),
+ "danger": Trigger(r"\bdanger\b", ["\U00002620"]),
"doot": Trigger(r"\bdo{2,}t\b", ["\U0001F480"]),
- "pumpkin": Trigger(r"\bpumpkin\b", ["\U0001F383"]),
"halloween": Trigger(r"\bhalloween\b", ["\U0001F383"]),
"jack-o-lantern": Trigger(r"\bjack-o-lantern\b", ["\U0001F383"]),
- "danger": Trigger(r"\bdanger\b", ["\U00002620"]),
- "bat": Trigger(r"\bbat((wo)?m[ae]n|persons?|people|s)?\b", ["\U0001F987"]),
+ "pumpkin": Trigger(r"\bpumpkin\b", ["\U0001F383"]),
+ "skeleton": Trigger(r"\bskeleton\b", ["\U0001F480"]),
+ "spooky": Trigger(r"\bspo{2,}[k|p][i|y](er|est)?\b", ["\U0001F47B"]),
}
)
Hanukkah = Holiday([Month.NOVEMBER, Month.DECEMBER], {
- "menorah": Trigger(r"\bc?haukkah|menorah\b", ["\U0001F54E"]),
+ "menorah": Trigger(r"\bc?hanukkah|menorah\b", ["\U0001F54E"]),
}
)
Christmas = Holiday([Month.DECEMBER], {
"christmas tree": Trigger(r"\b(christ|x)mas|tree\b", ["\U0001F384"]),
- "snowflake": Trigger(r"\b(snow ?)?flake(?! ?8)\b", ["\u2744\uFE0F"]),
+ "reindeer": Trigger(r"\breindeer|caribou|buck|stag\b", ["\U0001F98C"]),
"santa": Trigger(r"\bsanta\b", ["\U0001F385"]),
+ "snowflake": Trigger(r"\b(snow ?)?flake(?! ?8)\b", ["\u2744\uFE0F"]),
"snowman": Trigger(r"\bsnow(man|angel)\b", ["\u2603\uFE0F", "\u26C4"]),
- "reindeer": Trigger(r"\breindeer|caribou|buck|stag\b", ["\U0001F98C"]),
}
)
HOLIDAYS_TO_REACT = [
@@ -97,11 +97,11 @@ class HolidayReact(Cog):
async def _check_message(self, message: discord.Message, holiday: Holiday) -> None:
"""
- Checks if message is reactable.
+ Check if message is reactable.
- First checks if month is valid (else return). Then attempts to
- match regex triggers to message. Those that succeed result in
- reactions applied to the message.
+ React to message if:
+ * month is valid
+ * message contains reaction regex triggers
"""
if resolve_current_month() not in holiday.months:
return
@@ -109,8 +109,6 @@ class HolidayReact(Cog):
for name, trigger in holiday.triggers.items():
trigger_test = re.search(trigger.regex, message.content, flags=re.IGNORECASE)
if trigger_test:
- if await self._short_circuit_check(message):
- return
await message.add_reaction(random.choice(trigger.reaction))
log.info(f"Added {name!r} reaction to message ID: {message.id}")