Browse Source

Add "location" tracking for rooms

One of the things that's hard about using the ptg page is that you
don't know where things are located. This allows you to set the
location on a room, which is displayed in a 3rd column, and will be
persistent after a new set of now (thus not requiring everyone to
remember to include it in their updates).

Change-Id: I12bac56e29cc5974d5c925f23eb94945e6e36421
changes/41/502541/1
Sean Dague 4 years ago
parent
commit
7b193a0802
3 changed files with 14 additions and 4 deletions
  1. +4
    -3
      html/ptg.html
  2. +2
    -0
      ptgbot/bot.py
  3. +8
    -1
      ptgbot/db.py

+ 4
- 3
html/ptg.html View File

@ -27,10 +27,11 @@
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">Currently playing...</h3></div>
<table class="table">
{{#each now}}
{{#each now as |what room|}}
<tr>
<td class="col-sm-1"><span class="label label-primary {{@key}}">{{@key}}</span></td>
<td>{{#hashtag}}{{this}}{{/hashtag}}</td>
<td class="col-sm-1"><span class="label label-primary {{room}}">{{room}}</span></td>
<td>{{#hashtag}}{{what}}{{/hashtag}}</td>
<td class="col-sm-1">{{lookup @root.location room}}</td>
</tr>
{{else}}
<tr><td><small><i>Nothing yet</i></small><td></tr>


+ 2
- 0
ptgbot/bot.py View File

@ -137,6 +137,8 @@ class PTGBot(irc.bot.SingleServerIRCBot):
self.data.clean_rooms([room])
elif adverb == 'color':
self.data.add_color(room, session)
elif adverb == 'location':
self.data.add_location(room, session)
else:
self.send(chan, "%s: unknown directive '%s'" % (nick, adverb))
self.usage(chan)


+ 8
- 1
ptgbot/db.py View File

@ -21,7 +21,8 @@ import datetime
class PTGDataBase():
BASE = {'rooms': [], 'ethercalc': [], 'now': {}, 'next': {}, 'colors': {}}
BASE = {'rooms': [], 'ethercalc': [], 'now': {}, 'next': {}, 'colors': {},
'location': {}}
def __init__(self, filename, ethercalc):
self.filename = filename
@ -43,6 +44,12 @@ class PTGDataBase():
self.data['colors'][room] = color
self.save()
def add_location(self, room, location):
if 'location' not in self.data:
self.data['location'] = {}
self.data['location'][room] = location
self.save()
def add_next(self, room, session):
if room not in self.data['next']:
self.data['next'][room] = []


Loading…
Cancel
Save