<commit_before>from ModuleInterface import ModuleInterface
from IRCResponse import IRCResponse, ResponseType
import GlobalVars


class Module(ModuleInterface):
    triggers = ["alias"]
    help = "alias <alias> <command> -- create a new alias, Ex. {}alias hugs do hugs".format(GlobalVars.CommandChar)

    def onTrigger(self, Hubbot, message):
        if message.User.Name not in GlobalVars.admins:
            return IRCResponse(ResponseType.Say, "Only my admins may create new aliases!", message.ReplyTo)
        if len(message.ParameterList) <= 1:
            return IRCResponse(ResponseType.Say, "Alias what?", message.ReplyTo)
        newAlias = []
        for word in message.ParameterList[1:]:
            newAlias.append(word.lower())
        GlobalVars.commandAliases[message.ParameterList[0]] = newAlias
        return IRCResponse(ResponseType.Say, "Created a new alias '{}' for '{}'.".format(message.ParameterList[0], " ".join(message.ParameterList[1:])), message.ReplyTo)<commit_msg>[Alias] An alias may not match an existing trigger.<commit_after>from ModuleInterface import ModuleInterface
from IRCResponse import IRCResponse, ResponseType
import GlobalVars


class Module(ModuleInterface):
    triggers = ["alias"]
    help = "alias <alias> <command> -- create a new alias, Ex. {}alias hugs do hugs".format(GlobalVars.CommandChar)

    def onTrigger(self, Hubbot, message):
        if message.User.Name not in GlobalVars.admins:
            return IRCResponse(ResponseType.Say, "Only my admins may create new aliases!", message.ReplyTo)
        if len(message.ParameterList) <= 1:
            return IRCResponse(ResponseType.Say, "Alias what?", message.ReplyTo)
        for (name, module) in GlobalVars.modules.items():
            if message.ParameterList[0] in module.triggers:
                return IRCResponse(ResponseType.Say, "A new alias may not be the same as an existing command trigger!", message.ReplyTo)
        newAlias = []
        for word in message.ParameterList[1:]:
            newAlias.append(word.lower())
        GlobalVars.commandAliases[message.ParameterList[0]] = newAlias
        return IRCResponse(ResponseType.Say, "Created a new alias '{}' for '{}'.".format(message.ParameterList[0], " ".join(message.ParameterList[1:])), message.ReplyTo)
{'fraction_non_alphanumeric': 0.11257117827420061, 'fraction_numerical': 0.004818221638195357, 'mean_word_length': 3.6899383983572895, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3048571', 'n_tokens_mistral': 646, 'n_tokens_neox': 643, 'n_words': 178}