From a2852eab6ba73e8015aa703f6bb7a94253538b85 Mon Sep 17 00:00:00 2001 From: kwzrd Date: Sun, 15 Mar 2020 16:35:02 +0100 Subject: Deseasonify: season-lock listeners where appropriate We want to prevent listeners from performing season-specific behaviour outside of specific months. --- bot/seasons/halloween/candy_collection.py | 5 ++++- bot/seasons/halloween/spookyreact.py | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/halloween/candy_collection.py b/bot/seasons/halloween/candy_collection.py index 490609dd..3c65a745 100644 --- a/bot/seasons/halloween/candy_collection.py +++ b/bot/seasons/halloween/candy_collection.py @@ -8,7 +8,8 @@ from typing import List, Union import discord from discord.ext import commands -from bot.constants import Channels +from bot.constants import Channels, Month +from bot.decorators import in_month_listener log = logging.getLogger(__name__) @@ -35,6 +36,7 @@ class CandyCollection(commands.Cog): self.get_candyinfo[userid] = userinfo @commands.Cog.listener() + @in_month_listener(Month.october) async def on_message(self, message: discord.Message) -> None: """Randomly adds candy or skull reaction to non-bot messages in the Event channel.""" # make sure its a human message @@ -56,6 +58,7 @@ class CandyCollection(commands.Cog): return await message.add_reaction('\N{CANDY}') @commands.Cog.listener() + @in_month_listener(Month.october) async def on_reaction_add(self, reaction: discord.Reaction, user: discord.Member) -> None: """Add/remove candies from a person if the reaction satisfies criteria.""" message = reaction.message diff --git a/bot/seasons/halloween/spookyreact.py b/bot/seasons/halloween/spookyreact.py index 90b1254d..c6127298 100644 --- a/bot/seasons/halloween/spookyreact.py +++ b/bot/seasons/halloween/spookyreact.py @@ -4,6 +4,9 @@ import re import discord from discord.ext.commands import Bot, Cog +from bot.constants import Month +from bot.decorators import in_month_listener + log = logging.getLogger(__name__) SPOOKY_TRIGGERS = { @@ -24,6 +27,7 @@ class SpookyReact(Cog): self.bot = bot @Cog.listener() + @in_month_listener(Month.october) async def on_message(self, ctx: discord.Message) -> None: """ A command to send the seasonalbot github project. -- cgit v1.2.3