aboutsummaryrefslogtreecommitdiffstats
path: root/bot (follow)
Commit message (Collapse)AuthorAgeLines
* Let puzzle notification sleep until AoC startsGravatar Sebastiaan Zeeff2020-12-01-58/+77
| | | | | | | | | | | | | | | | | | | | | | | Instead of cancelling the task when it starts up outside of the boundaries of the Advent of Code, the task will now hibernate until just before the event starts if starts up before December. This allows it to actually announce the first puzzle. After the announcement for the last day of the current event is made, it will terminate itself. It will only start hibernating again when we've updated the environment variables for next year's event, ensuring that it does not run unnecessarily. To prevent issues with the guild cache not being available, I've added our new `wait_until_guild_available` waiting function. I've also moved the calls that get teh role/channel to before the loop, as there's no need to get them each time the loop goes around. I've also changed the way we calculate the time we need to sleep, as the old way used truncated seconds, meaning that we would always wake up relatively early. Instead, I'm now using fractional seconds, which means we can reduce the safety padding to a fraction of second. More accurate announcement timing!
* Ensure status countdown waits for bot start-upGravatar Sebastiaan Zeeff2020-12-01-0/+4
| | | | | | | | | | | | Trying to change the rich presence status of the bot too early in the bot's start-up sequence will cause the task to fail. To make it wait, I've added a `bot.wait_until_guild_available` point before the main loop of the task starts. This seems to solve the issue reliably, despite the `guild_available` event not being directly related to when the bot's connection with the API is ready to accept presence updates. However, the `ready` event is know to fire too early, according to the discord.py community.
* Let status update task sleep until the AoC startsGravatar Sebastiaan Zeeff2020-12-01-31/+60
| | | | | | | | | | | | | | | I've refactored the rich presence countdown task by making it hibernate until 2 hours before the next Advent of Code starts if the task starts up before the event has started. This ensures that the task will run when the event starts and allows it to countdown to the first challenge. After the event for the configured Advent of Code year has finished, the task will terminate. This also means that the task will terminate immediately in the year following the currently configured Advent of Code; it will only start hibernating again once we configure the bot for the next event. No unnecessary, year-long hibernation.
* Add function that allows tasks to sleep until AoCGravatar Sebastiaan Zeeff2020-12-01-0/+22
| | | | | | | | | | | | | | | | | | Our Advent of Code background tasks were written in such a way that they relied on the extension being loaded in December and only in December. However, since the deseasonification, the extension is loaded prior to December, with some commands being locked to that month with a check instead. This meant that our background tasks immediately cancelled themselves, as they observed themselves to be running outside of the boundaries of the event. As there was no mechanism for starting them back up again, these tasks would only start running again after redeployment of Sir Lancebot. To solve this issue, I've added a helper function that allows tasks to wait until a x hours before the event starts. This allows them to wake up in time to prepare for the release of the first puzzle.
* Fix daily stats by converting day, star to strGravatar Sebastiaan Zeeff2020-12-01-2/+3
| | | | | | | The daily stats function contained a bug that prevented it from working correctly. The reason was that I was looking for `int` keys where the actual keys were strings. I now make sure to create a `str` from the `int` I get back from `range`.
* Add support for ignoring scores from specific daysGravatar Sebastiaan Zeeff2020-12-01-3/+17
| | | | | | | | | | | | | | I've added support for ignoring scores from specific days. A list of days to ignore can be provided using the environment variable `AOC_IGNORED_DAYS` as a comma-separated list. This example would ignore day 1 and day 23: AOC_IGNORED_DAYS=1,23 I've also added a helper function to sort the leaderboard not only on the achieved score, but also on the number of stars an individual has completed.
* Clarify text of DM with Advent of Code join codeGravatar Sebastiaan Zeeff2020-11-30-5/+7
|
* Add note about refresh time to info embedGravatar Sebastiaan Zeeff2020-11-30-0/+2
|
* Enable AOC commands before DecemberGravatar Sebastiaan Zeeff2020-11-30-1/+11
| | | | | Note: This won't start the countdown functions yet, they still rely on the cog being loaded in december.
* Set character encoding for logging to utf-8Gravatar Sebastiaan Zeeff2020-11-30-2/+3
|
* Move helper functions to the ._helpers moduleGravatar Sebastiaan Zeeff2020-11-30-35/+42
| | | | | I've moved the helper functions to the _helpers.py module and clarified the docstring of the `is_in_advent` helper function.
* Remove constants replaced by AOC_LEADERBOARDSGravatar Sebastiaan Zeeff2020-11-30-3/+0
| | | | | There were still two constants left over that were no longer used after the rewrite. I've removed them.
* Update information for the .aoc about embedGravatar Sebastiaan Zeeff2020-11-30-4/+4
| | | | | | | | | | | I've updated the information for the about embed: - Added information on the scoring of private leaderboards - Changed the text of "join our private leaderboard", as we no longer have to introduce private leaderboards there. - I've also streamlined the section on Auth providers.
* Add global leaderboard command backGravatar Sebastiaan Zeeff2020-11-30-0/+16
| | | | | I accidentally removed the global leaderboard command. I've added it back!
* Fix docstrings and add a few explanatory commentsGravatar Sebastiaan Zeeff2020-11-30-5/+8
|
* Set correct channel ID as default for AoC channelGravatar Sebastiaan Zeeff2020-11-30-1/+1
|
* Remove now redundant advent_of_code_staff constantGravatar Sebastiaan Zeeff2020-11-30-2/+1
| | | | | We're no longer going to use a two-channel setup for this event, as we don't want to split the event community into two, staff and non-staff.
* Remove redundant _error_embed_helper functionGravatar Sebastiaan Zeeff2020-11-30-7/+3
| | | | | | This helper function was only being used in one spot and did not factor out any logic. I've removed the helper function to just create the embed where it's needed.
* Rewrite Advent of Code leaderboard logicGravatar Sebastiaan Zeeff2020-11-30-0/+680
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've rewritten the Advent of Code leaderboard logic. Unfortunately, nearly all of the changes made are interrelated, meaning that they've ended up in the same commit. To add a bit of structure to the extension, I've chosen for a subpackage structure instead of a single file structure. The biggest changes: - Whether or not you get a join code for the staff leaderboard will now be determined by looking for the Helpers-role. - The Python Discord Leaderboard now includes all boards, including the staff leaderboard. This is one event. - Redis is now used to set a cache expiry period. This means that our code does not have to check for cache staleness; Redis will do that for us. - The period "fetching" task has been removed. We now fetch solely when the data is needed to prevent putting unnecessary stress on the Advent of Code website. - The option to display the Global Leaderboard within Discord has been removed. Rather, we now link to the website. This simplified the code for now, although we could add it back later. - An additional command, `.aoc refresh`, has been added to allow Admins and the Events Lead to force the cache to be invalidated. This should be done sparingly to not overburden the AoC website. - I've also made sure that the daily notification task actually pings the notification role by setting the `allowed_mentions` kwarg.
* Remove adventofcode.py in favour of subpackageGravatar Sebastiaan Zeeff2020-11-30-983/+0
| | | | | | As the Advent of Code file was getting massive, I've removed the old single-file based extension as I'm going to replace it with a partially rewritten subpackage-based extension.
* Add constants parsing for multiple leaderboardsGravatar Sebastiaan Zeeff2020-11-30-9/+38
| | | | | | | | | | | | | | | | | | | | I've added a unified approach to setting data for multiple leaderboards using environmental variables. Instead of setting separate variables for the three pieces of data we have, hoping that the position of each board matches up in the three fields, I now set one environmental variable, AOC_LEADERBOARDS, that holds delimited data. The data is in the format: board_id1,session1,join_code1::board_id2,session2,join_code2[::...] The staff leaderboards should be included as usual in this environmental variable. Another environment variable, AOC_STAFF_LEADERBOARD_ID, can be used to designate which leaderboard should be used as the staff board. I've also made some other constants configurable in this commit and added the role ID of the Events Lead role to allow the Events Lead to force a reload of the leaderboard cache.
* Fix adventofcode extension (and constants) grammarGravatar ks1292020-11-27-12/+12
| | | Co-authored-by: Joe Banks <[email protected]>
* Use default 0 for score and reverse leaderboard membersGravatar ks1292020-11-27-1/+3
|
* Handle leaderboard cache create/update failGravatar ks1292020-11-27-12/+52
|
* Remove unnecessary check for members in leaderboard updater taskGravatar ks1292020-11-27-3/+1
|
* Add comment about choosing leaderboard for userGravatar ks1292020-11-27-0/+1
|
* Store AoC leaderboard IDs instead join codes for users mappingGravatar ks1292020-11-26-5/+10
|
* Implement staff and public leaderboardsGravatar ks1292020-11-26-58/+197
|
* Implement different invitation codes for staff and public leaderboardsGravatar ks1292020-11-25-11/+66
|
* Add comments about AoC env config order and change cookies wayGravatar ks1292020-11-24-1/+4
|
* Add staff AoC channel to whitelistGravatar ks1292020-11-24-1/+1
|
* Update constants to match with new format of AoC that will run in 2020Gravatar ks1292020-11-24-3/+6
|
* Merge branch 'master' into feature/wonder-twins-commandGravatar ks1292020-11-23-1064/+148
|\
| * Remove dead ShowProjects cog.Gravatar Leon Sandøy2020-11-21-37/+2
| | | | | | | | We no longer have this channel, so this cog serves no purpose.
| * Remove references to old name.Gravatar Leon Sandøy2020-11-21-60/+55
| | | | | | | | | | I've tried to replace this with generic references where appropriate, but a lot of the time it just doesn't make a lot of sense to do so.
| * Make the bot name less hard-coded.Gravatar Leon Sandøy2020-11-21-19/+22
| |
| * Get rid from branding management stuffGravatar ks1292020-11-17-836/+5
| |
| * Remove unnecessary JSON filesGravatar ks1292020-11-16-5/+0
| |
| * Port HacktoberStats cog to use Redis instead of JSONGravatar ks1292020-11-16-67/+12
| |
| * Port candy_collection.py to use Redis instead of JSONGravatar ks1292020-11-16-34/+26
| |
| * Migrate branding from JSON persist to RedisGravatar ks1292020-11-16-25/+13
| |
| * Implement Redis connection to bot class and create instanceGravatar ks1292020-11-16-2/+26
| |
| * Rename redis configuration classGravatar ks1292020-11-16-1/+2
| |
| * Create Redis configuration classGravatar ks1292020-11-16-0/+7
| |
* | fix typos in docstringGravatar fisher602020-11-22-1/+1
| |
* | make init variables more readable, fix docstring, remove redundant listGravatar fisher602020-11-22-6/+6
| |
* | move constants to init, change [-1] to .endswith()Gravatar fisher602020-11-21-9/+9
| |
* | feature/add wonder twins commandGravatar fisher602020-11-19-0/+148
| | | | | | | | This commit implements a wonder twins inspired command. This is a purely fun command that uses real transformations from the show to make random new transformations. The yaml is all hand transcribed from the actual show.
* | Fix lint errors introduced by persistence removalGravatar Sebastiaan Zeeff2020-11-16-8/+8
|/ | | | | | | | | | | We ripped some features out of the bot to make the migration to kubernetes easier. However, that process left us with some linting errors that will play up if anyone makes a PR. I've added "noqa" to the valid TODO lines and commented out lines that introduced now unused names or tried to use now undefined names. This should have no influence on the bot, as it does not touch code that is actually being run at the moment.
* Remove make_persistent import from bot extensionsGravatar Jeremiah Boby2020-11-14-4/+8
|