From 492c8bd8b71de8e912ff8a02694d2a544221744d Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Tue, 13 Feb 2018 16:26:57 +0100 Subject: [PATCH] Add 'unbook' admin command Allows admins to clean up a booked slot. Change-Id: I3984530b38a725b537f1457ed3e64224845a170e --- README.rst | 3 +++ ptgbot/bot.py | 4 ++++ ptgbot/db.py | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/README.rst b/README.rst index 9afb215..d42583c 100644 --- a/README.rst +++ b/README.rst @@ -124,6 +124,9 @@ You have to be a channel operator (+o) to use admin commands. ~clean TRACK [TRACK..] Removes active entries for specified track(s) +~unbook SLOTCODE + Removes any booking at the slot named SLOTCODE + ~newday Removes now/next/location entries, to be run at the start of a new day diff --git a/ptgbot/bot.py b/ptgbot/bot.py index 29bc809..5f0d080 100644 --- a/ptgbot/bot.py +++ b/ptgbot/bot.py @@ -165,6 +165,10 @@ class PTGBot(irc.bot.SingleServerIRCBot): command = words[0][1:].lower() if command == 'reload': self.data.reload() + elif command == 'unbook': + params = str.join(' ', words[1:]) + room, timeslot = params.split('-') + self.data.unbook(room, timeslot) elif command == 'newday': self.data.new_day_cleanup() elif command == 'list': diff --git a/ptgbot/db.py b/ptgbot/db.py index ec1f360..5ad3a74 100644 --- a/ptgbot/db.py +++ b/ptgbot/db.py @@ -161,6 +161,12 @@ class PTGDataBase(): self.data['additional'][room][timeslot] = track self.save() + def unbook(self, room, timeslot): + if room in self.data['additional'].keys(): + if timeslot in self.data['additional'][room].keys(): + self.data['additional'][room][timeslot] = "" + self.save() + def new_day_cleanup(self): self.data['now'] = {} self.data['next'] = {}