From 4aa7092a0c48846be8c84fbdeb669550e10a1c0d Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Thu, 7 Aug 2014 14:53:07 +0200 Subject: [PATCH] add command %delquote --- contrib/boobot.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/contrib/boobot.py b/contrib/boobot.py index bdebc79a..ccf655ea 100755 --- a/contrib/boobot.py +++ b/contrib/boobot.py @@ -291,6 +291,21 @@ class Boobot(SingleServerIRCBot): quotes.append({'author': nick, 'timestamp': datetime.now(), 'text': text}) self.storage.set(channel, 'quotes', quotes) self.storage.save() + self.send_message('Quote #%s added' % len(quotes) - 1, channel) + + def cmd_delquote(self, nick, channel, text): + quotes = self.storage.get(channel, 'quotes', default=[]) + + try: + n = int(text) + except ValueError: + self.send_message("Quote #%s not found gros" % text, channel) + return + + quotes.pop(n) + self.storage.set(channel, 'quotes', quotes) + self.storage.save() + self.send_message('Quote #%s removed' % n, channel) def cmd_searchquote(self, nick, channel, text): try: