diff --git a/ptgbot/bot.py b/ptgbot/bot.py index 6a797b2..a981418 100644 --- a/ptgbot/bot.py +++ b/ptgbot/bot.py @@ -124,6 +124,19 @@ class PTGBot(irc.bot.SingleServerIRCBot): return self.send(chan, "%s: ack" % (nick,)) + if msg.startswith('!'): + if not self.channels[chan].is_oper(nick): + self.send(chan, "%s: Need op for admin commands" % (nick,)) + return + words = msg.split() + command = words[0][1:].lower() + if command == 'wipe': + self.data.wipe() + else: + self.send(chan, "%s: unknown command '%s'" % (nick, command)) + return + self.send(chan, "%s: done" % (nick,)) + def send(self, channel, msg): self.connection.privmsg(channel, msg) time.sleep(ANTI_FLOOD_SLEEP) diff --git a/ptgbot/db.py b/ptgbot/db.py index ac742e0..7ff1921 100644 --- a/ptgbot/db.py +++ b/ptgbot/db.py @@ -44,6 +44,10 @@ class PTGDataBase(): # TODO: Load from ethercalc pass + def wipe(self): + self.data = {'now': {}, 'next': {}} + self.save() + def save(self): # self.from_ethercalc() with open(self.filename, 'w') as fp: