Let room operators clean up themselves

Add a '#ROOM clean' command at room operator level.

Change-Id: I81c08c9430df14615f2e4ec490f6b850335337be
This commit is contained in:
Thierry Carrez 2017-08-18 16:25:31 +02:00
parent 0084e17e31
commit 6a223d31fe
2 changed files with 11 additions and 2 deletions

View File

@ -41,6 +41,11 @@ Example::
#swift now discussing #glance support, come over!
#swift next at 3pm we plan to cover cold storage features
You can also remove all entries related to your room by issuing the following
command::
#ROOMNAME clean
Admin commands
==============

View File

@ -89,7 +89,8 @@ class PTGBot(irc.bot.SingleServerIRCBot):
self.identify_msg_cap = True
def usage(self, channel):
self.send(channel, "Format is '@ROOM [now|next] SESSION'")
self.send(channel,
"Format is '#ROOMNAME [ now ... | next ... | clean ]'")
def send_room_list(self, channel):
rooms = self.data.list_rooms()
@ -114,7 +115,8 @@ class PTGBot(irc.bot.SingleServerIRCBot):
return
words = msg.split()
if len(words) < 3:
if ((len(words) < 2) or
(len(words) == 2 and words[1].lower() != 'clean')):
self.send(chan, "%s: Incorrect number of arguments" % (nick,))
self.usage(chan)
return
@ -131,6 +133,8 @@ class PTGBot(irc.bot.SingleServerIRCBot):
self.data.add_now(room, session)
elif adverb == 'next':
self.data.add_next(room, session)
elif adverb == 'clean':
self.data.clean_rooms([room])
else:
self.send(chan, "%s: unknown directive '%s'" % (nick, adverb))
self.usage(chan)