[p]slowmode #2734

Merged
DevilXD merged 14 commits from patch-1 into V3/develop 2019-05-29 02:01:28 +02:00
DevilXD commented 2019-05-26 09:52:10 +02:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

This PR adds a [p]slowmode [interval=0] command, for easy slowmode management on a channel. This lets anyone with Manage Channels permission or a Mod role to change the slowmode setting.

Could be changed to require 0 to disable instead of having it there by default, this is up for discussion.

### Type - [ ] Bugfix - [ ] Enhancement - [x] New feature ### Description of the changes This PR adds a `[p]slowmode [interval=0]` command, for easy slowmode management on a channel. This lets anyone with `Manage Channels` permission or a `Mod` role to change the slowmode setting. Could be changed to require `0` to disable instead of having it there by default, this is up for discussion.
palmtree5 (Migrated from github.com) reviewed 2019-05-26 09:52:10 +02:00
skeith (Migrated from github.com) reviewed 2019-05-26 13:35:02 +02:00
@ -0,0 +1,41 @@
import re
skeith (Migrated from github.com) commented 2019-05-26 13:35:02 +02:00

can you add human time format converter?

seconds, minutes, hours etc

can you add human time format converter? seconds, minutes, hours etc
DevilXD (Migrated from github.com) reviewed 2019-05-26 13:49:41 +02:00
@ -0,0 +1,41 @@
import re
DevilXD (Migrated from github.com) commented 2019-05-26 13:49:40 +02:00

As the input parameter? Or for the Slowmode interval is now {interval} seconds. feedback message?

As the input parameter? Or for the `Slowmode interval is now {interval} seconds.` feedback message?
skeith (Migrated from github.com) reviewed 2019-05-26 14:16:34 +02:00
@ -0,0 +1,41 @@
import re
skeith (Migrated from github.com) commented 2019-05-26 14:16:34 +02:00

both

both
Jackenmen commented 2019-05-26 16:00:55 +02:00 (Migrated from github.com)

I don't believe it's for us to decide, if mods should be able to use this and I think this should be changed so only people with admin role or manage channels permission can use it and just leave it to Red users to decide if they want to allow it to mods role (which they can do by using permissions cog)

I don't believe it's for us to decide, if mods should be able to use this and I think this should be changed so only people with admin role or manage channels permission can use it and just leave it to Red users to decide if they want to allow it to mods role (which they can do by using permissions cog)
DevilXD commented 2019-05-26 17:34:23 +02:00 (Migrated from github.com)

This last commit comes with a simple time converter per request, that will convert input like 5, 5s, 5m or 5h to appropriate time interval. humanized_timedelta from utils is now used to pretty-print the slowmode interval set. Addressing jack's concerns, I've also bumped the decorator to admin_or_permissions, with the intention that it could be overwritten with permissions later if needed as suggested.

A proper, fully fledged time interval converter could be used here, but I believe this is beyond this simple PR. Such converter could be really useful to everyone using Red in general, not only here in the Mod cog, and could be incorporated here at a later date when available.

This last commit comes with a simple time converter per request, that will convert input like `5`, `5s`, `5m` or `5h` to appropriate time interval. `humanized_timedelta` from `utils` is now used to pretty-print the slowmode interval set. Addressing jack's concerns, I've also bumped the decorator to `admin_or_permissions`, with the intention that it could be overwritten with permissions later if needed as suggested. A proper, fully fledged time interval converter could be used here, but I believe this is beyond this simple PR. Such converter could be really useful to everyone using Red in general, not only here in the Mod cog, and could be incorporated here at a later date when available.
DevilXD (Migrated from github.com) reviewed 2019-05-26 17:36:30 +02:00
@ -0,0 +1,41 @@
import re
DevilXD (Migrated from github.com) commented 2019-05-26 17:36:30 +02:00

Should be resolved with the recent commit.

Should be resolved with the recent commit.
mikeshardmind commented 2019-05-27 02:10:46 +02:00 (Migrated from github.com)

