aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeLines
* Add custom exceptions for each error state.Gravatar Leon Sandøy2020-05-28-8/+21
| | | | | | | | | | | | | | The bot can get into trouble in three distinct ways: - It has no Bot instance - It has no namespace - It has no parent instance. These happen only if you're using it wrong. To make the test more precise, and to add a little bit more readability (RuntimeError could be anything!), we'll introduce some custom exceptions for these three states. This addresses a review comment by @aeros.
* Make prefix consts private and more precise.Gravatar Leon Sandøy2020-05-28-9/+9
|
* Reduce complexity on some of the typestring stuff.Gravatar Leon Sandøy2020-05-28-31/+9
| | | | | | | | | - Refactor error messages in _to_typestring and _from_typestring to just print the prefix tuples instead of that custom error string. - Create a RedisKeyOrValue type to simplify some annotations. - Simplify partialmethod calls. - Make the signatures for _to_typestring and _from_typestring one-liners - Fix a typo in the errors.
* Merge branch 'master' into redis_persistenceGravatar Leon Sandøy2020-05-27-80/+154
|\
| * Merge pull request #961 from ↵Gravatar Sebastiaan Zeeff2020-05-27-88/+161
| |\ | | | | | | | | | | | | python-discord/moderation_commands_in_modmail_category Permit moderation commands in ModMail category
| | * Add some tests for `in_whitelist_check`.Gravatar Leon Sandøy2020-05-27-0/+48
| | |
| | * Remove the now deprecated in_channel_check.Gravatar Leon Sandøy2020-05-27-16/+0
| | | | | | | | | | | | | | | This check was no longer being used anywhere, having been replaced by in_whitelist_check.
| | * Merge branch 'master' into moderation_commands_in_modmail_categoryGravatar Joseph Banks2020-05-27-0/+1
| | |\ | | |/ | |/|
| * | Add /r/FlutterDev to the guild invite whitelistGravatar Dennis Pham2020-05-26-0/+1
| | |
| | * Allow some commands to fail checks silently.Gravatar Leon Sandøy2020-05-27-2/+9
| | | | | | | | | | | | | | | | | | For example, we don't want the mod commands to produce any kind of error message when run by ordinary users in regular channels - these should have the perception of being invisible and unavailable.
| | * No redirect for mod management.Gravatar Leon Sandøy2020-05-27-0/+1
| | |
| | * Find + change all InWhitelistCheckFailure importsGravatar Leon Sandøy2020-05-27-9/+8
| | |
| | * Allow infraction management in modmail categoryGravatar Leon Sandøy2020-05-27-12/+13
| | |
| | * Refactor the in_whitelist deco to a check.Gravatar Leon Sandøy2020-05-27-53/+86
| |/ | | | | | | | | | | | | | | | | We're moving the actual predicate into the `utils.checks` folder, just like we're doing with most of the other decorators. This is to allow us the flexibility to use it as a pure check, not only as a decorator. This commit doesn't actually change any functionality, just moves it around.
* | Fix ATROCIOUS comment.Gravatar Leon Sandøy2020-05-27-3/+5
| | | | | | | | I should be shot.
* | Refactor typestring converters to partialmethods.Gravatar Leon Sandøy2020-05-27-30/+24
| | | | | | | | | | | | | | | | | | We're using functools.partialmethod to make the code a little cleaner and more readable here. Read more about them here: https://docs.python.org/3/library/functools.html#functools.partial https://docs.python.org/3/library/functools.html#functools.partialmethod
* | Floats are no longer permitted as RedisCache keys.Gravatar Leon Sandøy2020-05-27-43/+86
| | | | | | | | | | | | | | Also added a test for this. This is the DRYest approach I could find. It's a little ugly, but I think it's probably good enough.
* | Refactor .increment and add lock test.Gravatar Leon Sandøy2020-05-27-65/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The way we were doing the asyncio.Lock() stuff for increment was slightly problematic. @aeros has adviced us that it's better to just initialize the lock as None in __init__, and then initialize it inside the first coroutine that uses it instead. This ensures that the correct loop gets attached to the lock, so we don't end up getting errors like this one: RuntimeError: got Future <Future pending> attached to a different loop This happens because the lock and the actual calling coroutines aren't on the same loop. When creating a new test, test_increment_lock, we discovered that we needed a small refactor here and also in the test class to make this new test pass. So, now we're creating a DummyCog for every test method, and this will ensure the loop streams never cross. Cause we all know we must never cross the streams.
* | Clear cache in asyncSetUp instead of tests.Gravatar Leon Sandøy2020-05-27-6/+1
| |
* | Merge branch 'master' into redis_persistenceGravatar Leon Sandøy2020-05-26-24/+97
|\|
| * Merge pull request #866 from python-discord/restricted_tagsGravatar Shirayuki Nekomata2020-05-26-17/+42
| |\ | | | | | | feature to restrict tags to specific role(s)
| | * Merge branch 'master' into restricted_tagsGravatar Shirayuki Nekomata2020-05-26-955/+2577
| | |\ | | |/ | |/|
| * | [stats] Do not report modmail channels to statsGravatar Joseph Banks2020-05-26-1/+11
| | |
| * | Merge pull request #936 from python-discord/bug/filters/929/invalid-invitesGravatar kwzrd2020-05-25-1/+3
| |\ \ | | | | | | | | Filtering: don't attempt to send additional embeds for invalid invites
| | * \ Merge branch 'master' into bug/filters/929/invalid-invitesGravatar kwzrd2020-05-25-594/+833
| | |\ \ | | |/ / | |/| |
| * | | Add discord.gift to URL blacklist, closes #958Gravatar Joseph Banks2020-05-24-0/+1
| | | |
| * | | Merge pull request #956 from ks129/help-channels-deleteGravatar Sebastiaan Zeeff2020-05-24-5/+40
| |\ \ \ | | | | | | | | | | Help System: Move dormant faster if help channel is empty
| | * \ \ Merge branch 'master' into help-channels-deleteGravatar Sebastiaan Zeeff2020-05-24-8/+64
| | |\ \ \ | | |/ / / | |/| | |
| | * | | HelpChannels: remove `is_dormant_message`Gravatar MarkKoz2020-05-22-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | At this point, it's just a thin wrapper to call another function. It's redundant.
| | * | | HelpChannels: move message None check inside `match_bot_embed`Gravatar MarkKoz2020-05-22-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | It was being done repeatedly outside the function so let's move it in to reduce redundancy.
| | * | | HelpChannels: rename `embed_description_match`Gravatar MarkKoz2020-05-22-5/+5
| | | | |
| | * | | HelpChannels: fix `is_empty` not being awaitedGravatar MarkKoz2020-05-22-2/+5
| | | | |
| | * | | Help: Create `embed_description_match`Gravatar ks1292020-05-22-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Created function `embed_description_match`. - Implemented this to `is_empty` - Implemented this to `is_dormant_message`
| | * | | Help: Fix docstrings of `is_empty` and `on_message_delete`Gravatar ks1292020-05-22-2/+6
| | | | | | | | | | | | | | | Co-authored-by: Mark <[email protected]>
| | * | | Help: Implemented faster close when claimant delete msg no more messagesGravatar ks1292020-05-21-1/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Created function `is_empty` that check is there any message in channel after bot own available message. - `on_message_delete` that reschedule task when message is on correct channel and is empty. - In `move_idle_channel` function, implemented choosing right cooldown, based on is channel empty or not.
| | * | | Config: Added new `HelpChannels` config `deleted_idle_minutes`Gravatar ks1292020-05-21-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | This show how much minutes should this wait before making channel dormant when no messages in channel (original message deleted).
| | | * | Filtering: don't attempt to send additional embeds for invalid invitesGravatar MarkKoz2020-05-10-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Invalid invites won't have data available to put in the embeds. Fixes #929 Fixes BOT-3Z
| | | | * Tags: always use top-most folder for role restrictionsGravatar MarkKoz2020-04-18-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | Ensures that nested directories aren't used as the value for the role name.
| | | | * simplGravatar Rohan Reddy Alleti2020-04-14-3/+1
| | | | | | | | | | | | | | | Co-Authored-By: Mark <[email protected]>
| | | | * simplify if statementGravatar Rohan Reddy Alleti2020-04-14-4/+2
| | | | | | | | | | | | | | | Co-Authored-By: Mark <[email protected]>
| | | | * Feature now is cross-platformGravatar rohanjnr2020-04-14-7/+10
| | | | | | | | | | | | | | | | | | | | Instead of using string methods to split the file path at `/` which is not cross-platform, I am now entirely using pathlib methods to get the parent folder and restrict the tags.
| | | | * Remove unnecessary variable creation and join two if statementsGravatar rohanjnr2020-04-05-5/+6
| | | | |
| | | | * Add feature to restrict tags to specific role(s)Gravatar rohanjnr2020-04-05-15/+37
| | | | |
* | | | | Add a test for RuntimeErrors.Gravatar Leon Sandøy2020-05-26-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This just tests that the various RuntimeErrors are reachable - that includes the error about not having a bot instance, the one about not being a class attribute, and the one about not having instantiated the class. This test addresses a concern raised by @MarkKoz in a review. I've decided not to test that actual contents of these RuntimeErrors, because I believe that sort of testing is a bit too brittle. It shouldn't break a test just to change the content of an error string.
* | | | | Swap the order for the validate_cache checks.Gravatar Leon Sandøy2020-05-26-8/+8
| | | | |
* | | | | Improve some docstrings for RedisCache.Gravatar Leon Sandøy2020-05-26-5/+3
| | | | | | | | | | | | | | | | | | | | Thanks @MarkKoz!
* | | | | Make self.increment_lock private.Gravatar Leon Sandøy2020-05-26-2/+2
| | | | |
* | | | | Add better docstring for RedisCache.updateGravatar Leon Sandøy2020-05-26-2/+12
| | | | |
* | | | | Fix edge case where pop might not delete.Gravatar Leon Sandøy2020-05-26-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you passed a key for a value that was the same as your optional, it would just return it but not delete it. This edge case isn't worth it, so I'm just removing that condition and letting the extra API call fly.
* | | | | Turn log.exception into log.errorGravatar Leon Sandøy2020-05-26-17/+22
| | | | | | | | | | | | | | | | | | | | | | | | | Also, refactor error messages to be consistent and DRY throughout the file.