* do better with loop cleanup
* changelog
* remove redundant line
* Do this a bit better than the initial pass
* Improve windows support
Make some other things coroutines to work with improved design
* Wish we'd have done this right from the start...
* Update deps surrounding this
- see bpo-23057
- neccessary for windows users
- nice for consistent support channel info / feature availability
* dep issue
* Fix tests
* duplication plugin py version
* actually handle this
* Reconfigure some checks with codeclimate, disable pylint for now
* style
* Is my exasperation showing yet?
* handle some stupid stuff
* meh
* dep changelog
* feat: dispatch `on_red_api_tokens_update` event on api keys update
* docs: add event reference in Shared API Keys docs
* chore(changelog): add tonwcrier entries
* fix: wrap dispatched api tokens in MappingProxyType
* docs: reflect change of type change to read-only Mapping
* reorder some startup to prevent heartbeat issues
* changelog
* handle startup cleanup in audio
* style
* rebased to handle conflict
* be a little smarter to prevent (some) infinite hangs
* Fix a pre-existing NoneType Error
* Migrate config before things are using it...
* another place we should ensure we're ready
* rename-toavoid-issues
* fix cache ordering and mis-use of ensure_future
* remove incorrect typehints
* style
* More privatization, and some error helpers
This makes a lot more things private. Continued from #2967, fixes#2984
Adds public methods for various things.
Below is a brief summary of things available elsewhere, though this
particular set of changes may warrant a detailed section in the release notes.
- bot.db.locale -> redbot.core.i18n.get_locale
- Note: This one already existed.
- bot.db.help -> redbot.core.commands.help.HelpSettings
- bot db whitelist/blaclist? -> bot.allowed_by_whitelist_blacklist
- This has also been made a single cannonical function for this
purpose including check usage
- bot color? -> bot.get_embed_color/bot.get_embed_colour
- bot.id.api_tokens? ->
- bot.get_shared_api_tokens
- bot.set_shared_api_tokens
- bot.remove_shared_api_tokens
-bot.db.prefix -> bot.get_valid_prefixes
- (Note: This is a wrapper around bot.get_prefix)
Other changes include
- removing `bot.counter` as it was never used anywhere
- Adding properties with helpful error messages for moved and renamed
things
- making bot.uptime a property with an error on set
- adding a migration to the bot config for shared_api_tokens
* Remove overly encompassing message redaction, eval is a risk, dont run in dev if you cant manage it
* address Flame's feedback
* rephrase example
* changelog extras
* You saw nothing
* Rename `bot.db` as `bot._config`
- Continues work towards strong version guarantees
- Added methods for cog use for a few things which were previously
only accessible via direct access.
- Retained private use in a few internal use locations, though most
methods were updated away from this.
- Updated documentation for shared api token users
* changelog
* more detail
* docstring fixes
* Apparently, I forgot to commit something I had locally
- + a copy/paste failue in the changelog
* *sigh*:
* *sigh*
* PostgreSQL driver and general drivers cleanup
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Make tests pass
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Add black --target-version flag in make.bat
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Rewrite postgres driver
Most of the logic is now in PL/pgSQL.
This completely avoids the use of Python f-strings to format identifiers into queries. Although an SQL-injection attack would have been impossible anyway (only the owner would have ever had the ability to do that), using PostgreSQL's format() is more reliable for unusual identifiers. Performance-wise, I'm not sure whether this is an improvement, but I highly doubt that it's worse.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Reformat
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Fix PostgresDriver.delete_all_data()
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Clean up PL/pgSQL code
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* More PL/pgSQL cleanup
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* PL/pgSQL function optimisations
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Ensure compatibility with PostgreSQL 10 and below
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* More/better docstrings for PG functions
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Fix typo in docstring
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Return correct value on toggle()
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Use composite type for PG function parameters
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Fix JSON driver's Config.clear_all()
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Correct description for Mongo tox recipe
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Fix linting errors
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Update dep specification after merging bumpdeps
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Add towncrier entries
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Update from merge
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Mention [postgres] extra in install docs
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Support more connection options and use better defaults
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Actually pass PG env vars in tox
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Replace event trigger with manual DELETE queries
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Make Requires.verify() wait until rules are loaded
Also ensures `Requires` objects are reset when unloaded, particularly in case a `Command` object manages to stay in memory between cog unload and load, and its permissions rules change between those events.
Also, this PR re-ordered some of the event loop policy stuff, because it was required that the event loop policy be set before creating any `Requires` objects. This may or may not have an effect on other `get_event_loop()` calls elsewhere (either in our code, a dependency's, or asyncio's). Either way, these effects would be a *correction*, and any bugs that arise from it are likely to have been occurring silently beforehand.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Remove calls to `remove_listener()` in permissions
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Fix adding rules for permissions cog/commands itself
Also addresses feedback
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Clean up indentation when setting uvloop policy
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Use `set(walk_commands())` to traverse `Group` subcommands
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* [Core] Fix user output on cog load/reload
- Properly fixes the load/reload exception handling
- Fixes some i18n use here to not make assumptions about other
languages pluralization rules.
* Fix some typos
* Address Flame's Feedback
* It's important to save before committing ...
* formatting
* Fix some formats...
* Adds Schema versioning
- Adds Migration tool
- Adds tool to migrate to allow multiple admin and mod roles
- Supports Multiple mod and admin roles
* Ensures migration is run prior to cog load and connection to discord
* Updates to not rely on singular mod/admin role id
* Update requires logic for multiple mod/admin roles
* Add new commands for managing mod/admin roles
* Feedback
Update strings
Update docstrings
Add aliases
* Use snowflakelist
* paginate
* Change variable name
* Fix mistake
* handle settings view fix
* Fix name error
* I'm bad at Ux
* style fix
This still preserves the new event, which was a welcome change. However, context still needs to be invoked when a command isn't found, so `on_command_error` can still catch `commands.CommandNotFound`.
Fixes broken fuzzy help.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Add inviteset group command
* Fix errors
* Fix line break
* Remove user bot support
* Fix docstrings line breaks
* Remove embed specific formatting
* Remove invite redirect
* Add self argument to _can_get_invite_url
* Remove unused import
* fix errors related to classes + double help
* Removed self bot support
* same stuff, but with some more spurious error supression
* fix issue in permissions found in this
* fix a few more spurious errors
* fix another issue
* semi-spurious error fixes
* .
* formatting
* move this to properly log
* distutils import + virtualenv
* more fixes
* Add bot.send_to_owner
resolves#2665
Adds some basic methods and config entries.
Does not add commands for modifying this yet.
* Use send_to_owners in events
* handle feedback
* [Help] Add settings for various things
- Fixes a small issue in a previously not-exposed logic path
- Fixes an issue with denied commands help invocation
- Adds some global usage settings
* remove outdated comment
* improve intent of strings
* added punctuation
* Add DM forbidden handling
* use a slightly different method for shortening embed width specifically
* [Bot] Support new design
* [Context] use the new help in `ctx.send_help`
* [Commands] Update Cog and Group for help compat
- Removes a trap with all_commands, this isn't a good way to check this
- Adds a help property
- Fixes command parsing in invoke
* Redesigns red's help
* handle fuzzy help
* style
* handle a specific ugly hidden interaction
* fix bot-wide help grouping
* changelog
* remove no longer needed -
* Dependency update
discord.py==1.0.1
websockets<7
[style]
black==19.3b0
[Docs]
jinja==2.10.1
urllib3==1.24.2
Changes related to breaking changes from discord.py have also been made
to match
As of this commit, help formatter is back to discord.py's default
* Do things differently
* Uncomment critical lines
* Reduce, reuse, recycle
* Check groups on all new config objects after a cog loads
* I don't know why this is failing now or why we need the global keyword
* gotta fix this too
This creates a central location to store external API tokens that can be used between cogs without requiring each cog to be loaded for it to work.
A new set option for `[p]set api` is created to assist in forming bot readable API token locations.
This also updates the Streams cog to utilize the central database.
Tokens are moved from the old data locations in core cogs on load.
- Removed memory-sided `CogManager._paths` attribute, as it has no practical use.
- `[p]removepath` now removes the actual path displayed with the index specified in `[p]paths`.
- New method for retreiving a deduplicated list of user-defined paths as `Path` objects
- General cleanup so we don't have to do so much head-scratching next time an issue arises here
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
Some in-progress work slipped through #2149, and I figure it should be fixed before RC2.
I've also just decided to allow discovery of permissions hooks from superclasses as well. We should try to be more aware of the possibility of cog superclasses moving forward.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
API changes:
- Cogs must now inherit from `commands.Cog` (see #2151 for discussion and more details)
- All functions which are not decorators in the `redbot.core.checks` module are now deprecated in favour of their counterparts in `redbot.core.utils.mod`. This is to make this module more consistent and end the confusing naming convention.
- `redbot.core.checks.check_overrides` function is now gone, overrideable checks can now be created with the `@commands.permissions_check` decorator
- Command, Group, Cog and Context have some new attributes and methods, but they are for internal use so shouldn't concern cog creators (unless they're making a permissions cog!).
- `__permissions_check_before` and `__permissions_check_after` have been replaced: A cog method named `__permissions_hook` will be evaluated as permissions hooks in the same way `__permissions_check_before` previously was. Permissions hooks can also be added/removed/verified through the new `*_permissions_hook()` methods on the bot object, and they will be verified even when permissions is unloaded.
- New utility method `redbot.core.utils.chat_formatting.humanize_list`
- New dependency [`schema`](https://github.com/keleshev/schema)
User-facing changes:
- When a `@bot_has_permissions` check fails, the bot will respond saying what permissions were actually missing.
- All YAML-related `[p]permissions` subcommands now reside under the `[p]permissions acl` sub-group (tbh I still think the whole cog has too many top-level commands)
- The YAML schema for these commands has been changed
- A rule cannot be set as allow and deny at the same time (previously this would just default to allow)
Documentation:
- New documentation for `redbot.core.commands.requires` and `redbot.core.checks` modules
- Renewed documentation for the permissions cog
- `sphinx.ext.doctest` is now enabled
Note: standard discord.py checks will still behave exactly the same way, in fact they are checked before `Requires` is looked at, so they are not overrideable.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Add output sanitization defaults to context.send
Add some common regex filters in redbot.core.utils.common_filters
Add a wrapper for ease of use in bot.send_filtered
Sanitize ModLog Case's user field (other's considered trusted as moderator input)
Sanitize Usernames/Nicks in userinfo command.
Santize Usernames in closing of tunnels.
* Add documentation
* enforce commands as ours
* clearer user feedback
* No more 'one more tweak' commits without verifying anyway
* more detailed error with docs link + docs update
Resolves#1972.
Fixes#1943
This just skips cogs when `__module__` is None. Also:
- backported rapptz/discord.py#621
- moved RPC handler unregister to remove_cog()
- raise an exception when a load would overwrite an existing extension