Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
testing adding/removing tags
Browse files
app.py
CHANGED
|
@@ -178,12 +178,23 @@ SOLVED_TAG_IDS = {1026743978026094664, 1025179659215847575, 1263095032328753174,
|
|
| 178 |
@bot.event
|
| 179 |
async def on_thread_update(before, after):
|
| 180 |
if isinstance(after.parent, discord.ForumChannel) and after.parent.id in {ASK_FOR_HELP_CHANNEL_ID, GRADIO_CHANNEL_ID, ARGILLA_HELP_CHANNEL_ID, DATA_DISCUSSIONS_CHANNEL_ID}:
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
react_to_slack_message(slack_thread_ts, 'white_check_mark')
|
| 186 |
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
def react_to_slack_message(thread_ts, emoji):
|
| 189 |
try:
|
|
@@ -195,6 +206,17 @@ def react_to_slack_message(thread_ts, emoji):
|
|
| 195 |
except SlackApiError as e:
|
| 196 |
print(f"Error reacting to Slack message: {e.response['error']}")
|
| 197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
#----------------------------------------------------------------------------------------------
|
| 199 |
|
| 200 |
def send_daily_pings():
|
|
|
|
| 178 |
@bot.event
|
| 179 |
async def on_thread_update(before, after):
|
| 180 |
if isinstance(after.parent, discord.ForumChannel) and after.parent.id in {ASK_FOR_HELP_CHANNEL_ID, GRADIO_CHANNEL_ID, ARGILLA_HELP_CHANNEL_ID, DATA_DISCUSSIONS_CHANNEL_ID}:
|
| 181 |
+
|
| 182 |
+
before_tag_ids = {tag.id for tag in before.applied_tags}
|
| 183 |
+
after_tag_ids = {tag.id for tag in after.applied_tags}
|
| 184 |
+
|
| 185 |
+
added_tags = after_tag_ids - before_tag_ids
|
| 186 |
+
removed_tags = before_tag_ids - after_tag_ids
|
| 187 |
+
|
| 188 |
+
discord_thread_id = after.id
|
| 189 |
+
if discord_thread_id in thread_mapping:
|
| 190 |
+
slack_thread_ts = thread_mapping[discord_thread_id]
|
| 191 |
+
|
| 192 |
+
if any(tag_id in SOLVED_TAG_IDS for tag_id in added_tags):
|
| 193 |
react_to_slack_message(slack_thread_ts, 'white_check_mark')
|
| 194 |
|
| 195 |
+
if any(tag_id in SOLVED_TAG_IDS for tag_id in removed_tags):
|
| 196 |
+
unreact_to_slack_message(slack_thread_ts, 'white_check_mark')
|
| 197 |
+
|
| 198 |
|
| 199 |
def react_to_slack_message(thread_ts, emoji):
|
| 200 |
try:
|
|
|
|
| 206 |
except SlackApiError as e:
|
| 207 |
print(f"Error reacting to Slack message: {e.response['error']}")
|
| 208 |
|
| 209 |
+
|
| 210 |
+
def unreact_to_slack_message(thread_ts, emoji):
|
| 211 |
+
try:
|
| 212 |
+
response = slack_client.reactions_remove(
|
| 213 |
+
channel=SLACK_CHANNEL_ID,
|
| 214 |
+
name=emoji,
|
| 215 |
+
timestamp=thread_ts
|
| 216 |
+
)
|
| 217 |
+
except SlackApiError as e:
|
| 218 |
+
print(f"Error removing reaction from Slack message: {e.response['error']}")
|
| 219 |
+
|
| 220 |
#----------------------------------------------------------------------------------------------
|
| 221 |
|
| 222 |
def send_daily_pings():
|