aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeLines
* Change Default AoC Commands ChannelGravatar janine9vn2020-12-11-1/+1
| | | | | | | Changes the default value of the advent_of_code_commands constant to be the same channel ID as sir-lancebot-commands. If no AoC commands channel is set in the .env file, it'll re-direct people to sir-lancebot-commands instead.
* Remove extra pleaseGravatar janine9vn2020-12-11-1/+1
| | | | Please -= 1
* Remove re-raising the errorGravatar janine9vn2020-12-11-2/+0
| | | | Per Mark's comment, re-raising the error isn't necessary.
* Change custom error handler to match new styleGravatar janine9vn2020-12-11-1/+1
| | | | | I'm a bit ahead of the game and changing the error handler to match the new style that Iceman will PR shortly.
* Add cog-level error handler for Incorrect ChannelGravatar janine9vn2020-12-11-6/+18
| | | | | | | | | If any of the "spammier" commands (stats, leaderboard) are used within the primary advent of code channel, rather than a non-specific embed we instead reply with the channel they should be using. This also adds a "AOC_WHITELIST_PLUS" constant that makes it easier to adjust what channels the non-spammier aoc commands can be used in.
* Disallow .aoc commands in primary aoc channelGravatar janine9vn2020-12-11-5/+6
| | | | | | | | | | | | Commands like `.aoc leaderboard` and `.aoc stats` proved to be spammy in the main advent of code channel. An aoc_commands channel has been added for aoc commands and this update prohibits aoc commands from being used in the primary aoc channel and adds the comands channel to the whitelist. This also specifically allows the less spammier commands: join, subscribe, unsubscribe, and countdown in the primary channel to foster discussion though.
* Merge pull request #540 from RohanJnr/error_handler_changesGravatar Mark2020-12-11-21/+10
|\ | | | | Modify error handler check for locally handled errors.
| * Check if error.original is an instance of OSError.Gravatar Rohan2020-12-11-4/+3
| | | | | | | | Also, remove error handler for get_command and video_command.
| * Modify snakes_cog error handler.Gravatar Rohan2020-12-07-16/+6
| | | | | | | | | | local error handler no longer checks for BadArgument error and the attribute handled will be set to True on the error if an OSError occurs.
| * Check value of handled attribute on error in global error handler.Gravatar Rohan2020-12-04-1/+1
| |
| * Modify error handler check for locally handled errors.Gravatar Rohan2020-12-02-2/+2
| | | | | | | | | | Error handler now checks if the error has the attribute "handled" for locally handled errors.
* | Make sure PR artifacts are always uploadedGravatar Sebastiaan Zeeff2020-12-11-1/+1
| | | | | | We need to upload PR artifacts regardless of our lint job failing. As GitHub Actions uses an implicit "success" status function if you don't specify one of your own, we need to include the "always" function in our condition.
* | Skip status embed for skipped Build workflowGravatar Sebastiaan Zeeff2020-12-10-2/+3
| | | | | | With the new `workflow_run` setup, we need to make sure that we don't try to send an embed for a skipped workflow. This would be noisy and does not add a lot of useful information.
* | Use Build Artifact to communicate PR informationGravatar Sebastiaan Zeeff2020-12-10-18/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A workflow run with a `workflow_run` payload does not contain the necessary information to build a PR embed. As the old method of using the API to fetch the relevant information turned out to be fragile (read note 1 below) and the original Lint workflow already contains the `pull_request` payload, we now store it as a build artifact. The embed workflow then fetches the artifact and parses it to get the relevant information out of it. --- Note 1: Unfortunately, filtering Pull Requests using the "head" parameter of the ``/repos/{owner}/{repo}/pulls` endpoint does not work if the PR belongs to a fork with a different name than the base repository: the API request will just return an empty array. I've contacted GH to ask if this was intended or if it's a glitch, but, for now, it's not a route that's easily available.
* | Use workflow_run to send status embed to DiscordGravatar Sebastiaan Zeeff2020-12-09-63/+71
| | | | | | | | | | | | | | | | | | | | I've changed the way we send status embeds to make it work for PRs made from forks without potentially exposing secrets. Instead of using the initial workflows to send the embed, I've created a `workflow_run` workflow that always runs in the context of the base repository. And added benefit is that we don't have to add the status embed step to two separate workflows.
* | Merge pull request #542 from python-discord/sebastiaan/ci/status-embedsGravatar Dennis Pham2020-12-07-0/+63
|\ \ | | | | | | Use custom status embeds for workflow runs
| * \ Merge branch 'master' into sebastiaan/ci/status-embedsGravatar Dennis Pham2020-12-07-166/+3
| |\ \ | |/ / |/| |
* | | Merge pull request #543 from python-discord/update-approval-policiesGravatar Joe Banks2020-12-06-166/+3
|\ \ \
| * | | Create review-policy.ymlGravatar Joe Banks2020-12-06-0/+3
| | | |
| * | | Delete review check GitHub ActionGravatar Joe Banks2020-12-06-166/+0
|/ / /
| * / Use custom status embeds for workflow runsGravatar Sebastiaan Zeeff2020-12-05-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).
* | Mitigate session expiry by using fallback sessionGravatar Sebastiaan Zeeff2020-12-05-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.
* | Support a fallback session cookie in constantsGravatar Sebastiaan Zeeff2020-12-05-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.
* Fix leaderboard glitch caused by duplicate namesGravatar Sebastiaan Zeeff2020-12-02-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
* 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.
* Merge pull request #531 from python-discord/ks123/advent-of-codeGravatar Sebastiaan Zeeff2020-11-30-757/+748
|\ | | | | Advent of Code 2020
| * Merge branch 'master' into ks123/advent-of-codeGravatar Sebastiaan Zeeff2020-11-30-6/+169
| |\ | |/ |/|
* | Merge pull request #532 from ↵Gravatar Matteo Bertucci2020-11-30-6/+169
|\ \ | | | | | | | | | | | | python-discord/sebastiaan/ci/add-core-dev-approval-check Add check for core dev approvals on pull requests
| * | Update CODEOWNERS for Den4200.Gravatar Den42002020-11-30-6/+3
| | |
| * | Merge branch 'master' into sebastiaan/ci/add-core-dev-approval-checkGravatar Matteo Bertucci2020-11-30-0/+8
| |\ \ | |/ / |/| |
| * | Add check for core dev approvals on pull requestsGravatar Sebastiaan Zeeff2020-11-27-0/+166
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a workflow that checks if a pull request has received at least one approval from a core developer. If not, the check will fail and block us from merging the Pull Request. The reason we're adding this check is because we're moving away from making the Core Developers team "code owner" of every line in every repository. This created a lot of "notification" spam, which drowned out the actually relevant notifications. This will accomplish the same, at least one core dev needs to approve, but without the notification spam.
| | * 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.
| | * Merge branch 'master' into ks123/advent-of-codeGravatar Sebastiaan Zeeff2020-11-30-2/+10
| | |\ | |_|/ |/| |
* | | Add myself to CODEOWNERS of CI filesGravatar Sebastiaan Zeeff2020-11-27-1/+1
| | |
* | | Add @Akarys42 to the codeownersGravatar Matteo Bertucci2020-11-27-0/+8
|/ /
* | Update CODEOWNERSGravatar Joe Banks2020-11-26-2/+2
| |
* | Update CODEOWNERSGravatar Dennis Pham2020-11-24-2/+2
| |
| * 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.