Browse Source

Add admin 'wipe' command

Add framework for admin commands (reserved to channel ops),
and introduce the wipe command (cleans up the database).
changes/56/473756/1
Thierry Carrez 4 years ago
parent
commit
048dfc01e2
2 changed files with 17 additions and 0 deletions
  1. +13
    -0
      ptgbot/bot.py
  2. +4
    -0
      ptgbot/db.py

+ 13
- 0
ptgbot/bot.py View File

@ -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)


+ 4
- 0
ptgbot/db.py View File

@ -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:


Loading…
Cancel
Save