aboutsummaryrefslogtreecommitdiffstats
path: root/bot/bot.py (unfollow)
Commit message (Collapse)AuthorLines
2020-12-06Delete review check GitHub ActionGravatar Joe Banks-166/+0
2020-12-05Use custom status embeds for workflow runsGravatar Sebastiaan Zeeff-0/+63
This commit introduces enhanced status embeds for workflow runs that give more information about run that just ended. An added advantage is that we can disable the default "give me everything"-setting of GitHub and fine tune when we want to send embeds. This allows us to only send an embed for the `lint->build` sequence when the sequence ends (e.g. in the end when done or after an intermediate step due to failure/cancellation).
2020-12-05Mitigate session expiry by using fallback sessionGravatar Sebastiaan Zeeff-17/+75
Unfortunately, an expired session cookie wreaked havoc to our Advent of Code commands: All commands that relied on leaderboard data failed because we couldn't refresh our data and the cache had expired. To mitigate an expired session, I've added a fallback session feature that enables us to try again with a different session. While it will issue an error message to inform us to refresh the expired session cookie, it does mean that the functionality should continue to work in the mean time. The fallback session cookie is currently set to my session cookie, using an environment variable, `AOC_FALLBACK_SESSION`. It is important that the user connected to the session is a member of all boards and that it's a fresh session: We don't want our fallback to expire! At the same time, while a single fallback session works, the AoC website also does not like too many requests from a single user. That's why we'll still use a multi-session model under normal circumstances. To check for expired sessions, I've added a URL check: The Advent of Code website will silently redirect people with an expired session, issuing an 200: OK status as usual. The only way to really check for it is by comparing the final URL in the response object to the URL we set out to GET. I've added a custom exception to signal such an unexpected redirect. Finally, instead of having the commands just break, I've added an Exception signal that propagates back to the caller. The solution, with try-except, is a bit hacky and could benefit from an actual error handler, but I wanted to get things fixed first; polish can be added later.
2020-12-05Support a fallback session cookie in constantsGravatar Sebastiaan Zeeff-2/+20
To mitigate problems due to expiring session cookies, I'm currently in the process of adding support for a fallback cookie. Basically, my Advent of Code account is a member of *all* leaderboards, which means that my cookie can be used to fetch all leaderboards as well. As my session cookie should not expire until after the event, it should not give us any issues. However, to avoid issues with issuing too many requests from one session, we should still make sure to set individual session values regardless of the mitigation.
2020-12-02Fix leaderboard glitch caused by duplicate namesGravatar Sebastiaan Zeeff-13/+17
We noticed that some entries on our leaderboard had an incorrect star count attached to their name. After a bit of digging, @HassanAbouelela discovered that this was caused by the use of the member's name as the key for the leaderboard dictionary: If different accounts used the same display name for the leaderboard, they'd be combined into one glitched score dict. The fix @HassanAbouelela wrote is to use the member id instead of the name as the key for the leaderboard. I've changed a few names here and there, but nothing major. This commit closes #536
2020-12-01Fix daily stats by converting day, star to strGravatar Sebastiaan Zeeff-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`.
2020-12-01Add support for ignoring scores from specific daysGravatar Sebastiaan Zeeff-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.
2020-11-30Clarify text of DM with Advent of Code join codeGravatar Sebastiaan Zeeff-5/+7
2020-11-30Add note about refresh time to info embedGravatar Sebastiaan Zeeff-0/+2
2020-11-30Enable AOC commands before DecemberGravatar Sebastiaan Zeeff-1/+11
Note: This won't start the countdown functions yet, they still rely on the cog being loaded in december.
2020-11-30Update CODEOWNERS for Den4200.Gravatar Den4200-6/+3
2020-11-30Set character encoding for logging to utf-8Gravatar Sebastiaan Zeeff-2/+3
2020-11-30Move helper functions to the ._helpers moduleGravatar Sebastiaan Zeeff-35/+42
I've moved the helper functions to the _helpers.py module and clarified the docstring of the `is_in_advent` helper function.
2020-11-30Remove constants replaced by AOC_LEADERBOARDSGravatar Sebastiaan Zeeff-3/+0
There were still two constants left over that were no longer used after the rewrite. I've removed them.
2020-11-30Update information for the .aoc about embedGravatar Sebastiaan Zeeff-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.
2020-11-30Add global leaderboard command backGravatar Sebastiaan Zeeff-0/+16
I accidentally removed the global leaderboard command. I've added it back!
2020-11-30Fix docstrings and add a few explanatory commentsGravatar Sebastiaan Zeeff-5/+8
2020-11-30Set correct channel ID as default for AoC channelGravatar Sebastiaan Zeeff-1/+1
2020-11-30Remove now redundant advent_of_code_staff constantGravatar Sebastiaan Zeeff-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.
2020-11-30Remove redundant _error_embed_helper functionGravatar Sebastiaan Zeeff-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.
2020-11-30Rewrite Advent of Code leaderboard logicGravatar Sebastiaan Zeeff-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.
2020-11-30Remove adventofcode.py in favour of subpackageGravatar Sebastiaan Zeeff-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.
2020-11-30Add constants parsing for multiple leaderboardsGravatar Sebastiaan Zeeff-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.
2020-11-27Add myself to CODEOWNERS of CI filesGravatar Sebastiaan Zeeff-1/+1
2020-11-27Add @Akarys42 to the codeownersGravatar Matteo Bertucci-0/+8