aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeLines
...
* | | | | | | Merge pull request #972 from Numerlor/tag-encodingGravatar Mark2020-05-29-1/+1
|\ \ \ \ \ \ \ | |_|_|_|/ / / |/| | | | | | Specify encoding when reading tag files
| * | | | | | Tags: explicitly use UTF-8 to read filesGravatar MarkKoz2020-05-30-1/+1
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not all operating systems use UTF-8 as the default encoding. For systems that don't, reading tag files with Unicode would cause an unhandled exception. (cherry picked from commit adc75ff9bbcf8b905bd78c78f253522ae5e42fc3)
* | | | | | Merge pull request #965 from Akarys42/patch-1Gravatar Dennis Pham2020-05-29-0/+1
|\ \ \ \ \ \ | |_|_|/ / / |/| | | | | Ignore response when posting python news
| * | | | | Merge branch 'master' into patch-1Gravatar Dennis Pham2020-05-29-31/+8
| |\ \ \ \ \ | |/ / / / / |/| | | | |
* | | | | | Merge pull request #966 from python-discord/sebastiaan/help-channels/ratelimitsGravatar Joseph Banks2020-05-29-31/+8
|\ \ \ \ \ \ | |_|_|_|_|/ |/| | | | |
| * | | | | Reduce the number of help channel name changesGravatar Sebastiaan Zeeff2020-05-29-29/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Discord has introduced a new, strict rate limit for individual channel edits that reduces the number of allow channel name/channel topic changes to 2 per 10 minutes per channel. Unfortunately, our help channel system frequently goes over that rate limit as it edits the name and topic of a channel on all three "move" actions we have: to available, to occupied, and to dormant. In addition, our "unanswered" feature adds another channel name change on top of the move-related edits. That's why I've removed the topic/emoji changing features from the help channel system. This means we now have a generic topic that fits all three categories and no status emojis in the channel names.
| * | | | | Fix `check_for_answer` breaking on missing cacheGravatar Sebastiaan Zeeff2020-05-29-2/+5
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `check_for_answer` method of the HelpChannels cog relies on the channel->claimant cache being available. However, as this cache is (currently) lost during bot restarts, this method may fail with a KeyError exception. I've used `dict.get` with an `if not claimant: return` to circumvent this issue.
| * / / / Ignore response when posting python newsGravatar Matteo Bertucci2020-05-29-0/+1
|/ / / / | | | | | | | | Sometimes a mailing list user doesn't press respond correctly to the email, and so a response is sent as a separate thread. To keep only new threads in the channel, we need to ignore those.
* | | | Merge pull request #947 from python-discord/redis_persistenceGravatar Sebastiaan Zeeff2020-05-28-182/+1061
|\ \ \ \ | | | | | | | | | | RedisCache - Data Persistence
| * | | | Move the `self.redis_closed` into session create.Gravatar Leon Sandøy2020-05-28-1/+1
| | | | |
| * | | | Prevent a state where a coro could wait forever.Gravatar Leon Sandøy2020-05-28-2/+6
| | | | | | | | | | | | | | | | | | | | This addresses a review comment by @aeros.
| * | | | 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
| |\ \ \ \ \ | |/ / / / / |/| | | | |
| * | | | | 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
| | |\ \ \ \ | | |/ / / / | |/| | | |
| | * | | | 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.
| | * | | | Expose the redis port to the hostGravatar MarkKoz2020-05-25-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Useful for those that run redis with docker-compose but not the bot. The bot on the host won't have access to the Docker network in such case so the port must be exposed.
| | * | | | Improve output of section name in config validation subtestsGravatar MarkKoz2020-05-25-1/+1
| | | | | |
| | * | | | Support validating collection types for constantsGravatar MarkKoz2020-05-25-8/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a simple validation that only check the type of the collection. It does not validate the types inside the collection because that has proven to be quite complex.
| | * | | | Add support for Union type annotations for constantsGravatar MarkKoz2020-05-24-12/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note that `Optional[x]` is just an alias for `Union[None, x]` so this effectively supports `Optional` too. This was especially troublesome because the redis password must be unset/None in order to avoid authentication, but the test would complain that `None` isn't a `str`. Setting to an empty string would pass the test but then make redis authenticate and fail.
| | * | | | Improve error and error testing for incrementGravatar Leon Sandøy2020-05-24-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changed a RuntimeError to a KeyError (thanks @MarkKoz), and also added some tests to ensure that the right errors are raised whenever this method is used incorrectly.
| | * | | | Add an option to use fakeredis in Bot.Gravatar Leon Sandøy2020-05-24-48/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this option, all contributors would need to set up a Redis server in order to run the bot. But with use_fakeredis set to True, this is no longer necessary because it will just set up a fakeredis redis pool instead of trying to contact an actual server. This is more than good enough for most local testing purposes, since data persistence across restarts isn't really relevant for them. This also means we need to move fakeredis into our real dependency list instead of having it as a dev dependency, so there's a minor change for that as well. I also made a small kaizen change to sort all the dependencies in the Pipfile alphabetically.
| | * | | | MockBot needs to be aware of redis_readyGravatar Leon Sandøy2020-05-24-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Forgot to update the additional_spec_asyncs when changing the name of this Bot attribute to be public.
| | * | | | Add logging to the RedisCache.Gravatar Leon Sandøy2020-05-24-3/+39
| | | | | | | | | | | | | | | | | | | | | | | | Mostly trace and exception logging.
| | * | | | Rename Bot._redis_ready to Bot.redis_readyGravatar Leon Sandøy2020-05-24-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | It's a public attribute, we're accessing it from RedisCache.
| | * | | | Add .increment and .decrement methods.Gravatar Leon Sandøy2020-05-24-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes, we just want to store a counter in the cache. In this case, it is convenient to have a single method that will allow us to increment or decrement this counter. These methods allow you to decrement or increment floats and integers by an specified amount. By default, it'll increment or decrement by 1. Since this involves several API requests, we create an asyncio.Lock so that we don't end up with race conditions.
| | * | | | Make .items return ItemsView instead of AsyncIterGravatar Leon Sandøy2020-05-24-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There really was no compelling reason why this method should return an AsyncIterator or than that `async for items in cache.items()` has nice readability, but there were a few concerns. One is a concern about race conditions raised by @SebastiaanZ, and @MarkKoz raised a concern that it was misleading to have an AsyncIterator that only "pretended" to be lazy. To address these concerns, I've refactored it to return a regular ItemsView instead. I also improved the docstring, and fixed the relevant tests.
| | * | | | Better RuntimeErrors.Gravatar Leon Sandøy2020-05-24-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | We provide suggestions for how to solve these problems now.
| | * | | | Improves various docstrings and comments.Gravatar Leon Sandøy2020-05-24-10/+27
| | | | | | | | | | | | | | | | | | | | | | | | Thanks to @MarkKoz for suggesting most of these in their code review.