Add command to clean up at start of day

The ~newday admin command cleans up now/next/location to
get to a fresh start at the beginning of a new day / end of
previous day.

Change-Id: I0a274164939a37e4a3aa9f734d4aebdc4cd82bf3
This commit is contained in:
Thierry Carrez 2017-12-22 16:08:30 +01:00
parent 9046cbe463
commit 96d1a8421b
3 changed files with 11 additions and 1 deletions

View File

@ -74,6 +74,9 @@ You have to be a channel operator (+o) to use admin commands.
~clean TRACK [TRACK..] ~clean TRACK [TRACK..]
Removes active entries for specified track(s) Removes active entries for specified track(s)
~newday
Removes now/next/location entries, to be run at the start of a new day
~wipe ~wipe
Resets the database entirely (removes all defined tracks and topics) Resets the database entirely (removes all defined tracks and topics)

View File

@ -160,9 +160,10 @@ class PTGBot(irc.bot.SingleServerIRCBot):
command = words[0][1:].lower() command = words[0][1:].lower()
if command == 'wipe': if command == 'wipe':
self.data.wipe() self.data.wipe()
elif command == 'newday':
self.data.new_day_cleanup()
elif command == 'list': elif command == 'list':
self.send_track_list(chan) self.send_track_list(chan)
return
elif command in ('clean', 'add', 'del'): elif command in ('clean', 'add', 'del'):
if len(words) < 2: if len(words) < 2:
self.send(chan, "this command takes one or more arguments") self.send(chan, "this command takes one or more arguments")

View File

@ -128,6 +128,12 @@ class PTGDataBase():
self.data['additional'][room][timeslot] = track self.data['additional'][room][timeslot] = track
self.save() self.save()
def new_day_cleanup(self):
self.data['now'] = {}
self.data['next'] = {}
self.data['location'] = {}
self.save()
def wipe(self): def wipe(self):
self.data = self.BASE self.data = self.BASE
self.save() self.save()