Assuming this works properly (It looks solid, but I won't have a chance to test until later) I'm fine with merging prior to having a generalized timedelta converter in core and adding it and switching this to it later.

For anyone who goes to add that, the converter should likely be generalized in such a way in which valid units can be passed as well as an upper and lower bound on the time so that all of that is handled in the conversion step.

Assuming this works properly (It looks solid, but I won't have a chance to test until later) I'm fine with merging prior to having a generalized timedelta converter in core and adding it and switching this to it later. For anyone who goes to add that, the converter should likely be generalized in such a way in which valid units can be passed as well as an upper and lower bound on the time so that all of that is handled in the conversion step.
mikeshardmind (Migrated from github.com) requested changes 2019-05-28 02:26:45 +02:00
mikeshardmind (Migrated from github.com) left a comment

This works great for an initial addition. I do have a small change request here:

image

If this is going to use a simplistic handling prior to there being a generalized converter, this should throw an error to not cause confusion, rather than allow it to succeed with an ambiguous meaning.

a tweak to the regex used, or using re.fullmatch should be reasonably sufficient for this on the short term until the generalized converter is done.

This works great for an initial addition. I do have a small change request here: ![image](https://user-images.githubusercontent.com/22035876/58443044-60a34d80-80bd-11e9-8e11-6008b0346c55.png) If this is going to use a simplistic handling prior to there being a generalized converter, this should throw an error to not cause confusion, rather than allow it to succeed with an ambiguous meaning. a tweak to the regex used, or using `re.fullmatch` should be reasonably sufficient for this on the short term until the generalized converter is done.
DevilXD commented 2019-05-28 07:37:05 +02:00 (Migrated from github.com)

Right, I was using match instead of search already, but forgot that it still requires an explicit line end. Should be as easy as adding $ at the end of the regex pattern.

Right, I was using `match` instead of `search` already, but forgot that it still requires an explicit line end. Should be as easy as adding `$` at the end of the regex pattern.
Tobotimus (Migrated from github.com) reviewed 2019-05-28 07:41:17 +02:00
@ -0,0 +1,41 @@
import re
Tobotimus (Migrated from github.com) commented 2019-05-28 07:41:17 +02:00

Please use _("message").format() rather than f-strings for user-facing strings. f-strings fundamentally can't work with gettext due to order of evaluation.

            await ctx.send(_("Slowmode interval is now {interval}.").format(interval=interval))
Please use `_("message").format()` rather than f-strings for user-facing strings. f-strings fundamentally can't work with gettext due to order of evaluation. ```suggestion await ctx.send(_("Slowmode interval is now {interval}.").format(interval=interval)) ```
mikeshardmind (Migrated from github.com) reviewed 2019-05-28 08:10:00 +02:00
DevilXD (Migrated from github.com) reviewed 2019-05-28 08:11:07 +02:00
@ -0,0 +1,41 @@
import re
DevilXD (Migrated from github.com) commented 2019-05-28 08:11:07 +02:00

Right, switched it to the format method, slightly shorter than your version - hopefully that's alright.

Right, switched it to the format method, slightly shorter than your version - hopefully that's alright.
DevilXD (Migrated from github.com) reviewed 2019-05-28 17:22:05 +02:00
@ -0,0 +1,41 @@
import re
DevilXD (Migrated from github.com) commented 2019-05-28 17:22:05 +02:00

This should be resolved once #2736 will be accepted, so I can use it here.

This should be resolved once #2736 will be accepted, so I can use it here.
DevilXD commented 2019-05-28 20:43:32 +02:00 (Migrated from github.com)

This should be ready to go now.

This should be ready to go now.
Tobotimus (Migrated from github.com) approved these changes 2019-05-29 01:59:51 +02:00
Tobotimus (Migrated from github.com) left a comment

Thanks for your contribution! Works well :)

Thanks for your contribution! Works well :)
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!2734
No description provided.