diff options
author | 2018-09-13 08:24:35 +0000 | |
---|---|---|
committer | 2018-09-13 08:24:35 +0000 | |
commit | 4451b2b62da63cd07a205b6162f37d94031dbcb2 (patch) | |
tree | ff88eaf5e21ebb39ba898468e15c4e130002b3e5 | |
parent | [Snekbox] Show help when eval run without code (diff) | |
parent | Fixed linting issues (oops) (diff) |
Merge branch 'apostrophes-in-otnames' into 'master'
Patched off-topic system to allow alternative apostrophe character, and convert accordingly.
See merge request python-discord/projects/bot!57
-rw-r--r-- | bot/cogs/off_topic_names.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/bot/cogs/off_topic_names.py b/bot/cogs/off_topic_names.py index bcf3148f8..ac2e1269c 100644 --- a/bot/cogs/off_topic_names.py +++ b/bot/cogs/off_topic_names.py @@ -19,19 +19,22 @@ class OffTopicName(Converter): @staticmethod async def convert(ctx: Context, argument: str): + allowed_characters = ("-", "’", "'", "`") + if not (2 <= len(argument) <= 96): raise BadArgument("Channel name must be between 2 and 96 chars long") - elif not all(c.isalnum() or c == '-' for c in argument): + elif not all(c.isalnum() or c in allowed_characters for c in argument): raise BadArgument( - "Channel name must only consist of" - " alphanumeric characters or minus signs" + "Channel name must only consist of " + "alphanumeric characters, minus signs or apostrophes." ) elif not argument.islower(): raise BadArgument("Channel name must be lowercase") - return argument + # Replace some unusable apostrophe-like characters with "’". + return argument.replace("'", "’").replace("`", "’") async def update_names(bot: Bot, headers: dict): |