Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -121,23 +121,23 @@ async def on_message(message):
|
|
| 121 |
except SlackApiError as e:
|
| 122 |
print(f"Error posting to Slack: {e.response['error']}")
|
| 123 |
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
|
| 142 |
|
| 143 |
|
|
|
|
| 121 |
except SlackApiError as e:
|
| 122 |
print(f"Error posting to Slack: {e.response['error']}")
|
| 123 |
|
| 124 |
+
def find_slack_thread_ts(thread_id):
|
| 125 |
+
# search for a Slack thread based on Discord thread_id"""
|
| 126 |
+
try:
|
| 127 |
+
response = slack_client.conversations_history(
|
| 128 |
+
channel=SLACK_CHANNEL_ID_TEST,
|
| 129 |
+
limit=1000 # adjustable
|
| 130 |
+
)
|
| 131 |
+
messages = response['messages']
|
| 132 |
+
|
| 133 |
+
for message in messages:
|
| 134 |
+
if f"Discord Thread ID: {thread_id}" in message['text']:
|
| 135 |
+
return message['ts']
|
| 136 |
+
|
| 137 |
+
except SlackApiError as e:
|
| 138 |
+
print(f"Error fetching Slack messages: {e.response['error']}")
|
| 139 |
+
|
| 140 |
+
return None
|
| 141 |
|
| 142 |
|
| 143 |
|