aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-06-17 17:04:48 -0700
committerGravatar MarkKoz <[email protected]>2020-06-17 17:04:48 -0700
commit311326b21fe887063f0d4f757b9624f41ed28418 (patch)
tree3447c99e070186c5f6997edd240db2d1cf1c2a44
parentFix 400 when "clyde" is in webhook username (diff)
Make sub_clyde case-sensitive and use Cyrillic e's
The Cyrillic characters are more likely to be rendered similarly to their Latin counterparts than the math sans-serif characters.
-rw-r--r--bot/utils/messages.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/bot/utils/messages.py b/bot/utils/messages.py
index 6ad9351cc..c7d756708 100644
--- a/bot/utils/messages.py
+++ b/bot/utils/messages.py
@@ -119,10 +119,14 @@ async def send_attachments(
def sub_clyde(username: Optional[str]) -> Optional[str]:
"""
- Replace "e" in any "clyde" in `username` with a similar Unicode char and return the new string.
+ Replace "e"/"E" in any "clyde" in `username` with a Cyrillic "е"/"E" and return the new string.
Discord disallows "clyde" anywhere in the username for webhooks. It will return a 400.
Return None only if `username` is None.
"""
+ def replace_e(match: re.Match) -> str:
+ char = "е" if match[2] == "e" else "Е"
+ return match[1] + char
+
if username:
- return re.sub(r"(clyd)e", r"\1𝖾", username, flags=re.I)
+ return re.sub(r"(clyd)(e)", replace_e, username, flags=re.I)