|
|
@@ -0,0 +1,31 @@
|
|
|
+from __future__ import annotations
|
|
|
+
|
|
|
+import datetime
|
|
|
+import sys
|
|
|
+import typing
|
|
|
+
|
|
|
+import cache
|
|
|
+
|
|
|
+def main() -> None:
|
|
|
+ planets = ['Avalon', 'Berthier', 'Boucher', 'Nova Honshu', 'Promitor']
|
|
|
+ joined: dict[str, int] = {}
|
|
|
+ for planet in planets:
|
|
|
+ print('querying', planet, 'chat...', file=sys.stderr)
|
|
|
+ messages: typing.Sequence[Message] = cache.get(f'https://api.fnar.net/chat/messages?channel_names={planet} Global Site Owners')
|
|
|
+ for message in messages:
|
|
|
+ if message['Type'] == 'JOINED':
|
|
|
+ old_join = joined.get(message['SenderUserName'])
|
|
|
+ if old_join is None or old_join > message['MessageTimestamp']:
|
|
|
+ joined[message['SenderUserName']] = message['MessageTimestamp']
|
|
|
+
|
|
|
+ for user_id, join_ts in sorted(joined.items(), key=lambda i: i[1]):
|
|
|
+ join_str = datetime.datetime.fromtimestamp(join_ts/1000, tz=datetime.UTC).strftime('%Y-%m-%d %H:%M:%S')
|
|
|
+ print(user_id, join_str, sep='\t')
|
|
|
+
|
|
|
+class Message(typing.TypedDict):
|
|
|
+ Type: typing.Literal['JOINED', 'LEFT', 'MESSAGE']
|
|
|
+ SenderUserName: str
|
|
|
+ MessageTimestamp: int
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ main()
|