82 Commits

Author SHA1 Message Date
bobloy
d5899fae83 [RPC] Add missing await in rpc_load (#2167) 2018-10-02 18:44:38 +10:00
Toby Harradine
0870403299
Permissions redesign (#2149)
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>
2018-10-01 13:19:25 +10:00
Toby Harradine
b2497386bb
Update dependencies (#2148)
Core dependencies:
- discord.py: Rapptz/discord.py@00a659c6 -> Rapptz/discord.py@00a659c6
- multidict: 4.4.0 -> 4.4.2

[docs]
- pyparsing: 2.2.0 -> 2.2.1
- sphinx: 1.7.8 -> 1.7.9

[test]
- pytest: 3.7.4 -> 3.8.1

[style]
- toml: 0.9.4 -> 0.9.6

----

I've also replaced usages of `discord.utils.get(guild.roles, id=id)` with the new O(1) `guild.get_role(id)` method.

Signed-off-by: Toby <tobyharradine@gmail.com>
2018-09-25 16:09:36 +10:00
Michael H
f8558b98c1 Automated mod action immunity settings (#2129)
Refactors, and fixes some logic in filter which was encountered while
applying the settings to core
2018-09-25 11:30:28 +10:00
zephyrkul
2784730f7f [V3] Utilize shorten_by (#2131)
* utilize shorten_by

otherwise you get errors

* trivia shorten_by

* warnings shorten_by

max username length is 32 characters

* black formatting
2018-09-15 01:48:31 +02:00
Toby Harradine
9ee860c3f0
[Core] Command disable feature (#2099)
* [Core] Command disable feature

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* [Core] Allow user to set the "command disabled" message

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Reformat

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-06 12:52:19 +10:00
El Laggron
85354f2722 Support missing .po files (#2068)
* [V3 Core] Support missing .po files

* Modified if-state

* Use PEP8 recommendation for empty list check

https://www.python.org/dev/peps/pep-0008/#programming-recommendations
2018-09-03 15:44:58 +10:00
Toby Harradine
1b196bf0fb
[i18n] Use redgettext over pygettext (#2023)
* [i18n] Use redgettext over pygettext

* Clear out autogenerated `messages.pot` files

* Remove redundant `regen_messages.py` files

* Refactor `generate_strings.py` to use redgettext

* Install redgettext in Travis Crowdin job

* Clean up some problematic usages of gettext function

* Reformat

* Replace generate_strings.py with Makefile argument

* Update to redgettext 2.1, use exclusion pattern

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-08-26 23:35:42 +10:00
Michael H
6ebfdef025 Remove self-bot support (#2008) 2018-08-24 22:51:03 +10:00
Michael H
aa69dd381f [Core] Use autohelp properly in local blacklist/whitelist (#2042) 2018-08-23 11:22:03 +10:00
Caleb Johnson
1329fa1b09 [CogManager, Utils] Handle missing cogs correctly, add some helpful algorithms (#1989)
* Handle missing cogs correctly, add some helpful algorithms

For cog loading, only show "cog not found" if the module in question was the one
that failed to import. ImportErrors within cogs will show an error as they should.

- deduplicator, benchmarked to be the fastest
- bounded gather and bounded async as_completed
- tests for all additions

* Requested changes + wrap as_completed instead

So I went source diving and realized as_completed works the way I want it to,
and I don't need to reinvent the wheel for cancelling tasks that remain
if the generator is `break`ed out of. So there's that.
2018-08-21 11:26:04 +10:00
Michael H
35149f8837 [V3] DM usage fixes (#1919)
* DM usage fixes

* ...

* ...

* ...

* ok, formatting...
2018-07-12 02:46:14 +02:00
Michael H
1c2196f78f autohelp changes. (#1836) 2018-07-12 01:23:18 +02:00
Michael H
43cc3c40f3 [V3] use configured color in all places (#1918)
* use configured color

* help formatter too
2018-07-12 00:50:46 +02:00
Michael H
7a6a4cf59d typo fix (#1917) 2018-07-08 22:18:53 +02:00
Tobotimus
d0a53ed2df [V3 Core] Fix backup error (#1820) 2018-06-08 21:12:16 -04:00
Michael H
17c7dd658d [V3 Core] Command group automatic help (#1790)
* decorator inheritence

* black format

* add autohelp

* modify commands to use autohelp
2018-06-08 20:54:36 -04:00
Will
b983d5904b
[V3 RPC] Swap back to initial RPC library and hook into core commands (#1780)
* Switch RPC libs for websockets support

* Implement RPC handling for core

* Black reformat

* Fix docs for build on travis

* Modify RPC to use a Cog base class

* Refactor rpc server reference as global

* Handle cogbase unload method

* Add an init call to handle mutable base attributes

* Move RPC server reference back to the bot object

* Remove unused import

* Add tests for rpc method add/removal

* Add tests for rpc method add/removal and cog base unloading

* Add one more test

* Black reformat

* Add RPC mixin...fix MRO

* Correct internal rpc method names

* Add rpc test html file for debugging/example purposes

* Add documentation

* Add get_method_info

* Update docs with an example RPC call specifying parameter formatting

* Make rpc methods UPPER

* Black reformat

* Fix doc example

* Modify this to match new method naming convention

* Add more tests
2018-06-08 20:31:38 -04:00
Will
7d4946560d
[V3] Fix typo in load (#1814) 2018-06-08 10:56:03 -04:00
Michael H
b7c9647e1a [V3] Fix dm help set (#1806) 2018-06-07 01:23:26 -04:00
Eslyium
60a72b2ba4 [V3] Cleanup quotes in cogs (#1782)
* 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
2018-06-07 00:42:59 -04:00
Michael H
95f51e1126 [V3] Add missing await for [p]set prefix (#1809) 2018-06-06 17:08:33 +10:00
Michael H
4aaef9558a [V3 Core] local whitelist/blacklist (#1776)
* implements local whitelist/blacklist which had unused bot.db settings

This includes a role listing

* format pass

* Update core_commands.py

* .

* black format pass
2018-06-05 12:19:44 -08:00
palmtree5
0b78664792 [V3 Fuzzy search] fix several issues with this feature (#1788)
* [V3 Fuzzy search] fix several issues with this feature

* Make it check if parent commands are hidden

* Check if compiler available in setup.py

* Let's just compile a dummy C file to check compiler availability

* Add a missing import + remove unneeded code
2018-06-05 22:14:11 +02:00
rngesus-wept
11a2fb1088 [V3 Core] Fix display of whitelist and blacklist members (#1789) 2018-06-03 21:41:36 +10:00
Tobotimus
19b05e632c [V3] Use typing.TYPE_CHECKING instead of utils.TYPE_CHECKING (#1778)
Not needed any more as we no longer support python<3.6
2018-06-02 18:24:16 -04:00
Tobotimus
0d193d3e9e [V3] Make bot send typing whilst loading cogs (#1756)
* Show bot is responsive during cog load

* Log download of Lavalink.jar event

* Fix #1709's other bug

* Reformat

* Update core_commands.py from merge
2018-06-02 18:06:10 -04:00
Tobotimus
bcf7ea30c5
[V3 Core] Add a much-needed forward reference (#1763) 2018-06-02 11:20:06 +10:00
Will
864b6d313e [V3 Core Commands] Refactor some commands for testing/RPC (#1691)
* Extract load/unload/reload

* Add a few more commands

* Refactor load/unload signature

* Add invite URL and version info

* Black fixes

* Split the incoming cog names in reload correctly

* Reformat

* Remove meta.bot
2018-06-02 10:49:59 +10:00
Michael H
9f0e752318 [V3 Core] Fix error on [p]set command when used in DM (#1748)
* issue #1741 fix

* requested changes
2018-06-02 09:26:12 +10:00
palmtree5
7775b16199 [V3] Optimize the backup command (#1666)
* [V3 Core] Enhance [p]backup to exclude some files

* Backup the repo list too

* Lol Sinbad's pre-commit hook

* Add option of sending the backup to the owner via DM

* Drop an unnecessary config object in RepoManager

* Move the backup functionality in redbot-setup to the new stuff

* More work on implementation, including backing up the instance data
2018-05-28 06:56:28 +02:00
palmtree5
971ccf9df4 [V3 Core] add support for setting a color for embeds (#1707)
* [V3 Core] add support for setting a color for embeds

* Add a guild toggle for whether to use the bot color

* Add a function for getting embed color in Context

* Coroutines need to be awaited lol
2018-05-28 06:28:22 +02:00
Michael H
07eb6bf88e Reverted Ping back to its original state (#1712) 2018-05-28 06:17:02 +02:00
palmtree5
5ec25959df [V3 Help] add tagline support (#1705)
* [V3 Help] add tagline support

* Make the tagline resettable

* Actually, let's allow the user full control over the footer
2018-05-28 05:25:18 +02:00
Tobotimus
099fe59a97 [V3 Core] Add [p]helpset (#1694)
* Add settings and commands for page and character limits

* Add missing returns

* Consistent responses
2018-05-22 21:04:53 -08:00
Will
73a427f6aa [V3 RPC] Initial RPC library switch (#1634)
* Initial RPC library switch

* Use weak refs to the methods so cog unload works

* Add docs

* Black fixes

* Add jsonrpcserver to Pipfile.lock
2018-05-22 16:29:26 -08:00
Michael H
d3f406a34a [V3 Travis] Update travis to not skip pipfile lock... (#1678)
* Update travis to not sip pipfile lock

update pipfile dependencies

additional black formatting pass to conform to black 18.5b

* .

* pin async timeout until further discussion of 3.5 support

* .
2018-05-18 17:48:22 -08:00
Michael H
b88b5a2601 [V3] Update code standards (black code format pass) (#1650)
* ran black: code formatter against `redbot/` with `-l 99`

* badge
2018-05-14 15:33:24 -04:00
Michael H
8739c04024 [V3] Ping changes (#1618)
* moves ping to core commands
defaults ping behavior to reacting with a ping pong paddle with ball
adds an optional boolean flag to ping to get the avg latency from the bot
(strikes a middle ground with intended behavior from dev standpoint, and how users want it)

* casing for @Kowlin

* use correct check for permissions

* remove latency
2018-05-13 15:03:17 -08:00
Tobotimus
15ea5440a3 [V3 i18n] Internationalise help for commands and cogs (#1143)
* Framework for internationalised command help

* Translator for class docstring of cog

* Remove references to old context module

* Use CogManagerUI as PoC

* Replace all references to RedContext

* Rename CogI18n object to avoid confusion

* Update docs

* Update i18n docs.

* Store translators in list instead of dict

* Change commands module to package, updated refs in cogs

* Updated docs and more references in cogs

* Resolve syntax error

* Update from merge
2018-05-12 01:47:49 +02:00
Kowlin
fcb9b40b43 [V3] Fixed [p]servers bug (#1617)
* Fixed servers bug

* Added protections against going negative
2018-05-10 13:10:42 -08:00
palmtree5
fca7686701 [V3 Core] fix 3.5-specific issue with [p]backup (#1586) (#1588) 2018-05-04 06:18:44 +02:00
palmtree5
b3ad5d90ed [V3 Core] fix a couple issues with [p]servers (#1580) 2018-05-04 06:05:09 +02:00
Wyn
9188e4a7ec [V3 Info] Don't rely on redirect (#1581)
* [V3 Info] Don't rely on redirect

Http -> Https

* Update core_commands.py

Use existing variable instead of new string

* Update events.py

Remove redirect, url only reference
2018-05-02 10:35:48 +02:00
palmtree5
8495824843 [V3 Core] unhide [p]embedset (#1523) 2018-04-16 09:59:34 +02:00
palmtree5
402f6c19e7 [V3 Core] fix some issues with [p]set and [p]set nickname (#1494)
* [V3 Core] fix AttributeError in [p]set

* Fix [p]set nickname

* Make the nickname param on [p]set nickname optional
2018-04-04 12:42:10 +02:00
Will
d79d8fbbea [V3] Fix logic issue with [p]load (#1460) 2018-04-02 17:09:17 -08:00
palmtree5
772590c41c [V3] Add settings displays to [p]set and [p]bankset (#1475) 2018-04-02 21:01:43 -04:00
palmtree5
8eb075fa86 [V3 Core] Embed toggling support (#1467)
* [V3 CogManagerUI] implement text-only support in [p]cogs

* Change page length to 1800 + workaround for pages starting with delim

* [V3 Core] text mode support for [p]contact and [p]dm

* Implement text-only support in modlog and fix everything that broke because of it

* Fix modlog stuff in filter too

* Fix tests

* Implement optional embed support in [p]help

* move to .format
2018-03-28 20:15:51 -04:00
palmtree5
2f23244937 [V3 Core] Add [p]backup (#1471)
* [V3 Core] add [p]backup

* move imports
2018-03-28 19:53:27 -04:00