[V3 Alias] Allow wider range of aliases (#1201)

* [V3 Alias] Allow wider range of aliases

Possible fix for #1118

Makes it so that the only non-valid names are the ones that can't be printed by something.

* [V3 Alias] Edit Check & Error Message

Reflects the wider range of aliases that can be created.

* [V3 Alias] Fix wrong slash in regex

* [V3 Alias] Fix Wrong Closing Parenthesis Position

Can't believe I'm messing it up
This commit is contained in:
Aioxas 2018-01-14 23:28:57 -05:00 committed by palmtree5
parent 73c08da037
commit eb10508c5f

View File

@ -1,4 +1,5 @@
from copy import copy from copy import copy
from re import search
from typing import Generator, Tuple, Iterable from typing import Generator, Tuple, Iterable
import discord import discord
@ -75,7 +76,7 @@ class Alias:
@staticmethod @staticmethod
def is_valid_alias_name(alias_name: str) -> bool: def is_valid_alias_name(alias_name: str) -> bool:
return alias_name.isidentifier() return not bool(search(r'\s', alias_name)) and alias_name.isprintable()
async def add_alias(self, ctx: commands.Context, alias_name: str, async def add_alias(self, ctx: commands.Context, alias_name: str,
command: Tuple[str], global_: bool=False) -> AliasEntry: command: Tuple[str], global_: bool=False) -> AliasEntry:
@ -211,8 +212,7 @@ class Alias:
await ctx.send(_("You attempted to create a new alias" await ctx.send(_("You attempted to create a new alias"
" with the name {} but that" " with the name {} but that"
" name is an invalid alias name. Alias" " name is an invalid alias name. Alias"
" names may only contain letters, numbers," " names may not contain spaces.").format(alias_name))
" and underscores and must start with a letter.").format(alias_name))
return return
# endregion # endregion
@ -250,8 +250,7 @@ class Alias:
await ctx.send(_("You attempted to create a new global alias" await ctx.send(_("You attempted to create a new global alias"
" with the name {} but that" " with the name {} but that"
" name is an invalid alias name. Alias" " name is an invalid alias name. Alias"
" names may only contain letters, numbers," " names may not contain spaces.").format(alias_name))
" and underscores and must start with a letter.").format(alias_name))
return return
# endregion # endregion