Browse Source

Add ability to book a room

Available room slots can be booked for any track through
the ptgbot new #book command, referencing the slot code.

Change-Id: I0c661e448568c7f2f26fb296e3f2506ba1ed44ba
changes/87/529587/2
Thierry Carrez 2 years ago
parent
commit
c637840754
4 changed files with 29 additions and 6 deletions
  1. +2
    -1
      README.rst
  2. +5
    -0
      html/ptg.html
  3. +12
    -5
      ptgbot/bot.py
  4. +10
    -0
      ptgbot/db.py

+ 2
- 1
README.rst View File

@@ -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:



+ 5
- 0
html/ptg.html View File

@@ -111,7 +111,11 @@
{{#each @root.additional as |schedule room|}}
<tr><td>{{room}}</td>
{{#each (lookup @root.slots day) as |time|}}
{{#if (lookup schedule time.name)}}
<td><span class="label label-primary {{lookup schedule time.name}}">{{lookup schedule time.name}}</td>
{{else}}
<td><small><i>{{room}}-{{time.name}}</i></small></td>
{{/if}}
{{/each}}
</tr>
{{/each}}
@@ -119,6 +123,7 @@
</div>
{{/each}}
</div>
<small><i>Use #TRACK book SLOTREF to book one of those empty slots</i></small></td>
</div>
</div>
<p class="text-muted">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}}.</p>


+ 12
- 5
ptgbot/bot.py View File

@@ -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)


+ 10
- 0
ptgbot/db.py View File

@@ -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()


Loading…
Cancel
Save