aboutsummaryrefslogtreecommitdiffstats
path: root/bot/decorators.py (follow)
Commit message (Collapse)AuthorAgeLines
* Deseasonify: move decorators module under utilsGravatar kwzrd2020-03-28-321/+0
|
* Deseasonify: extend `in_month` docGravatar kwzrd2020-03-26-0/+5
|
* Deseasonify: use 't-dot' notation for type annotationsGravatar kwzrd2020-03-24-19/+19
| | | | | The module is full of complicated annotations, and the full `typing` takes up annoyingly much visual space.
* Deseasonify: add generic `in_month` decoratorGravatar kwzrd2020-03-24-1/+34
| | | | | | | | | | See docstring for further details. This serves as a convenience wrapper around `in_month_command` and `in_month_listener` to allow a consistent API. Proposed by lemon. Co-authored-by: Leon Sandøy <[email protected]>
* Deseasonify: rename `in_month` decoratorGravatar kwzrd2020-03-24-1/+1
| | | | | | Indicate that the decorator shall only be applied to commands. The `in_month` name will be used for a universal decorator that can season-lock both listeners and commands.
* Deseasonify: add `mock_in_debug` decoratorGravatar kwzrd2020-03-23-1/+21
| | | | This should be very useful for testing. See docstring.
* Deseasonify: abdicate responsibility to wait until bot is readyGravatar kwzrd2020-03-23-7/+3
| | | | | | | | | | | | | | | | The wrapper will no longer wait for the bot to be ready before it calls the wrapped function for the first time. If the function requires the bot's cache to be ready, it is responsible for awaiting the method itself. This removes the need to acquire a reference to the bot instance inside the decorator, which seems to be difficult to do cleanly. As Mark adds, this may in fact be safer as the bot may temporarily disconnect while the task is active, and awaiting the bot's ready status every time will prevent issues in such a situation. Co-authored-by: MarkKoz <[email protected]>
* Deseasonify: relax type annotationGravatar kwzrd2020-03-15-1/+1
| | | | | Asyncio's sleep will accept both, and we default to an int, so might as well not break our own promise.
* Deseasonify: remove fragile attr dependency in `seasonal_task`Gravatar kwzrd2020-03-15-6/+5
| | | | | | | | | Importing the bot instance will allow us to safely access the `wait_until_ready` method without having to make fragile assumptions about the arguments passed to the decorated method. Although still not perfect, this feels a lot cleaner and safer than the previous approach.
* Deseasonify: add convenience decorator for seasonal tasksGravatar kwzrd2020-03-15-0/+39
| | | | See docstring for implementation details.
* Deseasonify: add listener decorator for season lockingGravatar kwzrd2020-03-15-0/+22
| | | | | | A guarded listener will abort if the triggering event happens outside of `allowed_months`. This provides a convenient way of season-locking listeners without having to write guards directly within their bodies.
* Deseasonify: improve `in_month` command checkGravatar kwzrd2020-03-15-2/+13
| | | | | | Raise a custom exception if the command fails. This is then handled in the error handler, and the user will be informed of which months allow the invoked command.
* Implement in_month command checkGravatar kwzrd2020-02-22-1/+20
| | | | | Commands decorated with in_month can only be used in one of the allowed months.
* Fix inaccurate annotations for custom checks.Gravatar scragly2019-12-06-2/+2
|
* put role bypass check above channel override to make sure bypass roles can ↵Gravatar Numerlor2019-10-02-7/+7
| | | | activate commands everywhere even with override channels specified
* fix grammar in in_channel_override docstringGravatar Numerlor2019-10-02-1/+2
|
* add logging when an overriden in_channel_check failsGravatar Numerlor2019-10-02-0/+5
|
* fix in_channel_check docstring styleGravatar Numerlor2019-10-02-2/+4
|
* add return type hint to override_in_channel inner functionGravatar Numerlor2019-10-02-1/+1
|
* rewrite override_in_channel to accept an optional new channel whitelistGravatar Numerlor2019-10-02-10/+29
| | | | add checks for the new whitelist to in_channel_check
* Lint remaining filesGravatar S. Co12019-09-09-3/+3
| | | hacktoberstats cog handled in separate PR
* Initial linting passGravatar S. Co12019-09-09-6/+6
| | | | Bot root, seasons cog, easter cogs, evergreen cogs, halloween cogs
* Fix indent style and reduce logging message verbosityGravatar kosayoda2019-08-12-21/+34
| | | | Addresses PR review requests by Mark.
* Split in_channel's predicate and check, add bypass_roles functionalityGravatar kosayoda2019-08-06-8/+54
| | | | Separate the predicate function from `commands.check` to allow the predicate check to be added to the bot.
* Relint Seasonalbot with new linting rulesGravatar sco12019-04-24-4/+0
|
* Docstring pass for top-level bot functionsGravatar sco12019-03-18-2/+8
|
* Initial move of Snakes cog from the bot to seasonalbotGravatar Chris Goes2019-03-04-0/+41
|
* Allows you to create Seasons. (#64)Gravatar Leon Sandøy2018-11-27-0/+48
* Allows you to create Season objects which change the bots behavior. For example, a season can determine things like the avatar, the nickname, and which cogs are loaded. Season automatically changes according to the date range you specify when you create it. * removing some hungarian notation. * Automatic season changes will now always happen at a minute past midnight, no matter when the bot started. * catching dunders in the glob. * Refine Season Creation behaviour and structure. * Added channel and role constants, refactored roles into NamedTuples, added role check decorators from the main bot, and added role checks for the season change feature. Yes this is duplicate code from our main bot, but it will just have to be like that for now until we get a bot core running. * replacing the or with an xor and switching out the assert for a UserWarning * New lockfile * changing discord.py to discord-py to prevent pip bug from putting two of them in our lockfile * fixing flake errors * flake8 * Cleaned everything up, but I seem to have introduced some sort of infinite load loop? o.O * Fixing up all bugs in the halloween cogs. This should be ready for merge now. * Add avatar_path baseclass method for consistency. While making it simpler to add avatar urls in new season extensions, it also allows the avatar resource path to be changed in a single place if needed in future. * Avoid shadowing builtin `object`. * Add debug mode, refine bot user editing on season load. The changing of a bot's username and avatar is heavily ratelimited. While testing, restarting the bot and changing seasons is required, and hitting these limits are typical. Instead, when in debug mode, the avatar isn't set and only the nickname is changed to prevent unnecessary account edit requests. In the case that the rate limit is hit when not in debug mode, there's an added fallback to use the nickname instead. * Add cancel load_seasons task on SeasonManager un/reload. Previously the load_seasons task was loaded and looping forever. Even if the cog was unloaded for some reason, it would still be running. On loading the SeasonManager again, it would create a new load_seasons task, while the old one still existed. Adding the cancellation allows the task to end when the cog is unloaded or reloaded, and will help assist with live code changes during development at a later time where it's possible to reload this extension (perhaps when the pending bot core is implemented). * get_season_class helper, season class attribs, fix admin id Changes `get_season`'s date check to not initialise unwanted classes (to avoid needless loading of tasks which would otherwise cause unexpected behaviour). To do this, defining attributes of season classes have been moved from `__init__` as an instance variable, to the class variable level. This also results in `__init__` not needing to be defined for the `SeasonBase` class, and `super().__init__()` not needing to be called in individual season classes, making things cleaner/simpler for them. Adds a helper function for retrieving a season class and combines two unnecessarily separate if statements. Credits to @MarkKoz for the suggestions. Reverts the admin ID mistakenly changed in a previous commit. * Update bot/seasons/halloween/hacktoberstats.py Co-Authored-By: heavysaturn <[email protected]> * Update bot/seasons/halloween/halloween_facts.py Co-Authored-By: heavysaturn <[email protected]> * No more property in halloweenfacts * Changed all aliases to tuples * Made tokens a seperate namedtuple * Update bot/seasons/halloween/spookyavatar.py Co-Authored-By: heavysaturn <[email protected]>