# Path: bot/commands/abstract/command.py
# class Command(ABC):
#     """Represents a command, a way of reacting to chat messages."""
# 
#     perm = Permission.Admin
# 
#     def __init__(self, bot):
#         """Initialize the command."""
#         pass
# 
#     def match(self, bot, user, msg, tag_info):
#         """Return whether this command should be run."""
#         return False
# 
#     def run(self, bot, user, msg, tag_info):
#         """Run this command."""
#         pass
# 
#     def close(self, bot):
#         """Clean up."""
#         pass
# 
# Path: bot/utilities/tools.py
# def replace_vars(msg, args):
#     """Replace the variables in the message."""
#     oldmsg = msg
#     newmsg = msg
# 
#     for key in args:
#         newmsg = newmsg.replace(key, str(args[key]))
#         """Check if something was replaced, otherwise something went wrong."""
#         if newmsg is oldmsg:
#             print("ERROR: Could not replace variable in string!")
# 
#         oldmsg = newmsg
#     return newmsg


from bot.commands.abstract.command import Command
from bot.utilities.permission import Permission
from bot.utilities.tools import replace_vars

    perm = Permission.Admin

    def __init__(self, _):
        """Initialize variables."""
        self.responses = {}

    def match(self, bot, user, msg, tag_info):
        """Match if !addmod or !delmod."""
        return (msg.startswith("!addmod ") or msg.startswith("!delmod ")) and len(
            msg.split(" ")
        ) == 2

    def run(self, bot, user, msg, tag_info):
        """Add or delete a mod."""
        self.responses = bot.config.responses["EditCommandMods"]
        mod = msg.split(" ")[1].lower()
        if msg.startswith("!addmod "):
            if mod not in bot.config.trusted_mods:
                bot.config.trusted_mods.append(mod)
                bot.write(self.responses["mod_added"]["msg"])
            else:
                var = {"<USER>": mod}
                bot.write(replace_vars(self.responses["already_mod"]["msg"], var))
        elif msg.startswith("!delmod "):
            if mod in bot.config.trusted_mods:
                bot.config.trusted_mods.remove(mod)
                bot.write(self.responses["mod_deleted"]["msg"])
            else:
                var = {"<USER>": mod}

# Path: bot/commands/abstract/command.py
# class Command(ABC):
#     """Represents a command, a way of reacting to chat messages."""
# 
#     perm = Permission.Admin
# 
#     def __init__(self, bot):
#         """Initialize the command."""
#         pass
# 
#     def match(self, bot, user, msg, tag_info):
#         """Return whether this command should be run."""
#         return False
# 
#     def run(self, bot, user, msg, tag_info):
#         """Run this command."""
#         pass
# 
#     def close(self, bot):
#         """Clean up."""
#         pass
# 
# Path: bot/utilities/tools.py
# def replace_vars(msg, args):
#     """Replace the variables in the message."""
#     oldmsg = msg
#     newmsg = msg
# 
#     for key in args:
#         newmsg = newmsg.replace(key, str(args[key]))
#         """Check if something was replaced, otherwise something went wrong."""
#         if newmsg is oldmsg:
#             print("ERROR: Could not replace variable in string!")
# 
#         oldmsg = newmsg
#     return newmsg


# Path: bot/commands/editcommandmods.py
from bot.commands.abstract.command import Command
from bot.utilities.permission import Permission
from bot.utilities.tools import replace_vars


    perm = Permission.Admin

    def __init__(self, _):
        """Initialize variables."""
        self.responses = {}

    def match(self, bot, user, msg, tag_info):
        """Match if !addmod or !delmod."""
        return (msg.startswith("!addmod ") or msg.startswith("!delmod ")) and len(
            msg.split(" ")
        ) == 2

    def run(self, bot, user, msg, tag_info):
        """Add or delete a mod."""
        self.responses = bot.config.responses["EditCommandMods"]
        mod = msg.split(" ")[1].lower()
        if msg.startswith("!addmod "):
            if mod not in bot.config.trusted_mods:
                bot.config.trusted_mods.append(mod)
                bot.write(self.responses["mod_added"]["msg"])
            else:
                var = {"<USER>": mod}
                bot.write(replace_vars(self.responses["already_mod"]["msg"], var))
        elif msg.startswith("!delmod "):
            if mod in bot.config.trusted_mods:
                bot.config.trusted_mods.remove(mod)
                bot.write(self.responses["mod_deleted"]["msg"])
            else:
                var = {"<USER>": mod}

                bot.write(replace_vars(self.responses["user_not_in_list"]["msg"], var))