schedulebot: List all currently active people by role (except shift sup)

pull/370/head
Mike Lang 1 year ago
parent b65203ce0e
commit f63e68f609

@ -85,6 +85,7 @@ def hour_to_shift(hour, start_time):
def post_schedule(client, send_client, start_time, schedule, stream, hour, no_mentions, last, omega): def post_schedule(client, send_client, start_time, schedule, stream, hour, no_mentions, last, omega):
going_offline = [] going_offline = []
coming_online = [] coming_online = []
online_by_role = {}
display_names = {} display_names = {}
supervisor = None supervisor = None
found_any = False found_any = False
@ -99,6 +100,10 @@ def post_schedule(client, send_client, start_time, schedule, stream, hour, no_me
supervisor = user_id supervisor = 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)
elif now != "":
online_by_role.setdefault(now, []).append(user_id)
if user_id not in display_names:
display_names[user_id] = gevent.spawn(get_display_name, client, user_id)
if prev != now: if prev != now:
if prev != "": if prev != "":
going_offline.append((prev, user_id)) going_offline.append((prev, user_id))
@ -164,6 +169,19 @@ def post_schedule(client, send_client, start_time, schedule, stream, hour, no_me
f"- {render_name(user_id)} - {role}" f"- {render_name(user_id)} - {role}"
for role, user_id in going_offline for role, user_id in going_offline
] ]
if online_by_role:
lines += [
"",
"---",
]
for role, user_ids in sorted(online_by_role.items()):
user_ids.sort()
lines += [
"Current {}:".format(role),
] + [
f"- {render_name(user_id, False)}"
for user_id in user_ids
]
lines += [ lines += [
"", "",
"---", "---",

Loading…
Cancel
Save