about summary refs log tree commit diff stats
path: root/browse-slack
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-09 19:57:53 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-11-09 19:57:53 -0800
commitb10bbc3a51801345c68fdfbe0eff1700451c7be5 (patch)
tree570e75fa068ec0b4706ac62cbfa369ea0f16c966 /browse-slack
parent1f9b16680f1190a7be4098d61ed2ef74b1906b79 (diff)
downloadmu-b10bbc3a51801345c68fdfbe0eff1700451c7be5.tar.gz
slack: one more corner case during import
Diffstat (limited to 'browse-slack')
-rw-r--r--browse-slack/convert_slack.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/browse-slack/convert_slack.py b/browse-slack/convert_slack.py
index e6ee6a56..e365dc3b 100644
--- a/browse-slack/convert_slack.py
+++ b/browse-slack/convert_slack.py
@@ -32,6 +32,7 @@ import json
 from os import listdir
 from os.path import isfile, join, basename, splitext
 from urllib.parse import urlparse
+import traceback
 
 def look_up_ppm_image(url):
     file_root = splitext(basename(urlparse(url).path))[0]
@@ -49,6 +50,11 @@ with open('users.json') as f:
         user_idx[user['id']] = idx
 
 def by(item):
+    if 'subtype' in item and item['subtype'] == 'bot_message' and 'username' in item:
+        federated_user = item['username']
+        if federated_user not in user_idx:
+            user_idx[federated_user] = len(user_idx)
+        return user_idx[federated_user]
     return user_idx[item['user']]
 
 item_idx = {}
@@ -74,4 +80,5 @@ for item in sorted(items, key=lambda item: item['ts']):
         item_idx[item['ts']] = idx
         idx += 1  # only increment when actually used and no exception raised
     except KeyError:
+        traceback.print_exc(file=stderr)
         stderr.write(repr(item)+'\n')