Spaces:
Paused
Paused
debug
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ SLACK_BOT_TOKEN = os.getenv('BOT_USER_OAUTH_TOKEN_HF')
|
|
| 11 |
|
| 12 |
# real = os.getenv('SLACK_CHANNEL_ID_HF')
|
| 13 |
# test = 'C07B4KNU5BQ'
|
| 14 |
-
SLACK_CHANNEL_ID =
|
| 15 |
|
| 16 |
|
| 17 |
TRIGGERS = {
|
|
@@ -74,11 +74,13 @@ async def on_message(message):
|
|
| 74 |
|
| 75 |
# Check if the message is in a thread
|
| 76 |
if isinstance(message.channel, discord.Thread):
|
|
|
|
| 77 |
discord_thread_id = message.channel.id
|
| 78 |
-
|
| 79 |
# Check if there's an existing Slack thread for this Discord thread
|
| 80 |
# (the only Slack threads created should be for forum channel threads, not just any thread)
|
| 81 |
if discord_thread_id in thread_mapping:
|
|
|
|
| 82 |
slack_thread_ts = thread_mapping[discord_thread_id]
|
| 83 |
# post to slack only if thread already exists
|
| 84 |
post_to_slack_forum_version(SLACK_CHANNEL_ID, message.content, thread_ts=slack_thread_ts)
|
|
@@ -88,6 +90,7 @@ async def on_message(message):
|
|
| 88 |
async def on_thread_create(thread):
|
| 89 |
# (discord) must be the child thread of the CORRECT forum channel(s) (not just any thread, or any forum channel)
|
| 90 |
if isinstance(thread.parent, discord.ForumChannel) and thread.parent.id == FORUM_CHANNEL_ID:
|
|
|
|
| 91 |
discord_thread_id = thread.id
|
| 92 |
slack_thread_ts = post_to_slack_forum_version(
|
| 93 |
SLACK_CHANNEL_ID,
|
|
@@ -95,11 +98,13 @@ async def on_thread_create(thread):
|
|
| 95 |
f"{thread.jump_url}",
|
| 96 |
thread.owner
|
| 97 |
)
|
|
|
|
| 98 |
if slack_thread_ts:
|
| 99 |
thread_mapping[discord_thread_id] = slack_thread_ts
|
| 100 |
|
| 101 |
|
| 102 |
def post_to_slack_forum_version(channel, text, thread_owner, thread_ts=None):
|
|
|
|
| 103 |
try:
|
| 104 |
response = slack_client.chat_postMessage(
|
| 105 |
channel=channel,
|
|
|
|
| 11 |
|
| 12 |
# real = os.getenv('SLACK_CHANNEL_ID_HF')
|
| 13 |
# test = 'C07B4KNU5BQ'
|
| 14 |
+
SLACK_CHANNEL_ID = 'C07B4KNU5BQ'
|
| 15 |
|
| 16 |
|
| 17 |
TRIGGERS = {
|
|
|
|
| 74 |
|
| 75 |
# Check if the message is in a thread
|
| 76 |
if isinstance(message.channel, discord.Thread):
|
| 77 |
+
print("1")
|
| 78 |
discord_thread_id = message.channel.id
|
| 79 |
+
print("2")
|
| 80 |
# Check if there's an existing Slack thread for this Discord thread
|
| 81 |
# (the only Slack threads created should be for forum channel threads, not just any thread)
|
| 82 |
if discord_thread_id in thread_mapping:
|
| 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, thread_ts=slack_thread_ts)
|
|
|
|
| 90 |
async def on_thread_create(thread):
|
| 91 |
# (discord) must be the child thread of the CORRECT forum channel(s) (not just any thread, or any forum channel)
|
| 92 |
if isinstance(thread.parent, discord.ForumChannel) and thread.parent.id == FORUM_CHANNEL_ID:
|
| 93 |
+
print("4")
|
| 94 |
discord_thread_id = thread.id
|
| 95 |
slack_thread_ts = post_to_slack_forum_version(
|
| 96 |
SLACK_CHANNEL_ID,
|
|
|
|
| 98 |
f"{thread.jump_url}",
|
| 99 |
thread.owner
|
| 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, thread_owner, thread_ts=None):
|
| 107 |
+
print("6")
|
| 108 |
try:
|
| 109 |
response = slack_client.chat_postMessage(
|
| 110 |
channel=channel,
|