Spaces:
Paused
Paused
fixes
Browse files
app.py
CHANGED
|
@@ -83,7 +83,7 @@ async def on_message(message):
|
|
| 83 |
print("3")
|
| 84 |
slack_thread_ts = thread_mapping[discord_thread_id]
|
| 85 |
# post to slack only if thread already exists
|
| 86 |
-
post_to_slack_forum_version(SLACK_CHANNEL_ID, message.content,
|
| 87 |
|
| 88 |
|
| 89 |
@bot.event
|
|
@@ -92,31 +92,32 @@ async def on_thread_create(thread):
|
|
| 92 |
if isinstance(thread.parent, discord.ForumChannel) and thread.parent.id == FORUM_CHANNEL_ID:
|
| 93 |
print("4")
|
| 94 |
discord_thread_id = thread.id
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
|
|
|
| 100 |
)
|
| 101 |
print("5")
|
| 102 |
if slack_thread_ts:
|
| 103 |
thread_mapping[discord_thread_id] = slack_thread_ts
|
| 104 |
|
| 105 |
|
| 106 |
-
def post_to_slack_forum_version(channel, text,
|
| 107 |
print("6")
|
| 108 |
try:
|
| 109 |
response = slack_client.chat_postMessage(
|
| 110 |
channel=channel,
|
| 111 |
-
text=
|
| 112 |
thread_ts=thread_ts
|
| 113 |
)
|
| 114 |
return response['ts'] # Return the Slack message timestamp (thread ID)
|
| 115 |
except SlackApiError as e:
|
| 116 |
print(f"Error posting to Slack: {e.response['error']}")
|
| 117 |
return None
|
| 118 |
-
#----------------------------------------------------------------------------------------------
|
| 119 |
|
|
|
|
| 120 |
|
| 121 |
|
| 122 |
async def post_to_slack(author, content, channel, url, slack_mention, trigger):
|
|
|
|
| 83 |
print("3")
|
| 84 |
slack_thread_ts = thread_mapping[discord_thread_id]
|
| 85 |
# post to slack only if thread already exists
|
| 86 |
+
post_to_slack_forum_version(SLACK_CHANNEL_ID, message.content, message.author, thread_ts=slack_thread_ts)
|
| 87 |
|
| 88 |
|
| 89 |
@bot.event
|
|
|
|
| 92 |
if isinstance(thread.parent, discord.ForumChannel) and thread.parent.id == FORUM_CHANNEL_ID:
|
| 93 |
print("4")
|
| 94 |
discord_thread_id = thread.id
|
| 95 |
+
text=f"New forum thread started in #ask-for-help by {thread.owner}: *{thread.name}*\n{thread.jump_url}"
|
| 96 |
+
|
| 97 |
+
slack_thread_ts = slack_client.chat_postMessage(
|
| 98 |
+
channel=FORUM_CHANNEL_ID,
|
| 99 |
+
text=text,
|
| 100 |
+
thread_ts=thread_ts
|
| 101 |
)
|
| 102 |
print("5")
|
| 103 |
if slack_thread_ts:
|
| 104 |
thread_mapping[discord_thread_id] = slack_thread_ts
|
| 105 |
|
| 106 |
|
| 107 |
+
def post_to_slack_forum_version(channel, text, author, thread_ts=None):
|
| 108 |
print("6")
|
| 109 |
try:
|
| 110 |
response = slack_client.chat_postMessage(
|
| 111 |
channel=channel,
|
| 112 |
+
text=author + ": " + text,
|
| 113 |
thread_ts=thread_ts
|
| 114 |
)
|
| 115 |
return response['ts'] # Return the Slack message timestamp (thread ID)
|
| 116 |
except SlackApiError as e:
|
| 117 |
print(f"Error posting to Slack: {e.response['error']}")
|
| 118 |
return None
|
|
|
|
| 119 |
|
| 120 |
+
#----------------------------------------------------------------------------------------------
|
| 121 |
|
| 122 |
|
| 123 |
async def post_to_slack(author, content, channel, url, slack_mention, trigger):
|