diff options
| -rw-r--r-- | bot/utils/messages.py | 8 |
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) |