<commit_before>from zope.interface import implementer
from twisted.plugin import IPlugin

from desertbot.message import IRCMessage
from desertbot.moduleinterface import IModule
from desertbot.modules.commandinterface import admin, BotCommand
from desertbot.response import IRCResponse, ResponseType

import random


@implementer(IPlugin, IModule)
class Storage(BotCommand):
    def triggers(self):
        return ["storage"]

    def actions(self):
        return super(Storage, self).actions() + [("storage-load", 1, self.loadStorage),
                                                 ("storage-save", 1, self.saveStorage)]

    def help(self, query):
        helpDict = {
            "storage": f"{self.bot.commandChar}storage stopsync/startsync/load/save <modulename> - Manage bot storage files.",
            "stopsync": f"{self.bot.commandChar}storage stopsync <modulename> - Halts the periodic autosave for the specified modules storage file.",
            "startsync": f"{self.bot.commandChar}storage startsync <modulename> - Start periodic autosave for the specified modules storage file.",
            "load": f"{self.bot.commandChar}storage load <modulename> - Manually load the specified modules storage from file.",
            "save": f"{self.bot.commandChar}storage save <modulename> - Manually save the specified modules storage to file."
        }
        if len(query) > 1 and query[1].lower() in helpDict:
            return helpDict[query[1].lower()]
        else:
            return f"{self.bot.commandChar}storage stopsync/startsync/load/save <modulename> - Manage bot storage files."

    def execute(self, message: IRCMessage):
        if len(message.parameterList) <= 2:
            return IRCResponse(ResponseType.Say, self.help(["storage"]), message.replyTo)
        else:
            subcommand = message.parameterList[0].lower()
            if subcommand == "stopsync":
                return self.stopStorageSync(message)
            elif subcommand == "startsync":
                return self.startStorageSync(message)
            elif subcommand == "load":
                return self.loadStorage(message)
            elif subcommand == "save":
                return self.saveStorage(message)

    @admin("[Storage] Only my admins may stop my storage sync!")
    def stopStorageSync(self, message: IRCMessage):
        moduleNames = self._getValidModuleNames(message.parameterList[1:])
        for moduleName in moduleNames:
            self._stopDataSync(moduleName)
        return IRCResponse(ResponseType.Say,
                           f"Stopped storage sync for modules {', '.join(moduleNames)}. They will no longer periodically autosave to file!",
                           message.replyTo)

    @admin("[Storage] Only my admins may start up my storage sync!")<commit_msg>[Storage] Fix bug with parameterList check<commit_after>from zope.interface import implementer
from twisted.plugin import IPlugin

from desertbot.message import IRCMessage
from desertbot.moduleinterface import IModule
from desertbot.modules.commandinterface import admin, BotCommand
from desertbot.response import IRCResponse, ResponseType

import random


@implementer(IPlugin, IModule)
class Storage(BotCommand):
    def triggers(self):
        return ["storage"]

    def actions(self):
        return super(Storage, self).actions() + [("storage-load", 1, self.loadStorage),
                                                 ("storage-save", 1, self.saveStorage)]

    def help(self, query):
        helpDict = {
            "storage": f"{self.bot.commandChar}storage stopsync/startsync/load/save <modulename> - Manage bot storage files.",
            "stopsync": f"{self.bot.commandChar}storage stopsync <modulename> - Halts the periodic autosave for the specified modules storage file.",
            "startsync": f"{self.bot.commandChar}storage startsync <modulename> - Start periodic autosave for the specified modules storage file.",
            "load": f"{self.bot.commandChar}storage load <modulename> - Manually load the specified modules storage from file.",
            "save": f"{self.bot.commandChar}storage save <modulename> - Manually save the specified modules storage to file."
        }
        if len(query) > 1 and query[1].lower() in helpDict:
            return helpDict[query[1].lower()]
        else:
            return f"{self.bot.commandChar}storage stopsync/startsync/load/save <modulename> - Manage bot storage files."

    def execute(self, message: IRCMessage):
        if len(message.parameterList) < 2:
            return IRCResponse(ResponseType.Say, self.help(["storage"]), message.replyTo)
        else:
            subcommand = message.parameterList[0].lower()
            if subcommand == "stopsync":
                return self.stopStorageSync(message)
            elif subcommand == "startsync":
                return self.startStorageSync(message)
            elif subcommand == "load":
                return self.loadStorage(message)
            elif subcommand == "save":
                return self.saveStorage(message)

    @admin("[Storage] Only my admins may stop my storage sync!")
    def stopStorageSync(self, message: IRCMessage):
        moduleNames = self._getValidModuleNames(message.parameterList[1:])
        for moduleName in moduleNames:
            self._stopDataSync(moduleName)
        return IRCResponse(ResponseType.Say,
                           f"Stopped storage sync for modules {', '.join(moduleNames)}. They will no longer periodically autosave to file!",
                           message.replyTo)

    @admin("[Storage] Only my admins may start up my storage sync!")
{'fraction_non_alphanumeric': 0.09893805309734513, 'fraction_numerical': 0.002831858407079646, 'mean_word_length': 2.762316910785619, 'pattern_counts': {'":': 18, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4208806', 'n_tokens_mistral': 1477, 'n_tokens_neox': 1454, 'n_words': 422}