-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdispatch_messages.py
34 lines (25 loc) · 1022 Bytes
/
dispatch_messages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from rid_lib.core import RID
from rid_lib.types import SlackUser
from app import orchestrator
from app.dereference import deref
import json, time
messages = []
with open("backfill.json", "r") as f:
data = json.load(f)
for channel_id, channel in data.items():
if channel["observed_messages"] == 0:
continue
messages.extend([RID.from_string(msg_str) for msg_str in channel["messages"]])
messages.sort(key=lambda x: x.ts)
for i, message in enumerate(messages):
message_data = deref(message)
author_user_id = message_data["user"]
for reaction in message_data["reactions"]:
if reaction["name"] == "telescope":
tagger_user_id = reaction["users"][0]
break
author = SlackUser(message.team_id, author_user_id)
tagger = SlackUser(message.team_id, tagger_user_id)
print(i, "/", len(messages), end=" ")
orchestrator.create_request_interaction(message, author, tagger)
time.sleep(1)