|
|
@ -84,9 +84,12 @@ def post_schedule(client, send_client, start_time, schedule, stream, hour, no_me
|
|
|
|
coming_online = []
|
|
|
|
coming_online = []
|
|
|
|
display_names = {}
|
|
|
|
display_names = {}
|
|
|
|
supervisor = None
|
|
|
|
supervisor = None
|
|
|
|
|
|
|
|
found_any = False
|
|
|
|
for user_id, (_, hours) in schedule.items():
|
|
|
|
for user_id, (_, hours) in schedule.items():
|
|
|
|
prev = get_role_at_hour(hours, hour - 1)
|
|
|
|
prev = get_role_at_hour(hours, hour - 1)
|
|
|
|
now = get_role_at_hour(hours, hour)
|
|
|
|
now = get_role_at_hour(hours, hour)
|
|
|
|
|
|
|
|
if now != "" or prev != "":
|
|
|
|
|
|
|
|
found_any = True
|
|
|
|
if now == "Supervisor":
|
|
|
|
if now == "Supervisor":
|
|
|
|
supervisor = user_id
|
|
|
|
supervisor = user_id
|
|
|
|
if user_id not in display_names:
|
|
|
|
if user_id not in display_names:
|
|
|
@ -98,6 +101,10 @@ def post_schedule(client, send_client, start_time, schedule, stream, hour, no_me
|
|
|
|
coming_online.append((now, user_id))
|
|
|
|
coming_online.append((now, user_id))
|
|
|
|
if user_id not in display_names:
|
|
|
|
if user_id not in display_names:
|
|
|
|
display_names[user_id] = gevent.spawn(get_display_name, client, user_id)
|
|
|
|
display_names[user_id] = gevent.spawn(get_display_name, client, user_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not found_any:
|
|
|
|
|
|
|
|
logging.info("Not posting schedule for hour {} as no-one is or was scheduled".format(hour))
|
|
|
|
|
|
|
|
|
|
|
|
# sort by role
|
|
|
|
# sort by role
|
|
|
|
going_offline.sort()
|
|
|
|
going_offline.sort()
|
|
|
|
coming_online.sort()
|
|
|
|
coming_online.sort()
|
|
|
@ -180,7 +187,7 @@ def parse_schedule(user_ids, schedule_file):
|
|
|
|
return schedule
|
|
|
|
return schedule
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(conf_file, hour=-1, no_groups=False, stream="General", no_mentions=False):
|
|
|
|
def main(conf_file, hour=-1, no_groups=False, stream="General", no_mentions=False, no_initial=False):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
config:
|
|
|
|
config:
|
|
|
|
url: the base url of the instance
|
|
|
|
url: the base url of the instance
|
|
|
@ -212,10 +219,12 @@ def main(conf_file, hour=-1, no_groups=False, stream="General", no_mentions=Fals
|
|
|
|
return
|
|
|
|
return
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
hour = (time.time() - start_time) // 3600
|
|
|
|
hour = (time.time() - start_time) // 3600
|
|
|
|
if not no_groups:
|
|
|
|
if not no_initial:
|
|
|
|
update_groups(client, group_ids, schedule, hour)
|
|
|
|
if not no_groups:
|
|
|
|
if stream:
|
|
|
|
update_groups(client, group_ids, schedule, hour)
|
|
|
|
post_schedule(client, send_client, start_time, schedule, stream, hour, no_mentions)
|
|
|
|
if stream:
|
|
|
|
|
|
|
|
post_schedule(client, send_client, start_time, schedule, stream, hour, no_mentions)
|
|
|
|
|
|
|
|
no_initial = False
|
|
|
|
next_hour = start_time + 3600 * (hour + 1)
|
|
|
|
next_hour = start_time + 3600 * (hour + 1)
|
|
|
|
remaining = next_hour - time.time()
|
|
|
|
remaining = next_hour - time.time()
|
|
|
|
if remaining > 0:
|
|
|
|
if remaining > 0:
|
|
|
|