test
Browse files
app.py
CHANGED
@@ -92,12 +92,10 @@ 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 |
-
text=text,
|
100 |
-
thread_ts=None
|
101 |
)
|
102 |
print("5")
|
103 |
if slack_thread_ts:
|
@@ -106,10 +104,11 @@ async def on_thread_create(thread):
|
|
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=
|
113 |
thread_ts=thread_ts
|
114 |
)
|
115 |
return response['ts'] # Return the Slack message timestamp (thread ID)
|
@@ -117,6 +116,20 @@ def post_to_slack_forum_version(channel, text, author, thread_ts=None):
|
|
117 |
print(f"Error posting to Slack: {e.response['error']}")
|
118 |
return None
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
#----------------------------------------------------------------------------------------------
|
121 |
|
122 |
|
|
|
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_create_thread(
|
96 |
+
SLACK_CHANNEL_ID,
|
97 |
+
f"New forum thread started in #ask-for-help by {thread.owner}: *{thread.name}*\n"
|
98 |
+
f"{thread.jump_url}"
|
|
|
|
|
99 |
)
|
100 |
print("5")
|
101 |
if slack_thread_ts:
|
|
|
104 |
|
105 |
def post_to_slack_forum_version(channel, text, author, thread_ts=None):
|
106 |
print("6")
|
107 |
+
text = author + ": " + text
|
108 |
try:
|
109 |
response = slack_client.chat_postMessage(
|
110 |
channel=channel,
|
111 |
+
text=text,
|
112 |
thread_ts=thread_ts
|
113 |
)
|
114 |
return response['ts'] # Return the Slack message timestamp (thread ID)
|
|
|
116 |
print(f"Error posting to Slack: {e.response['error']}")
|
117 |
return None
|
118 |
|
119 |
+
|
120 |
+
def post_to_slack_create_thread(channel, text, thread_ts=None):
|
121 |
+
print("6")
|
122 |
+
try:
|
123 |
+
response = slack_client.chat_postMessage(
|
124 |
+
channel=channel,
|
125 |
+
text=text,
|
126 |
+
thread_ts=thread_ts
|
127 |
+
)
|
128 |
+
return response['ts'] # Return the Slack message timestamp (thread ID)
|
129 |
+
except SlackApiError as e:
|
130 |
+
print(f"Error posting to Slack: {e.response['error']}")
|
131 |
+
return None
|
132 |
+
|
133 |
#----------------------------------------------------------------------------------------------
|
134 |
|
135 |
|