Specify and load event schedule
In order to be able to specify topic/room assignments, we need a map of the available time slots. Specify that at the config level. Change-Id: I58e3d13e169a66c10e74ec9faa97243a40f14ee0
This commit is contained in:
parent
3b87290132
commit
2ddba00d6d
|
@ -4,5 +4,27 @@
|
||||||
"irc_server": "irc.freenode.net",
|
"irc_server": "irc.freenode.net",
|
||||||
"irc_port": 6667,
|
"irc_port": 6667,
|
||||||
"irc_channel": "#CHANNEL",
|
"irc_channel": "#CHANNEL",
|
||||||
"db_filename": "html/ptg.json"
|
"db_filename": "html/ptg.json",
|
||||||
|
"slots": {
|
||||||
|
"Monday": [
|
||||||
|
{
|
||||||
|
"name": "MonAM",
|
||||||
|
"desc": "09:00-12:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MonPM",
|
||||||
|
"desc": "14:00-17:00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Tuesday": [
|
||||||
|
{
|
||||||
|
"name": "TueAM",
|
||||||
|
"desc": "09:00-12:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "TuePM",
|
||||||
|
"desc": "14:00-17:00"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import collections
|
||||||
import daemon
|
import daemon
|
||||||
import irc.bot
|
import irc.bot
|
||||||
import json
|
import json
|
||||||
|
@ -171,7 +172,7 @@ class PTGBot(irc.bot.SingleServerIRCBot):
|
||||||
|
|
||||||
def start(configpath):
|
def start(configpath):
|
||||||
with open(configpath, 'r') as fp:
|
with open(configpath, 'r') as fp:
|
||||||
config = json.load(fp)
|
config = json.load(fp, object_pairs_hook=collections.OrderedDict)
|
||||||
|
|
||||||
if 'log_config' in config:
|
if 'log_config' in config:
|
||||||
log_config = config['log_config']
|
log_config = config['log_config']
|
||||||
|
@ -182,7 +183,7 @@ def start(configpath):
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
db = ptgbot.db.PTGDataBase(config['db_filename'])
|
db = ptgbot.db.PTGDataBase(config['db_filename'], config['slots'])
|
||||||
|
|
||||||
bot = PTGBot(config['irc_nick'],
|
bot = PTGBot(config['irc_nick'],
|
||||||
config.get('irc_pass', ''),
|
config.get('irc_pass', ''),
|
||||||
|
|
|
@ -21,16 +21,17 @@ import datetime
|
||||||
|
|
||||||
class PTGDataBase():
|
class PTGDataBase():
|
||||||
|
|
||||||
BASE = {'tracks': [], 'now': {}, 'next': {}, 'colors': {},
|
BASE = {'tracks': [], 'slots': {}, 'now': {}, 'next': {}, 'colors': {},
|
||||||
'location': {}}
|
'location': {}}
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename, slots):
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
with open(filename, 'r') as fp:
|
with open(filename, 'r') as fp:
|
||||||
self.data = json.load(fp)
|
self.data = json.load(fp)
|
||||||
else:
|
else:
|
||||||
self.data = self.BASE
|
self.data = self.BASE
|
||||||
|
self.data['slots'] = slots
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def add_now(self, track, session):
|
def add_now(self, track, session):
|
||||||
|
|
Loading…
Reference in New Issue