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_port": 6667,
|
||||
"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.
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import daemon
|
||||
import irc.bot
|
||||
import json
|
||||
|
@ -171,7 +172,7 @@ class PTGBot(irc.bot.SingleServerIRCBot):
|
|||
|
||||
def start(configpath):
|
||||
with open(configpath, 'r') as fp:
|
||||
config = json.load(fp)
|
||||
config = json.load(fp, object_pairs_hook=collections.OrderedDict)
|
||||
|
||||
if 'log_config' in config:
|
||||
log_config = config['log_config']
|
||||
|
@ -182,7 +183,7 @@ def start(configpath):
|
|||
else:
|
||||
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'],
|
||||
config.get('irc_pass', ''),
|
||||
|
|
|
@ -21,16 +21,17 @@ import datetime
|
|||
|
||||
class PTGDataBase():
|
||||
|
||||
BASE = {'tracks': [], 'now': {}, 'next': {}, 'colors': {},
|
||||
BASE = {'tracks': [], 'slots': {}, 'now': {}, 'next': {}, 'colors': {},
|
||||
'location': {}}
|
||||
|
||||
def __init__(self, filename):
|
||||
def __init__(self, filename, slots):
|
||||
self.filename = filename
|
||||
if os.path.isfile(filename):
|
||||
with open(filename, 'r') as fp:
|
||||
self.data = json.load(fp)
|
||||
else:
|
||||
self.data = self.BASE
|
||||
self.data['slots'] = slots
|
||||
self.save()
|
||||
|
||||
def add_now(self, track, session):
|
||||
|
|
Loading…
Reference in New Issue