Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Alias] Aliased commands retain newlines #4656

Merged
merged 6 commits into from
Jan 9, 2024

Conversation

goettner
Copy link
Contributor

@goettner goettner commented Dec 4, 2020

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

As detailed in issue #2704 when an alias for a command is created, and this alias is passed input, any newlines in the input are stripped. This is reproducible with the [p]say command (an example can be seen in the issue documentation).

To fix this, I altered the method get_extra_args_from_alias() in redbot/cogs/alias/alias_entry.py to not skip whitespace in between arguments, maintaining newlines if they exist. When these arguments are then formatted into the content of the message that is passed along to the bot, whitespace is not added back in. This should have the effect of better maintaining the passed message, while still allowing customized parameters to be inserted into the input.

I also added a test case for this issue to tests/cogs/test_alias.py. This required the splitting up of the call_alias in redbot/cogs/alias/alias.py into two functions, in order to return a value that could be tested. It also required the creation of two new fixtures in redbot/pytest/core.py, newline_message and prefix. In the case that more tests are eventually added to test_alias, these might prove useful.

I submitted an earlier PR here: #4632, but accidentally modified the commits. This PR incorporates the feedback given to me there, and should avoid interfering with alias parameter functionality.

Fixes #2704

@Jackenmen Jackenmen added Category: Cogs - Alias This is related to the Alias cog. Type: Fix labels Dec 4, 2020
@goettner goettner changed the title Alias retain newlines [Alias] Aliased commands retain newlines Dec 12, 2020
@Jackenmen Jackenmen added this to the 3.4.7 milestone Jan 20, 2021
@Jackenmen Jackenmen modified the milestones: 3.4.9, Backlog Apr 1, 2021
@Jackenmen Jackenmen added Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing. and removed Type: Fix labels Jul 15, 2021
@Flame442 Flame442 self-assigned this Dec 3, 2023
@github-actions github-actions bot added the Category: Core - Other Internals This is related to core internals that don't have a dedicated label. label Jan 8, 2024
@Flame442 Flame442 merged commit 569840e into Cog-Creators:V3/develop Jan 9, 2024
17 checks passed
@red-githubbot red-githubbot bot added the Changelog Entry: Pending Changelog entry for this PR hasn't been added by repo maintainers yet. label Jan 9, 2024
@Jackenmen Jackenmen added Changelog Entry: Added Changelog entry for this PR has already been added to changelog PR. and removed Changelog Entry: Pending Changelog entry for this PR hasn't been added by repo maintainers yet. labels Mar 22, 2024
Injabie3 added a commit to SFUAnime/Ren that referenced this pull request Apr 23, 2024
Merge tag '3.5.9' of Cog-Creators/Red-DiscordBot into V3/testing

For the alias cog, it looks like new line handling that was fixed in
issue #311 was handled upstream in Cog-Creators#4656.
Resolved merge conflict by removing our changes.
Dav-Git pushed a commit to Dav-Git/Red-DiscordBot that referenced this pull request Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Cogs - Alias This is related to the Alias cog. Category: Core - Other Internals This is related to core internals that don't have a dedicated label. Changelog Entry: Added Changelog entry for this PR has already been added to changelog PR. Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[V3 Alias] New lines don't get passed to target command
3 participants