Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -113,7 +113,7 @@ async def on_message(message):
|
|
| 113 |
if discord_thread_id in thread_mapping:
|
| 114 |
slack_thread_ts = thread_mapping[discord_thread_id]
|
| 115 |
# post to slack only if thread already exists
|
| 116 |
-
post_to_slack_forum_version(message,
|
| 117 |
|
| 118 |
await bot.process_commands(message)
|
| 119 |
|
|
@@ -191,8 +191,6 @@ def send_daily_pings():
|
|
| 191 |
print("sending daily pings...")
|
| 192 |
# combine into one message
|
| 193 |
combined_message = '\n'.join(f"{ping['mention']} (for the keyword -> '{ping['trigger']}')\nFrom {ping['author']} in channel #{ping['channel']}: {ping['content']}\n{ping['url']}" for ping in daily_pings)
|
| 194 |
-
#await post_to_slack(None, combined_message, SLACK_CHANNEL_ID_TEST, None, None, None)
|
| 195 |
-
|
| 196 |
|
| 197 |
response = slack_client.chat_postMessage(
|
| 198 |
channel=SLACK_CHANNEL_ID,
|
|
@@ -201,21 +199,10 @@ def send_daily_pings():
|
|
| 201 |
unfurl_media=False
|
| 202 |
)
|
| 203 |
|
| 204 |
-
|
| 205 |
daily_pings = [] # reset after posting
|
| 206 |
|
| 207 |
# pings -------------------------------------------------------------------------------------------
|
| 208 |
|
| 209 |
-
async def post_to_slack(author, content, channel, url, slack_mention, trigger):
|
| 210 |
-
try:
|
| 211 |
-
response = slack_client.chat_postMessage(
|
| 212 |
-
channel=SLACK_CHANNEL_ID,
|
| 213 |
-
text=f"{slack_mention} (for the keyword -> '{trigger}')\nFrom {author} in channel #{channel}: {content}\n{url}"
|
| 214 |
-
)
|
| 215 |
-
except SlackApiError as e:
|
| 216 |
-
print(f"Error posting to Slack: {e.response['error']}")
|
| 217 |
-
|
| 218 |
-
|
| 219 |
executor = ThreadPoolExecutor(max_workers=1)
|
| 220 |
scheduler = BackgroundScheduler(executors={'default': executor})
|
| 221 |
scheduler.add_job(send_daily_pings, trigger='interval', days=1)
|
|
|
|
| 113 |
if discord_thread_id in thread_mapping:
|
| 114 |
slack_thread_ts = thread_mapping[discord_thread_id]
|
| 115 |
# post to slack only if thread already exists
|
| 116 |
+
post_to_slack_forum_version(message, SLACK_CHANNEL_ID_TEST, message.content, message.author, thread_ts=slack_thread_ts)
|
| 117 |
|
| 118 |
await bot.process_commands(message)
|
| 119 |
|
|
|
|
| 191 |
print("sending daily pings...")
|
| 192 |
# combine into one message
|
| 193 |
combined_message = '\n'.join(f"{ping['mention']} (for the keyword -> '{ping['trigger']}')\nFrom {ping['author']} in channel #{ping['channel']}: {ping['content']}\n{ping['url']}" for ping in daily_pings)
|
|
|
|
|
|
|
| 194 |
|
| 195 |
response = slack_client.chat_postMessage(
|
| 196 |
channel=SLACK_CHANNEL_ID,
|
|
|
|
| 199 |
unfurl_media=False
|
| 200 |
)
|
| 201 |
|
|
|
|
| 202 |
daily_pings = [] # reset after posting
|
| 203 |
|
| 204 |
# pings -------------------------------------------------------------------------------------------
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
executor = ThreadPoolExecutor(max_workers=1)
|
| 207 |
scheduler = BackgroundScheduler(executors={'default': executor})
|
| 208 |
scheduler.add_job(send_daily_pings, trigger='interval', days=1)
|