aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeLines
...
* | | | | 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.
* | | | | Refactor the nice prefix/type strings to constantsGravatar Leon Sandøy2020-05-24-31/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's leaner to just move that code out of the class and up to the module level as constants. This commit also renames ValidRedisType to RedisType.
* | | | | len(prefix) instead of hardcoding 2Gravatar Leon Sandøy2020-05-24-1/+1
| | | | | | | | | | | | | | | Co-authored-by: Mark <[email protected]>
* | | | | use __name__ for type list Gravatar Leon Sandøy2020-05-24-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of relying on __str__ representation, we'll use the __name__ dunder. Co-authored-by: Mark <[email protected]>
* | | | | Merge branch 'master' into redis_persistenceGravatar Leon Sandøy2020-05-23-4/+6
|\| | | |
| * | | | Merge pull request #934 from python-discord/bug/filters/933/dont-delete-in-dmsGravatar Dennis Pham2020-05-23-4/+6
| |\ \ \ \ | | | | | | | | | | | | Filtering: don't delete messages in DMs
| | * \ \ \ Merge branch 'master' into bug/filters/933/dont-delete-in-dmsGravatar Dennis Pham2020-05-23-585/+786
| | |\ \ \ \ | | |/ / / / | |/| | | |
| | * | | | Filtering: don't delete messages in DMsGravatar MarkKoz2020-05-09-4/+6
| | | |/ / | | |/| | | | | | | | | | | | Bots are incapable of deleting direct messages authored by others.
* | | | | Show a warning when redis pool isn't closedGravatar MarkKoz2020-05-23-0/+5
| | | | |
* | | | | Remove redis session mock from MockBotGravatar MarkKoz2020-05-23-16/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's not feasible to mock it because all the commands return futures rather than being coroutines, so they cannot automatically be turned into AsyncMocks. Furthermore, no code should ever use the redis session directly besides RedisCache. Since the tests for RedisCache already use fakeredis, there's no use in trying to mock redis in MockBot.
* | | | | DRY approach to typestring prefix resolutionGravatar Leon Sandøy2020-05-23-15/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thanks to @kwzrd for this idea, basically we're making a constant with the typestring prefixes and iterating that in all our converters. These converter functions will also now raise TypeErrors if we try to convert something that isn't in this constants list. I've also added a new test that tests this functionality.
* | | | | Don't rely on HDEL ignoring keys for .popGravatar Leon Sandøy2020-05-23-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we would try to .delete keys that did not exist if a default was provided when calling .pop. This is okay to do (because HDEL will just ignore any attempts to delete non-existing calls), but it does add an additional pointless API call to Redis, so I've added some validation as a small optimization. This also adds a few additional lines of documentation as requested by @SebastiaanZ in their review.
* | | | | Fix typo in test_to_dict docstringGravatar Leon Sandøy2020-05-23-1/+1
| | | | |
* | | | | Update exception message Gravatar Leon Sandøy2020-05-23-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was incorrectly suggesting the user needed to create an instance of RedisCache, when in fact it is the parent that needs to be instantiated. Co-authored-by: Sebastiaan Zeeff <[email protected]>
* | | | | CI needs REDIS_PASSWORD to pass testsGravatar Leon Sandøy2020-05-23-0/+1
| | | | |
* | | | | Moving the Redis session creation to Bot._recreateGravatar Leon Sandøy2020-05-23-2/+5
| | | | |
* | | | | Unbreak the error_handlerGravatar Leon Sandøy2020-05-23-1/+1
| | | | |
* | | | | Merge branch 'redis_persistence' of github.com:python-discord/bot into ↵Gravatar Leon Sandøy2020-05-23-44/+127
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | redis_persistence
| * | | | | Merge branch 'master' into redis_persistenceGravatar Leon Sandøy2020-05-23-44/+127
| |\| | | |
| | * | | | Merge pull request #945 from ks129/statsGravatar Joseph Banks2020-05-22-1/+36
| | |\ \ \ \
| | | * \ \ \ Merge branch 'master' into statsGravatar Joseph Banks2020-05-22-505/+362
| | | |\ \ \ \ | | | |/ / / / | | |/| | | |
| | * | | | | Merge pull request #942 from ks129/python-news-statsGravatar Joseph Banks2020-05-22-0/+6
| | |\ \ \ \ \
| | | * \ \ \ \ Merge branch 'master' into python-news-statsGravatar Mark2020-05-20-505/+356
| | | |\ \ \ \ \ | | | |/ / / / / | | |/| | | | |
| | * | | | | | Merge pull request #944 from Numerlor/eval-timeout-increaseGravatar Dennis Pham2020-05-19-2/+7
| | |\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Increase snekbox re eval timeout to 30 seconds
| | | * \ \ \ \ \ Merge branch 'master' into eval-timeout-increaseGravatar Dennis Pham2020-05-19-503/+349
| | | |\ \ \ \ \ \ | | | |/ / / / / / | | |/| | | | | |
| | * | | | | | | Add Steam gift card scam to domain blacklistGravatar S. Co12020-05-18-0/+2
| | | | | | | | |
| | * | | | | | | [bug] Adjustment to changes in #941, return message sent by webhook so ↵Gravatar Joseph Banks2020-05-19-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | publish can take place
| | * | | | | | | Merge pull request #941 from ks129/reddit-publishGravatar Dennis Pham2020-05-18-1/+7
| | |\ \ \ \ \ \ \ | | | |_|_|_|_|/ / | | |/| | | | | | Add message publishing to Reddit cog
| | | * | | | | | Merge branch 'master' into reddit-publishGravatar Dennis Pham2020-05-18-777/+1183
| | | |\ \ \ \ \ \ | | | |/ / / / / / | | |/| | | | | |
| | * | | | | | | Merge pull request #858 from python-discord/decorator-factory-mutability-tagGravatar kwzrd2020-05-17-0/+37
| | |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | Add mutability.md tag
| | | * \ \ \ \ \ \ Merge branch 'master' into decorator-factory-mutability-tagGravatar kwzrd2020-05-17-890/+2365
| | | |\ \ \ \ \ \ \ | | | |/ / / / / / / | | |/| | | | | | |
| | * | | | | | | | Merge pull request #949 from python-discord/help-command-fix-invocationGravatar kwzrd2020-05-17-41/+33
| | |\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | Use `send_help` to ensure that our help command is correctly invoked
| | | * | | | | | | | Use `Command`-object for `send_help`Gravatar Sebastiaan Zeeff2020-05-17-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As @mathsman5133 pointed out, it's better to use the `Command`-instance we typically already have in the current context than to rely on parsing the qualified name again. The invocation is now done as: `await ctx.send_help(ctx.command)`
| | | * | | | | | | | Use `send_help` to invoke command helpGravatar Sebastiaan Zeeff2020-05-17-40/+32
| | |/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After the refactoring of the help command, we need to use the built-in method of calling the help command: `Context.send_help`. As an argument, the qualified name (a string containing the full command path, including parents) of the command can be passed. Examples: - await ctx.send_help("reminders edit") This would send a help embed with information on `!reminders edit` to the Context. - await ctx.send_help(ctx.command.qualified_name) This would extract the qualified name of the command, which is the full command path, and send a help embed to Context. - await ctx.send_help() This will send the main "root" help embed to the Context.
| | | * | | | | | | Fix incomplete variable renamingGravatar decorator-factory2020-05-17-1/+1
| | | | | | | | | |
| | | * | | | | | | Rename `string` to `greeting`Gravatar decorator-factory2020-05-17-10/+10
| | | | | | | | | |
| | | * | | | | | | Add a note on user-defined classesGravatar decorator-factory2020-05-17-1/+1
| | | | | | | | | |
| | | * | | | | | | Change standalone programs to interactive sessionsGravatar decorator-factory2020-05-17-8/+13
| | | | | | | | | |