diff --git a/README.rst b/README.rst index 0e2d5da..21bd4f3 100644 --- a/README.rst +++ b/README.rst @@ -19,7 +19,8 @@ You have to have voice in the channel (+v) to send commands to the ptgbot. Commands follow the following format:: #TRACK [now|next] TOPIC - #TRACK [color] CSS_COLOR_SPECIFIER + #TRACK color CSS_COLOR_SPECIFIER + #TRACK book SLOT_REFERENCE Please note that: diff --git a/html/ptg.html b/html/ptg.html index 7041fba..d58e6b8 100644 --- a/html/ptg.html +++ b/html/ptg.html @@ -111,7 +111,11 @@ {{#each @root.additional as |schedule room|}} {{room}} {{#each (lookup @root.slots day) as |time|}} + {{#if (lookup schedule time.name)}} {{lookup schedule time.name}} + {{else}} + {{room}}-{{time.name}} + {{/if}} {{/each}} {{/each}} @@ -119,6 +123,7 @@ {{/each}} + Use #TRACK book SLOTREF to book one of those empty slots

Content on this page is being driven by room operators through the openstackptg bot on the #openstack-ptg IRC channel. It was last refreshed on {{timestamp}}.

diff --git a/ptgbot/bot.py b/ptgbot/bot.py index 6ae7a34..b085e36 100644 --- a/ptgbot/bot.py +++ b/ptgbot/bot.py @@ -129,17 +129,24 @@ class PTGBot(irc.bot.SingleServerIRCBot): return adverb = words[1].lower() - session = str.join(' ', words[2:]) + params = str.join(' ', words[2:]) if adverb == 'now': - self.data.add_now(track, session) + self.data.add_now(track, params) elif adverb == 'next': - self.data.add_next(track, session) + self.data.add_next(track, params) elif adverb == 'clean': self.data.clean_tracks([track]) elif adverb == 'color': - self.data.add_color(track, session) + self.data.add_color(track, params) elif adverb == 'location': - self.data.add_location(track, session) + self.data.add_location(track, params) + elif adverb == 'book': + room, timeslot = params.split('-') + if self.data.is_slot_valid_and_empty(room, timeslot): + self.data.book(track, room, timeslot) + else: + self.send(chan, "%s: invalid slot reference '%s'" % + (nick, params)) else: self.send(chan, "%s: unknown directive '%s'" % (nick, adverb)) self.usage(chan) diff --git a/ptgbot/db.py b/ptgbot/db.py index bb3bf7f..944df6b 100644 --- a/ptgbot/db.py +++ b/ptgbot/db.py @@ -104,6 +104,16 @@ class PTGDataBase(): del self.data['next'][track] self.save() + def is_slot_valid_and_empty(self, room, timeslot): + try: + return not self.data['additional'][room][timeslot] + except KeyError: + return False + + def book(self, track, room, timeslot): + self.data['additional'][room][timeslot] = track + self.save() + def wipe(self): self.data = self.BASE self.save()