646 Commits

Author SHA1 Message Date
Ryan
b6c8be5f43 [MongoDB] Support mongodb+srv protocol (#2159) 2018-10-01 16:49:29 +10:00
aikaterna
b2abfc5710 [Audio] Playlist list and notify msg changes (#2155) 2018-10-01 16:44:46 +10:00
zephyrkul
a9b328ff3c [Mod] Remove tempban from data after unbanning (#2161)
Resolves #2160.

Also resolves another issue where the bot will error out when getting the guild's invites when it doesn't have the Manage Server permission.
2018-10-01 14:15:51 +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
f07b78bd0d
Fix help command with cogs (#2156)
This bug was introduced in #2122 (whoops)

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-30 14: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
Michael H
84ac5f3952 JsonIO atomic write improvements (#2132)
Use `async with Lock` instead of deprecated `with await lock` usage.

Forces a file fsync prior and a directory fsync (where available) after rename to prevent issues with left behind temp files.

Also should clarify: this is not threadsafe. Comments were clarified, function names remain misleading.
2018-09-24 18:29:14 +10:00
Michael H
404800c556 Hackban fixes (#2128)
If the member is in the guild, delegates to existing ban logic.

Additionally, check that we have ban perms prior to attempting to fetch the existing ban list.

Fixes #2127.
2018-09-24 18:21:21 +10:00
Toby Harradine
415385b747
[Downloader] Fix git pull command (#2146)
I somehow managed to botch this in #2121

Signed-off-by: Toby Harradine <t.harradine@student.unsw.edu.au>
2018-09-24 13:20:30 +10:00
Toby Harradine
f7dbaca340
Refactor fuzzy help and clean up help command (#2122)
What's changed:
- Fixed issues mentioned on #2031
- Fuzzy help displays more like help manual
- Fuzzy help is easier and more flexible to use
- Fuzzy help string-matching ratio lowered to 80
- Help formatter is more extendable
- Help command has been optimized, cleaned up and better incorporates fuzzy help
- Added async_filter and async_enumerate utility functions because I was using them for this PR, then no longer needed them, but decided they might be useful anyway.
- Added `Context.me` property which is a shortcut to `Context.guild.me` or `Context.bot.user`, depending on the channel type.
2018-09-24 10:34:39 +10:00
bobloy
32b4c6ce86 [Image] Remove V2 relics from command decorators (#2138) 2018-09-23 23:44:01 +10:00
zephyrkul
a3c36d4bde NoneType check for module in should_log_sentry (#2139)
Allows for a lack of module (which returns False) for `should_log_sentry`. This allows for, say, commands to be added by the Dev cog. ( ͡ಠ ʖ̯ ͡ಠ)
2018-09-23 23:42:25 +10:00
bobloy
fc4703ef80 [Launcher] Don't ask for CLI flags when no instances (#2142)
Seems to have been fixed in #1497 but accidentally reverted at a later date.
2018-09-23 23:39:32 +10:00
zephyrkul
a301b2c758 Add missing @staticmethod to Red.send_filtered (#2143)
Method was previously missing `self` argument but was missing static decorator.
2018-09-23 23:34:57 +10:00
Toby Harradine
e27682abd3
[Downloader] More robust repo loading (#2121)
Previously, when downloader was loaded, the RepoManager would spawn a task to load available repos. If one repo failed loading for some reason, the function would raise and the remaining repos would never be loaded, however downloader would still appear to load correctly.

This change handles exceptions better during repo loading, but also, if an unhandled exception is raised, downloader will fail to load as it should.

Also included, as requested in #1968, is the --recurse-submodules flag in cloning/pulling repositories.

This change resolves #1950.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-22 15:05:42 +10:00
Toby Harradine
df922a0e3e
[Audio] More robust startup and unload (#2118)
* More robust cleanup for audio and streams

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

* Remove copied code from streams

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-22 15:04:46 +10:00
aikaterna
51c83d958c [Audio] Check if player is playing when pausing (#2130) 2018-09-18 23:54:32 +10:00
Toby Harradine
17139ce439
Fix compiler detection on Windows (#2136)
Signed-off-by: Toby Harradine <t.harradine@student.unsw.edu.au>
2018-09-18 14:07:50 +10:00
zephyrkul
61652a0306 [V3 CustomCommands] Cooldowns (#2124)
* customcom cooldowns

allows you to set multiple different cooldowns for custom commands

* black formatting

* [docs] cooldowns
2018-09-17 17:47:45 +02:00
Michael H
113b97b9c9 Fix role check in local blacklist/whitelist (#2134)
fixes #2133 , 

`discord.Role.is_default` is a method, not a property.
2018-09-17 17:30:56 +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
1a9216b522
Set 3.6.6 as minimum python version on Windows (#2117)
* Set 3.6.6 as minimum python version on Windows

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

* Conditional python_requires in setup.py

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

* Should probably add the comment too

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-14 21:22:43 +10:00
Toby Harradine
08fc732b7b
[Downloader] Fix URL parsing for non-GitHub/GitLab links (#2123)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-12 11:01:54 +10:00
Toby Harradine
54baf687ec
[Downloader] Parse tree URLs when cloning repos (#2119)
* [Downloader] Parse tree URLs when cloning repos

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

* Only match GitHub and GitLab URLs

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-12 10:03:15 +10:00
Toby Harradine
8096cd803e
Bump version to 3.0.0b21 (#2115)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
3.0.0b21
2018-09-10 00:44:11 +10:00
Toby Harradine
27b0d606c8
Fix CCs with no args (#2114)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-10 00:35:53 +10:00
aikaterna
af220e497f [Docs] Update sample cog (#2072)
* [V3 Docs] Update sample cog

* Remove self.bot assignment

We don't really do this any more unless we need to
2018-09-09 23:35:22 +10:00
Toby Harradine
892b2487f5
Dependency update (#2100)
aiohttp-json-rpc 0.11 -> 0.11.1
atomicwrites 1.1.5 -> 1.2.1
attrs 18.1.0 -> 18.2.0
certifi 2018.4.16 -> 2018.8.24
discord.py 8ccb98d395537b1c9acc187e1647dfdd07bb831b -> 00a659c6526b2445162b52eaf970adbd22c6d35d
fuzzywuzzy 0.16.0 -> 0.17.0
imagesize 1.0.0 -> 1.1.0
multidict 4.3.1 -> 4.4.0
py 1.5.4 -> 1.6.0
pytest 3.7.0 -> 3.7.4
sphinx 1.7.6 -> 1.7.8

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-09 23:21:48 +10:00
Kowlin
7971c02dc5 Escape user and passwords for mongo (#2111)
* Escape user and passwords for mongo.

* Quote -> Quote_Plus

* formatting
2018-09-09 23:07:40 +10:00
zephyrkul
c1d8272b49 [CustomCommands] Show parameter name correctly in help (#2102) 2018-09-09 23:05:33 +10:00
aikaterna
bce5dd26f3 [Audio] Local playback (#2097)
* [V3 Audio] Local playback

* Formatting

* Update application.yml

* Add catch for an empty localtracks directory

* Linebreak in help for i18n
2018-09-09 23:02:53 +10:00
zephyrkul
04e97f3516 [CustomCom] Custom Command Parameters (#2051)
* [V3 CustomCom] Custom Command Parameters

Allows specifying more parameters for CC's via {0}, {1}, etc. that will be filled by the user invoking the CC. Python-style type hinting and attribute access is also allowed for Discord and builtin types.

> [p]cc add simple greet Hi, {0.mention:Member}!
> ...
> [p]greet zephyrkul
> Hi, @zephyrkul!

The bot will reply with the standard help messages if the cc is incorrectly executed.

> [p]greet me
> Member "me" not found

* black formatting

* check command failure

Only call the custom command if the faked command succeeded.

* misc fixes

1) don't str.strip all the time, it's not family-friendly and doesn't match transform_parameter
2) transform_arg now actually returns strings in every case
3) improve prepare_args parsing security
4) help parameters will show what type they expect
5) make linter less angery

* customcom documentation

I hate rst

* don't require repeated type hinting

If a parameter was type hinted previously, don't require it again.
Ex: `{0.display_name:Member}#{0.discriminator}` is now possible.

* add cog_customcom.rts to index

I despise rst

* don't enforce order

Allow type hinting and attribute access to be in either order.
Ex. `{0:Member.mention}` is now valid.

* clean up on_message

We're building context anyway, may as well use it.

* [doc] correct cog name

Cog class is named CustomCommands, not CustomCom

* minor on_message optimization

only build context if it's needed

* update cc_add docstring

Old one wasn't user-friendly. Replaced with a link to the new docs.
Link will not function until PR is merged and docs refreshed.

* [doc] change repeat to say

repeat is an audio command, use say in the example instead

* compare ctx.prefix to None

allows for null prefixes, which is a bad idea but who am I to judge

* address review

* raise error on conflicting colon notation

bugfix I was working on but failed to actually commit
2018-09-07 00:14:02 +10:00
Toby Harradine
7eed033c9e
Prettify README and translate to MarkDown (#2101)
Signed-off-by: Redjumpman <redjumpman@users.noreply.github.com>
2018-09-06 21:53:18 +10:00
Richard Guan
a2fe1a8757 [Audio] Don't allow duplicate links in playlists (#2071)
* Just a test

* another test

* undoing my test

* First solution, style issue

* Works functionally, but there are is a minor style issue

* style fixed

* Revert README changes
2018-09-06 16:25:27 +10: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
Toby Harradine
1dbe9537e9
Ignore fuzzywuzzy slow sequence matcher warning (#2096)
* Ignore fuzzywuzzy slow sequence matcher warning

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

* Add log.info call instead

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-06 12:50:30 +10:00
Toby Harradine
775f4ce69a
Use ProactorEventLoop on Windows (#2062)
* Use ProactorEventLoop on Windows

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

* Set the actual loop instead of the policy

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-06 00:40:15 +10:00
zephyrkul
e83beeef34 [Audio] Add [p]sing (#2067)
* port [p]sing

* [p]sing in alphabetical order

what even is an alphabet
2018-09-04 13:23:50 +10:00
Brramble
e77cfff892 [p]serverinfo respects set embed colour (#2083) 2018-09-04 13:01:50 +10:00
Michael H
9495432b8f More mention filtering (#2081)
* more filters

* note to future people touching this

* chan mentions were almost missed...

* Swap strategies as the previous escaped the mention, while still pinging the user/role
2018-09-04 12:59:59 +10:00
palmtree5
d71c334a34 [Filter] Fix issue with filtering sentences (#2065) 2018-09-04 12:55:18 +10:00
Michael H
aa8cc90ad0 Update minimum Python version to 3.6.2 (#2093)
* Correct minimum version

see #2092 

While this is needed because of an import just for typing, I see no reason not to bump the minimum version since this is a minor version difference since this is several minor version behind the latest 3.6, and there have been both security and performance improvements since.

That said, we need to be testing on our lowest supported version to ensure we don't have this happen again, right now our tests run on whatever Travis grabs for 3.6, which I assume is 3.6.6, but could be wrong.

* Update other mentions of min version to 3.6.2
2018-09-04 11:38:56 +10:00
palmtree5
589041556e [Streams] Fix excessive writes to config (#2095)
Resolves #2052.
2018-09-04 11:01:48 +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
c0c5535005
[Warnings] Help users understand custom reasons (#2049)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-03 14:57:14 +10:00
zephyrkul
e126cf9f4e [Launcher] use "python -m" to run Red (#2080)
friendlier for virtual environments
2018-09-03 10:44:50 +10:00
aikaterna
c2d23b37a7 [Audio] Fix for using [p]now with thumbnail (#2063) 2018-08-28 13:02:40 +10:00
aikaterna
3a968d707f Fix Travis deployment attempt 2 (#2061) 3.0.0b20 2018-08-27 10:24:03 +10:00
aikaterna
b07c44c8b4 Fix travis deployment (#2060) 2018-08-27 10:09:02 +10:00