Exemple #1
0
    def delquote(self, bot, msg):
        """Delete a quote from the list."""
        quote = msg[len("!delquote ") :]
        quote.strip()

        if quote in self.quotelist:
            self.quotelist.remove(quote)
            with open(QUOTES_FILE.format(bot.root), "w", encoding="utf-8") as file:
                json.dump(self.quotelist, file, indent=4)
            bot.reload_commands()  # Needs to happen to refresh the list.
            bot.write(self.responses["quote_removed"]["msg"])
        else:
            bot.write(self.responses["quote_not_found"]["msg"])
Exemple #2
0
    def addquote(self, bot, msg):
        """Add a quote to the list."""
        quote = msg[len("!addquote ") :]
        quote.strip()

        if quote not in self.quotelist:
            self.quotelist.append(quote)
            with open(QUOTES_FILE.format(bot.root), "w", encoding="utf-8") as file:
                json.dump(self.quotelist, file, indent=4)
            bot.reload_commands()  # Needs to happen to refresh the list.
            bot.write(self.responses["quote_added"]["msg"])
        else:
            bot.write(self.responses["quote_exists"]["msg"])
 def __init__(self, bot):
     """Load command list."""
     self.responses = {}
     with open(QUOTES_FILE.format(bot.root), encoding="utf-8") as file:
         self.quotelist = json.load(file)