seawolf2357 commited on
Commit
c0cea59
โ€ข
1 Parent(s): b63eee6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
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
- async with aiohttp.ClientSession() as session:
173
- async with session.post(WEBHOOK_URL, json=chunk_data) as resp:
174
- if resp.status == 200:
175
- logging.info(f"์›นํ›…์œผ๋กœ ๋ฐ์ดํ„ฐ ์ „์†ก ์„ฑ๊ณต: {i // chunk_size + 1} ๋ฒˆ์งธ")
176
- else:
177
- logging.error(f"์›นํ›…์œผ๋กœ ๋ฐ์ดํ„ฐ ์ „์†ก ์‹คํŒจ: {resp.status}, {i // chunk_size + 1} ๋ฒˆ์งธ")
 
 
 
 
 
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)