aboutsummaryrefslogtreecommitdiffstats
path: root/bot/bot.py (follow)
Commit message (Collapse)AuthorAgeLines
* Prevent bot from mentioning non-mod rolesGravatar MarkKoz2020-07-14-2/+4
| | | | | This was open to abuse when the bot relayed user input. The fix relies on a discord.py alpha feature.
* Show bot prefix in rich presenceGravatar kwzrd2020-05-08-1/+4
| | | | This emulates the main bot's message for consistency.
* Transition towards `wait_until_guild_available` useGravatar kwzrd2020-04-04-1/+1
| | | | | | All calls to `wait_until_ready` are replaced with the new event. To help with static analysis, we annotate `bot` attrs as instances of our custom SeasonalBot class where necessary.
* Add `wait_until_guild_available` coroutineGravatar kwzrd2020-04-04-0/+34
| | | | | | | | | | | See docstring for explanation & comparison to the `on_ready` event. This is taken from the Python bot repository. Originally implemented by Mark. The `on_guild_available` callback was adapted and simplified from the original implementation, as with Sentry in place, it is believed that dispatching an error webhook is unnecessary. Co-authored-by: MarkKoz <[email protected]>
* Try to fetch devlog channel if not found in cacheGravatar kwzrd2020-04-04-2/+6
|
* Remove redundant task assignmentGravatar kwzrd2020-04-03-1/+1
|
* Send greeting message to devlog channel on bot start-upGravatar kwzrd2020-04-03-0/+1
| | | | | Previously, this was done by the SeasonManager cog, which was removed during our deseasonification efforts.
* Ensure cache is ready before grabbing devlog channelGravatar kwzrd2020-04-03-0/+1
|
* Refactor: capitalize AssetType enum membersGravatar kwzrd2020-03-31-6/+6
| | | | Co-authored-by: MarkKoz <[email protected]>
* Deseasonify: use `self` rather than local `bot` instance varGravatar kwzrd2020-03-29-3/+3
|
* Deseasonify: adjust bot method defs to a more logical orderGravatar kwzrd2020-03-29-33/+33
|
* Deseasonify: use new `_apply_asset` setterGravatar kwzrd2020-03-29-54/+26
| | | | | | | | The diff should demonstrate how much code repetition we prevent. We do not make use of `_apply_asset` for nickname changes - due to the comparative simplicity and conceptual difference, this method provides its own error handling.
* Deseasonify: implement generic media asset setterGravatar kwzrd2020-03-29-2/+30
| | | | | | | | | | | | | | | | Current `set_avatar`, `set_icon` and `set_banner` methods are almost identical - they only differ in the type of asset they upload. This leads to a lot of code repetition, especially w.r.t. error handling. We instead add a generic method that is parametrized by an AssetType param, and by the target entity (i.e. bot, or guild) that the asset should be applied to. All error handling can then be done in one place. Error handling methodology is adjusted - instead of suppressing errors, we catch and log them. Since we no longer determine whether the upload succeeded based on 'before' != 'after', this solves a bug where re-applying the same asset resulted in a warning-level log, triggering Sentry.
* Deseasonify: add AssetType enumGravatar kwzrd2020-03-29-2/+14
|
* Deseasonify: remove unused `set_username` methodGravatar kwzrd2020-03-29-30/+0
| | | | | | | The method is a left-over from the old seasonal system. We no longer use it, the bot's username never changes, only the nickname. The amount of internal branching logic makes it difficult to maintain.
* Deseasonify: log in `add_cog` rather than in each `setup`Gravatar kwzrd2020-03-28-0/+9
| | | | | | | | | | | | The previous system required each extension's `setup` func to log that the cog was loaded. This leads to inconsistent messages all trying to convey the same thing, variable logger names in the output file are difficult to read, and several extensions were not logging at all. By logging directly in the `add_cog` method, we reduce code repetition, ensure consistent format, and remove the responsibility to remember that a log should be made.
* Deseasonify: move decorators module under utilsGravatar kwzrd2020-03-28-1/+1
|
* Deseasonify: mock expensive API calls in debug modeGravatar kwzrd2020-03-24-1/+13
| | | | | | The methods will pretend that the selected asset was uploaded successfully. This allows extensive testing of the branding manager without API abuse.
* Deseasonify: remove `load_extensions` methodGravatar kwzrd2020-03-23-19/+1
| | | | | This is unused and no longer necessary, as all extensions load only once: on start-up, in `__main__.py`.
* Merge branch 'master' into seasonal-purgeGravatar kwzrd2020-03-15-1/+1
|\ | | | | | | | | | | | | This merges the newly added help cog. Resolve slight conflict in the __main__ module caused by the the master branch still assuming the presence of the legacy season manager cog.
| * (Help): Added unloading block in cogs loadingGravatar ks1232020-03-07-1/+1
| |
* | Deseasonify: add `set_banner` method to SeasonalBotGravatar kwzrd2020-03-14-0/+18
| |
* | Add meta methods to Bot class.Gravatar scragly2019-12-06-1/+97
|/
* Initial linting passGravatar S. Co12019-09-09-4/+4
| | | | Bot root, seasons cog, easter cogs, evergreen cogs, halloween cogs
* Move bot out of constants.py to bot.pyGravatar kosayoda2019-08-05-3/+6
|
* Relint Seasonalbot with new linting rulesGravatar sco12019-04-24-3/+0
|
* Merge branch 'master' into flake8-docstringGravatar sco12019-03-26-6/+2
|\ | | | | | | Resolve merge conflicts
| * Recombine error handlers into the main listener. Fix cooldown revert.Gravatar Scragly2019-03-26-14/+3
| |
| * Merge branch 'master' into dpy-cog-changesGravatar sco12019-03-09-1/+1
| |\
| * | Add new Cog class inheritance & event listener decorationGravatar sco12019-03-03-1/+2
| | | | | | | | | Mitigates recent breaking d.py changes
* | | Rephrase docstring to be consistent with function verbageGravatar Mark2019-03-20-1/+1
| | | | | | | | | Co-Authored-By: sco1 <[email protected]>
* | | Docstring pass for top-level bot functionsGravatar sco12019-03-18-7/+7
| |/ |/|
* | Make this pig flyGravatar Chris Goes2019-03-04-1/+1
|/
* Refine love calculator commandGravatar Ava2019-02-15-0/+8
|
* Send devlog message on season load.Gravatar Scragly2018-12-05-0/+21
|
* Allows you to create Seasons. (#64)Gravatar Leon Sandøy2018-11-27-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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]>
* Adding Pale Man, fixing all flake8 issues, converting halloweenify to use ↵Gravatar Leon Sandøy2018-10-11-39/+0
| | | | aiohttp, fixing broken logging, ignoring irrelevant loggers, and turning the script into a valid module script.
* Merge branch 'master' into masterGravatar ninexball2018-10-08-0/+1
|\
| * Add Hacktoberfest user stats cog (#7)Gravatar sco12018-10-07-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initialize Hacktoberfest stats cog * Fix generated grammar, add temporary variables to shorten string gen * Code review modifications Adjust variable & function names to be more in line with PEP8's recommendations. Break API query URL into multiple parts to aid readability and customization Adjust command input to explicitly accept a username input rather than star packing & unpacking. d.py guards against too many inputs for us Change _getURL to _get_shortname and adjust documentation because we're not even doing what the function name and documentation said we were * Remove hardcoded response channel * Update prefixes Spoooooky * Swap emoji for unicode string 👻👻👻 * Change unicode ghost string to a friendlier ghost string See: Casper, the Friendly Ghost
* | Added basic logging to bot.pyGravatar ninexball2018-10-08-6/+22
|/
* Fix improper docstrings and comments.Gravatar Marko Kovačević2018-10-03-2/+3
|
* Add some comments and docstrings documenting the code and replacing minor ↵Gravatar Marko Kovačević2018-10-02-4/+4
| | | | issues.
* Implemented flake8 and a Discord Bot base.Gravatar Marko Kovačević2018-10-02-0/+21