Skip to content

Escape nicknames in patrick responses. - #67

Open
JoBeGaming wants to merge 9 commits into
OpenRedstoneEngineers:mainfrom
JoBeGaming:escape-usernames
Open

JoBeGaming wants to merge 9 commits into
OpenRedstoneEngineers:mainfrom
JoBeGaming:escape-usernames

Conversation

@JoBeGaming

@JoBeGaming JoBeGaming commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

See https://discord.com/channels/116914772766752769/165640273810948097/1544019167798239233 for embeds, and https://discord.com/channels/116914772766752769/1216162486152335471/1544010187546038282 as well as https://discord.com/channels/116914772766752769/1216162486152335471/1544010104511266841 for nickame usage in normal commands.

For tests, the output of the test attached was sent in https://discord.com/channels/116914772766752769/165640273810948097/1544010979694608516, and seems to raise no issues with Discord Markdown. See https://discord.com/channels/116914772766752769/165640273810948097/1544023339042087113 for tests related to links. Note that I've not implemented direct link escaping (https://www.youtube.com) yet.

assert escape_nickname("> job") == r"\> job"
assert escape_nickname("*job*") == r"\*job\*"
assert escape_nickname("**job**") == r"\*\*job\*\*"
assert escape_nickname("_job_") == r"\_job\_"
assert escape_nickname("__job__") == r"\_\_job\_\_"
assert escape_nickname("`job`") == r"\`job\`"
assert escape_nickname("> job") == r"\> job"
assert escape_nickname("~~job~~") == r"\~\~job\~\~"
assert escape_nickname("||job||") == r"\|\|job\|\|"

(Edit: Fix name of function in tests)

@JoBeGaming
JoBeGaming marked this pull request as draft September 11, 2026 16:55

@Nickster258 Nickster258 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably shouldn't escape the logged statements. At the same time, would be worth logging the user ID in the event message.

Comment thread patrick.py Outdated
Comment thread patrick.py Outdated
Comment thread patrick.py Outdated
@Wueffi

Wueffi commented Sep 15, 2026

Copy link
Copy Markdown
Member

67

Comment thread util.py Outdated
@JoBeGaming

Copy link
Copy Markdown
Contributor Author

Weird how my commit from VSC got added, but the reply didn't get send...

@JoBeGaming
JoBeGaming marked this pull request as ready for review September 15, 2026 10:16
@JoBeGaming

Copy link
Copy Markdown
Contributor Author

Ok seems like I've forgotten to add cases such as # job, - job and -# job as I've primarily focused on names possible in Minecraft. I've updated the regex accordingly, although we might actually be better off using the function provided by discord.py later, if necessary.

@JoBeGaming

JoBeGaming commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author
assert escape_nickname("> job") == r"\> job"
assert escape_nickname("*job*") == r"\*job\*"
assert escape_nickname("**job**") == r"\*\*job\*\*"
assert escape_nickname("_job_") == r"\_job\_"
assert escape_nickname("__job__") == r"\_\_job\_\_"
assert escape_nickname("`job`") == r"\`job\`"
assert escape_nickname("> job") == r"\> job"
assert escape_nickname("~~job~~") == r"\~\~job\~\~"
assert escape_nickname("||job||") == r"\|\|job\|\|"
assert escape_nickname("# job") == r"\# job"
assert escape_nickname("- job") == r"\- job"
assert escape_nickname("-# job") == r"\-\# job"

(Updated test-cases if anyone is interested)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants