seawolf2357
commited on
Commit
โข
c0cea59
1
Parent(s):
b63eee6
Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,9 @@ SPECIFIC_CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID"))
|
|
37 |
# ์นํ
URL ์ค์
|
38 |
WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY1MDYzMjA0MzA1MjY4NTUzMDUxMzUi_pc"
|
39 |
|
|
|
|
|
|
|
40 |
class MyClient(discord.Client):
|
41 |
def __init__(self, *args, **kwargs):
|
42 |
super().__init__(*args, **kwargs)
|
@@ -169,12 +172,17 @@ async def create_thread_and_send_replies(message, video_id, comments, replies):
|
|
169 |
chunk = webhook_data["replies"][i:i+chunk_size]
|
170 |
chunk_data = {"video_id": video_id, "replies": chunk}
|
171 |
|
172 |
-
|
173 |
-
async with
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
if __name__ == "__main__":
|
180 |
discord_client = MyClient(intents=intents)
|
|
|
37 |
# ์นํ
URL ์ค์
|
38 |
WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY1MDYzMjA0MzA1MjY4NTUzMDUxMzUi_pc"
|
39 |
|
40 |
+
# ์ ์ก ์คํจ ์ ์ฌ์๋ ํ์
|
41 |
+
MAX_RETRIES = 3
|
42 |
+
|
43 |
class MyClient(discord.Client):
|
44 |
def __init__(self, *args, **kwargs):
|
45 |
super().__init__(*args, **kwargs)
|
|
|
172 |
chunk = webhook_data["replies"][i:i+chunk_size]
|
173 |
chunk_data = {"video_id": video_id, "replies": chunk}
|
174 |
|
175 |
+
for attempt in range(MAX_RETRIES):
|
176 |
+
async with aiohttp.ClientSession() as session:
|
177 |
+
try:
|
178 |
+
async with session.post(WEBHOOK_URL, json=chunk_data) as resp:
|
179 |
+
if resp.status == 200:
|
180 |
+
logging.info(f"์นํ
์ผ๋ก ๋ฐ์ดํฐ ์ ์ก ์ฑ๊ณต: {i // chunk_size + 1} ๋ฒ์งธ ์๋")
|
181 |
+
break # ์ฑ๊ณต ์ ๋ฃจํ ํ์ถ
|
182 |
+
else:
|
183 |
+
logging.error(f"์นํ
์ผ๋ก ๋ฐ์ดํฐ ์ ์ก ์คํจ: {resp.status}, {i // chunk_size + 1} ๋ฒ์งธ ์๋")
|
184 |
+
except aiohttp.ClientError as e:
|
185 |
+
logging.error(f"์นํ
์ ์ก ์ค ์ค๋ฅ ๋ฐ์: {e}, {i // chunk_size + 1} ๋ฒ์งธ ์๋")
|
186 |
|
187 |
if __name__ == "__main__":
|
188 |
discord_client = MyClient(intents=intents)
|