From 7b193a0802d4453a8cec49c04f060d5af40ca378 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 11 Sep 2017 13:12:13 -0600 Subject: [PATCH] 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 --- html/ptg.html | 7 ++++--- ptgbot/bot.py | 2 ++ ptgbot/db.py | 9 ++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/html/ptg.html b/html/ptg.html index b15744f..ee56321 100644 --- a/html/ptg.html +++ b/html/ptg.html @@ -27,10 +27,11 @@

Currently playing...

- {{#each now}} + {{#each now as |what room|}} - - + + + {{else}} diff --git a/ptgbot/bot.py b/ptgbot/bot.py index 05f3e14..42ff544 100644 --- a/ptgbot/bot.py +++ b/ptgbot/bot.py @@ -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) diff --git a/ptgbot/db.py b/ptgbot/db.py index addf3e8..71331d2 100644 --- a/ptgbot/db.py +++ b/ptgbot/db.py @@ -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] = []
{{@key}}{{#hashtag}}{{this}}{{/hashtag}}{{room}}{{#hashtag}}{{what}}{{/hashtag}}{{lookup @root.location room}}
Nothing yet