Browse Source

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
changes/42/529842/1
Thierry Carrez 2 years ago
parent
commit
96d1a8421b
3 changed files with 11 additions and 1 deletions
  1. +3
    -0
      README.rst
  2. +2
    -1
      ptgbot/bot.py
  3. +6
    -0
      ptgbot/db.py

+ 3
- 0
README.rst View File

@@ -74,6 +74,9 @@ You have to be a channel operator (+o) to use admin commands.
~clean TRACK [TRACK..]
Removes active entries for specified track(s)

~newday
Removes now/next/location entries, to be run at the start of a new day

~wipe
Resets the database entirely (removes all defined tracks and topics)



+ 2
- 1
ptgbot/bot.py View File

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


+ 6
- 0
ptgbot/db.py View File

@@ -128,6 +128,12 @@ class PTGDataBase():
self.data['additional'][room][timeslot] = track
self.save()

def new_day_cleanup(self):
self.data['now'] = {}
self.data['next'] = {}
self.data['location'] = {}
self.save()

def wipe(self):
self.data = self.BASE
self.save()


Loading…
Cancel
Save