* [Commands Module] Better Typehint Support
We now do a lot more with type hints
- No more rexporting d.py commands submodules
- New type aliases for GuildContext & DMContext
- More things are typehinted
Note: Some things are still not typed, others are still incorrectly
typed, This is progress.
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
* Add command to remove dead members from bank
* Add a global check
* Added a FIXME so `bank_local_clean` is updated once bulk-update is implemented
Added a brief warning to warn devs not to use the `_get_base_group` as it can mess up their config files
Removed a redundant existence check
* Updated commit to reflect changes requested in review
* Updated commit to reflect changes requested in review
* 🤦
* Return command to run with user id so we don't worry about safeguarding the command agaisn't invalid formats
* Braaaainnn
Removed aliases that used old naming scheme
* TL:DR Added global bank support, and rework permissions
Renamed `bank_local_clean` to `bank_prune`
Added support for global banks to `bank_prune`
`bank_prune` will now raise `BankPruneError` if trying to prune a local bank and `guild` is not supplied
Renamed `cleanup` subgroup to `prune`
`prune` subgroup will have 3 commands:
`user` : Deletes the bank account for the specified member : Accepts `Union[discord.Member, discord.User, int]`
`global` : Prune global bank accounts for all users who no longer share a server with the bot
`local` : Prune local bank accounts for all users who are no longer in the guild
Changed check for `prune` subgroup to be `@check_global_setting_admin()`
[p]bank prune local : Can be run by Guild owners only
[p]bank prune global : Can be run by Bot Owner only
[p]bank prune user : Can be run by Admins, Guild owners and Bot Owner
* Yikes ... Updated kwarg name
* Fixed unexpected unindent: docstring of redbot.core.bank.bank_prune:14:Field list ends without a blank line
* ...
* 3rd time lucky?
* 4th time lucky?
* Fix Docstring
* Initial commit to address review by Flame
* Updated code to reflect Flame's comments
* Skip pruning of unavailable guilds
* Fixed typo in string
* *sigh* black is the bane of my existence
* addressed Flames commends
Fixed [p]bank prune user, When run via DM it will now return an error message to the user (Thanks jack1142)
* Time to get some sleep
* 'DM' > 'DMs' in string
* Add towncrier entries
Signed-off-by: Draper <guyreis96@gmail.com>
* Update to reflect Flame's review
Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>
* 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>
- Fixes defaults being mixed into custom groups above the document level when doing `Group.all()`
- Fixes `Config.clear_all()` with Mongo driver
- Fixes `Group.set()` with Mongo driver on custom groups above the document level
- Fixes `IdentifierData.custom_group_data` being set to the wrong thing in `BaseDriver.import/export_data` (although this was an inconsequential bug)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* 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
* 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
* Require custom group initialization before usage and write that data to disk
* Style
* add tests
* remove custom info update method from drivers
* clean up remnant
* Turn config objects into a singleton to deal with custom group identifiers
* Fix dumbassery
* Stupid stupid stupid
* modify config to use identifier data class and update json driver
* move identifier data attributes into read only properties
* Update mongo get and set methods
* Update get/set to use UUID separately, make clear work
* Remove not implemented and fix get_raw
* Update remaining untouched get/set/clear
* Fix get_raw
* Finally fix get_raw and set_raw
* style
* This is better
* Sorry guys
* Update get behavior to handle "all" calls as expected
* style again
* Why do you do this to me
* style once more
* Update mongo schema
* Logging enhancements and cleanup
- Removed debug log messages every time `Config.get_conf` is used or a JSON file is read/saved. The basic configuration is now logged once with DEBUG when the bot starts up instead.
- Changed logging output format to reverse date order, include seconds, and use the logger's name instead of the module, function and line number.
- Log files are now kept in the `DATAPATH/core/logs` directory. Each time Red is restarted, a new log is created, and the old ones renamed in a rotating fashion. There can be a maximum of 9 logs in total.
- Each log file now has a smaller max size of 500KB before it will be split into multiple parts. There are also a maximum of 9 parts of each log.
- Discord.py logger now uses the same output formatter as red's loggers
- Moved logging setup code into `redbot.logging` module.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Reformat
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Implement discussed changes
- We maintain a red.log over multiple runtimes, alongside a latest.log and previous.log for individual runtimes.
- Naming convention changed a bit. E.g. when latest.log is just one part, it will be named latest.log. When it becomes two parts, they will both be named latest-part1.log and latest-part2.log.
- Rotation direction is reversed. This means as the files end up being named in chronological order.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
Renames the `current_build` key to `current_version`. This means the `current_version` key will always be a dict and never a list, and `current_build` having no defaults means it won't mess with `[p]audioset settings`.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This is a step towards a more consistent front-end behaviour of Config, where errors are either circumvented or raised in the same way regardless of the driver being used.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Make calling groups useful
This makes config.Group.__call__ effectively an alias for Group.all(),
with the added bonus of becoming a context manager.
get_raw has been updated as well to reflect the new behaviour of
__call__.
* Fix unintended side-effects of new behaviour
* Add tests
* Add test for get_raw mixing in defaults
* Another cleanup for relying on old behaviour internally
* Fix bank relying on old behaviour
* Reformat
* [V3 JSON] Return deepcopy in JSON driver
* Add a test
* foo not bar
* Add a test for setting and then mutating
* Resolve issue for setting and mutating as well
* Reformat
* Cleanup quotes in cogs
* More quote cleanup that I missed
fixed a little bit of grammar here and there as well.
* [V3 Warnings] Change allowcustomreasons docstring
To help not confuse users who would believe that the command would use allow or disallow.
* Run black reformat
* Upgrade sphinx version to 1.7+
* Fix title overlines/underlines in autostart_systemd.rst
* Skip trying to document a method from discord.py
* Add escaped space after backtick
* Escape underscores (sphinx tries to interpret a hyperlink)
* Use fully qualified reference for class
* Fix reference in tunnel.py
* Remove python syntax highlighting in data_converter.py
For some reason sphinx couldn't lex these as python. Removing the highlighting seems like the logical solution for now, since if it wasn't being lexed, it wouldn't highlight anyway.
* Comment out static path since we're not using it right now
* Update sphinx version in docs requirements too
Would rather remove this duplication but RTD is a special snowflake
* Add the identifier as an initialization parameter
* Remove config object singleton and opt for a shared JSON datastore
* Fix bot unloading to deal with memory leaks
* Fix tests
* Fix clear all bug
* Add get_raw/set_raw
* Add default to get_raw
* Add custom group method to the config object
* Add more methods for custom groups
* Add some docstrings
* Deepcopy the result of get_raw, throw TypeError if no value is passed to set_raw
* Do it right..
* Better way to require kwarg
* Remove get_driver
* Rename self.driver to self._driver
* Do not unnecessarily pass the cog identifier
* Remove unused import
* Fix type annotation
* Missed a keyword rename
* Modify signature of get/set methods in drivers
* Basic Mongo Driver
* Update docstrings
* WIP motor support
* Use motor
* Update docs, add selective importer
* Make use of selective importer
* Fix docs
* Fix config storage location for JSON
* Add delimiters in the drivers doc section
* Make async things async
* Add basic config information for mongo driver
* get info from basic setup into config
* IT WORKS
* Add dependency for RJM's PR.
* Added alternative to all_from_kind
* Returned dicts include default values
Also added docstrings
Also removed all_globals since it's kind of redundant and it wasn't working out for me
* Refactored clear_all
* Tests
* Tests again..
* Make all new methods coroutines
Ya'll are gonna hate me.
* Initial modifications
* Add initial setup.py
* working setup py help
* Modify setup file to package stuff
* Move a bunch of shit and fix imports
* Fix or skip tests
* Must add init files for find_packages to work
* Move main to scripts folder and rename
* Add shebangs
* Copy over translation files
* WORKING PIP INSTALL
* add dependency information
* Hardcoded version for now, will need to figure out a better way to do this
* OKAY ITS FINALLY FUCKING WORKING
* Add this guy
* Fix stuff
* Change readme to rst
* Remove double sentry opt in
* Oopsie
* Fix this thing
* Aaaand fix test
* Aaaand fix test
* Fix core cog importing and default cog install path
* Adjust readme
* change instance name from optional to required
* Ayyy let's do more dependency injection