seawolf2357 commited on
Commit
b63eee6
·
verified ·
1 Parent(s): bc99da9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -163,13 +163,18 @@ async def create_thread_and_send_replies(message, video_id, comments, replies):
163
  # 웹훅 데이터 준비 (comment id 포함)
164
  webhook_data["replies"].append({"comment": comment, "reply": reply, "comment_id": comment_id})
165
 
166
- # 웹훅으로 데이터 전송
167
- async with aiohttp.ClientSession() as session:
168
- async with session.post(WEBHOOK_URL, json=webhook_data) as resp:
169
- if resp.status == 200:
170
- logging.info("웹훅으로 데이터 전송 성공")
171
- else:
172
- logging.error(f"웹훅으로 데이터 전송 실패: {resp.status}")
 
 
 
 
 
173
 
174
  if __name__ == "__main__":
175
  discord_client = MyClient(intents=intents)
 
163
  # 웹훅 데이터 준비 (comment id 포함)
164
  webhook_data["replies"].append({"comment": comment, "reply": reply, "comment_id": comment_id})
165
 
166
+ # 데이터를 여러 번 나누어 전송
167
+ chunk_size = 5 # 전송할 데이터의 개수
168
+ for i in range(0, len(webhook_data["replies"]), chunk_size):
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)