[Streams] Save/remove/check custom message(s) for each streamer registered #4668

Closed
KianBral wants to merge 0 commits from custom-message into V3/develop
KianBral commented 2020-12-12 03:25:21 +01:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

Worked alongside @willkang-1 (kaesd #6455 on discord) for this PR

This should hopefully resolve #3824, should also fix #4984

We added a few new functions/variables to the streams cog that allow users to add custom mention and no-mention stream alert messages for every individual streamer.

Commands Added

[p]streamset message streamer <streamer_name> <mention|nomention> [if_mention: audience] <message>
Allows users to set a custom message for an already-registered streamer, select between mention/no-mention, and give them the optional argument for who to mention, if mention is selected.

[p]streamset message check <streamer_name>
Returns the mention/no-mention messages for the input streamer, and notifies if the streamer does not have one of or both of the messages. Will also notifies user if the streamer is not registered in the server.

[p]streamset message remove <streamer> <mention|nomention|both>
Removes the mention/no-mention (or both) messages for the input streamer. Notifies user only if streamer is not registered in the server.

Additionally, we added functions and variables to add and remove attributes to streamer objects or dictionaries. Corresponding logic was added to check whether or not a streamer has a custom message, and if not the server will just print the default for the server.

There was an initial commit that was accidentally from another branch. It was reverted in the last commit since we only just realized it, so please ignore it as it does not make any changes, sorry about that!

This was a relatively big and confusing feature to integrate. Please let me or @willkang-1 know if we overlooked anything, made things too complicated, or didn't follow any common conventions that we should have. Also feel free to ask about our implementation.

### Type - [ ] Bugfix - [ ] Enhancement - [x] New feature ### Description of the changes ### **Worked alongside @willkang-1 (kaesd #6455 on discord) for this PR** This should hopefully resolve #3824, should also fix #4984 We added a few new functions/variables to the streams cog that allow users to add custom mention and no-mention stream alert messages for every individual streamer. **Commands Added** `[p]streamset message streamer <streamer_name> <mention|nomention> [if_mention: audience] <message>` Allows users to set a custom message for an already-registered streamer, select between mention/no-mention, and give them the optional argument for who to mention, if mention is selected. `[p]streamset message check <streamer_name>` Returns the mention/no-mention messages for the input streamer, and notifies if the streamer does not have one of or both of the messages. Will also notifies user if the streamer is not registered in the server. `[p]streamset message remove <streamer> <mention|nomention|both>` Removes the mention/no-mention (or both) messages for the input streamer. Notifies user only if streamer is not registered in the server. Additionally, we added functions and variables to add and remove attributes to streamer objects or dictionaries. Corresponding logic was added to check whether or not a streamer has a custom message, and if not the server will just print the default for the server. There was an initial commit that was accidentally from another branch. It was reverted in the last commit since we only just realized it, so please ignore it as it does not make any changes, sorry about that! This was a relatively big and confusing feature to integrate. Please let me or @willkang-1 know if we overlooked anything, made things too complicated, or didn't follow any common conventions that we should have. Also feel free to ask about our implementation.
palmtree5 (Migrated from github.com) reviewed 2020-12-12 03:25:21 +01:00
madebylydia commented 2023-02-12 18:33:55 +01:00 (Migrated from github.com)

Hello @KianBral, thank you for your PR!
I'd like to point out certain problems with your PR that needs certain fixes:

  • At line 638, 639, 650, 695, etc., you are using special methods to get, set and delete attributes. This isn't the way to go, you should rather use the builtin commands provided by Python:
# Original
class.__getattr__("attribute")
# Become
class.attribute

# Original
class.__setattr__("attribute", value)
# Become
class.attribute = value

# Original
class.__delattr__("attribute")
# Become
del class.attribute
  • Your strings do not respect i18n when using .format, as the .format should be outside the _() pairs, not inside:
# Incorrect
_("My string".format(format_data=""))

# Correct
_("My string").format(format_data="")
  • A personal point is that you should use f-string rather than format in this context, they are the modern way to go, but you can keep .format if you'd like.
  • When using .format, you should use keyword arguments rather than positional arguments, like this:
# Positional
"My {}".format(stuff)

# Keyword
"My {secret}".format(secret=stuff)

This is in order to improve clarity of arguments you're passing.

  • I think it's better that the information you are passing in the streamer_info attribute should go directly into the Stream class (Available at redbot.cogs.streams.streamtypes)
Hello @KianBral, thank you for your PR! I'd like to point out certain problems with your PR that needs certain fixes: - At line 638, 639, 650, 695, etc., you are using special methods to get, set and delete attributes. This isn't the way to go, you should rather use the builtin commands provided by Python: ```py # Original class.__getattr__("attribute") # Become class.attribute # Original class.__setattr__("attribute", value) # Become class.attribute = value # Original class.__delattr__("attribute") # Become del class.attribute ``` - Your strings do not respect i18n when using `.format`, as the `.format` should be outside the `_()` pairs, not inside: ```py # Incorrect _("My string".format(format_data="")) # Correct _("My string").format(format_data="") ``` - A personal point is that you should use f-string rather than format in this context, they are the modern way to go, but you can keep `.format` if you'd like. - When using `.format`, you should use keyword arguments rather than positional arguments, like this: ```py # Positional "My {}".format(stuff) # Keyword "My {secret}".format(secret=stuff) ``` This is in order to improve clarity of arguments you're passing. - I think it's better that the information you are passing in the `streamer_info` attribute should go directly into the `Stream` class (Available at `redbot.cogs.streams.streamtypes`)
madebylydia commented 2023-12-29 13:43:02 +01:00 (Migrated from github.com)

Hello @KianBral, are you still interested to work on this PR?

Hello @KianBral, are you still interested to work on this PR?
madebylydia commented 2024-07-05 17:01:41 +02:00 (Migrated from github.com)

@Jackenmen This PR is stalling, but I would like this contribution merged. What can I do about it, so this can get merged, can I re-use this work and open my own PR? I'm unsure about how this is falling under the license if I reuse the code.

@Jackenmen This PR is stalling, but I would like this contribution merged. What can I do about it, so this can get merged, can I re-use this work and open my own PR? I'm unsure about how this is falling under the license if I reuse the code.
Jackenmen commented 2024-07-05 17:03:57 +02:00 (Migrated from github.com)

You need to keep commit authorship so that when we merge it from your PR, it is attributed to all its authors, not just you.

You need to keep commit authorship so that when we merge it from your PR, it is attributed to all its authors, not just you.
Jackenmen commented 2026-05-22 07:22:36 +02:00 (Migrated from github.com)

Superseded by #6483

Superseded by #6483

Pull request closed

Sign in to join this conversation.
No reviewers
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!4668
No description provided.