aboutsummaryrefslogtreecommitdiffstats
path: root/bot/seasons/halloween/spookyreact.py
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-03-28 15:13:26 +0100
committerGravatar kwzrd <[email protected]>2020-03-28 15:13:26 +0100
commit294915013680c9ad205d6c9fa0c7fa2b79cc1919 (patch)
tree117612b7f890e35010fe53575879edc1c41362e0 /bot/seasons/halloween/spookyreact.py
parentDeseasonify: info log on help cog load (diff)
Deseasonify: rename `seasons` pkg to `exts`
It is believed that this is now a more logical name for the package, as extensions no longer bind to seasons. Internally, packages are still grouped into seasonal sub-packages. There are quite a few, and it makes sense to group them by a common theme that inspired their functionality.
Diffstat (limited to 'bot/seasons/halloween/spookyreact.py')
-rw-r--r--bot/seasons/halloween/spookyreact.py76
1 files changed, 0 insertions, 76 deletions
diff --git a/bot/seasons/halloween/spookyreact.py b/bot/seasons/halloween/spookyreact.py
deleted file mode 100644
index 16f18019..00000000
--- a/bot/seasons/halloween/spookyreact.py
+++ /dev/null
@@ -1,76 +0,0 @@
-import logging
-import re
-
-import discord
-from discord.ext.commands import Bot, Cog
-
-from bot.constants import Month
-from bot.utils.decorators import in_month
-
-log = logging.getLogger(__name__)
-
-SPOOKY_TRIGGERS = {
- 'spooky': (r"\bspo{2,}ky\b", "\U0001F47B"),
- 'skeleton': (r"\bskeleton\b", "\U0001F480"),
- 'doot': (r"\bdo{2,}t\b", "\U0001F480"),
- 'pumpkin': (r"\bpumpkin\b", "\U0001F383"),
- 'halloween': (r"\bhalloween\b", "\U0001F383"),
- 'jack-o-lantern': (r"\bjack-o-lantern\b", "\U0001F383"),
- 'danger': (r"\bdanger\b", "\U00002620")
-}
-
-
-class SpookyReact(Cog):
- """A cog that makes the bot react to message triggers."""
-
- def __init__(self, bot: Bot):
- self.bot = bot
-
- @in_month(Month.october)
- @Cog.listener()
- async def on_message(self, ctx: discord.Message) -> None:
- """
- A command to send the seasonalbot github project.
-
- Lines that begin with the bot's command prefix are ignored
-
- Seasonalbot's own messages are ignored
- """
- for trigger in SPOOKY_TRIGGERS.keys():
- trigger_test = re.search(SPOOKY_TRIGGERS[trigger][0], ctx.content.lower())
- if trigger_test:
- # Check message for bot replies and/or command invocations
- # Short circuit if they're found, logging is handled in _short_circuit_check
- if await self._short_circuit_check(ctx):
- return
- else:
- await ctx.add_reaction(SPOOKY_TRIGGERS[trigger][1])
- logging.info(f"Added '{trigger}' reaction to message ID: {ctx.id}")
-
- async def _short_circuit_check(self, ctx: discord.Message) -> bool:
- """
- Short-circuit helper check.
-
- Return True if:
- * author is the bot
- * prefix is not None
- """
- # Check for self reaction
- if ctx.author == self.bot.user:
- logging.debug(f"Ignoring reactions on self message. Message ID: {ctx.id}")
- return True
-
- # Check for command invocation
- # Because on_message doesn't give a full Context object, generate one first
- tmp_ctx = await self.bot.get_context(ctx)
- if tmp_ctx.prefix:
- logging.debug(f"Ignoring reactions on command invocation. Message ID: {ctx.id}")
- return True
-
- return False
-
-
-def setup(bot: Bot) -> None:
- """Spooky reaction Cog load."""
- bot.add_cog(SpookyReact(bot))
- log.info("SpookyReact cog loaded")