seawolf2357
commited on
Commit
โข
4e04dd7
1
Parent(s):
1423a35
Update app.py
Browse files
app.py
CHANGED
@@ -192,26 +192,44 @@ async def send_webhook_data(session, chunk_data, chunk_number):
|
|
192 |
|
193 |
return False # ์ฌ์๋ ํ์ ์ด๊ณผ ์ ์คํจ๋ก ๊ฐ์ฃผ
|
194 |
|
|
|
195 |
async def create_thread_and_send_replies(message, video_id, comments, replies, session):
|
196 |
thread = await message.channel.create_thread(name=f"{message.author.name}์ ๋๊ธ ๋ต๊ธ", message=message)
|
197 |
-
|
198 |
-
|
199 |
for (comment, comment_id), reply in zip(comments, replies):
|
200 |
embed = discord.Embed(description=f"**๋๊ธ**: {comment}\n**๋ต๊ธ**: {reply}")
|
201 |
await thread.send(embed=embed)
|
202 |
|
203 |
-
# ์นํ
|
204 |
-
webhook_data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
|
206 |
-
|
207 |
-
chunk_size = 1 # ์ ์กํ ๋ฐ์ดํฐ์ ๊ฐ์๋ฅผ 1๋ก ์ค์ ํ์ฌ ๊ฐ ๋ฐ์ดํฐ๋ฅผ ๋ณ๋๋ก ์ ์ก
|
208 |
-
for i in range(0, len(webhook_data["replies"]), chunk_size):
|
209 |
-
chunk = webhook_data["replies"][i:i+chunk_size]
|
210 |
-
chunk_data = {"video_id": video_id, "replies": chunk}
|
211 |
|
212 |
-
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
|
216 |
if __name__ == "__main__":
|
217 |
discord_client = MyClient(intents=intents)
|
|
|
192 |
|
193 |
return False # ์ฌ์๋ ํ์ ์ด๊ณผ ์ ์คํจ๋ก ๊ฐ์ฃผ
|
194 |
|
195 |
+
|
196 |
async def create_thread_and_send_replies(message, video_id, comments, replies, session):
|
197 |
thread = await message.channel.create_thread(name=f"{message.author.name}์ ๋๊ธ ๋ต๊ธ", message=message)
|
198 |
+
|
|
|
199 |
for (comment, comment_id), reply in zip(comments, replies):
|
200 |
embed = discord.Embed(description=f"**๋๊ธ**: {comment}\n**๋ต๊ธ**: {reply}")
|
201 |
await thread.send(embed=embed)
|
202 |
|
203 |
+
# ์นํ
๋ฐ์ดํฐ๋ฅผ ๊ฐ๋ณ์ ์ผ๋ก ์ ์ก
|
204 |
+
webhook_data = {
|
205 |
+
"video_id": video_id,
|
206 |
+
"replies": [{"comment": comment, "reply": reply, "comment_id": comment_id}]
|
207 |
+
}
|
208 |
+
|
209 |
+
# ์นํ
๋ฐ์ดํฐ ์ ์ก
|
210 |
+
success = await send_webhook_data(session, webhook_data, 1) # ์ฒญํฌ ๋ฒํธ๋ ์ฌ๊ธฐ์๋ ์ฌ์ฉํ์ง ์๊ณ , 1์ ๊ณ ์ ๊ฐ์ผ๋ก ์ฌ์ฉ
|
211 |
+
if not success:
|
212 |
+
logging.error("์นํ
์ ํตํ ๋ฐ์ดํฐ ์ ์ก ์คํจ")
|
213 |
|
214 |
+
await asyncio.sleep(1) # ๋ค์ ๋ต๊ธ ์ ์ก ์ ์ ์ ์ ๋๊ธฐ (ํ์ํ ๊ฒฝ์ฐ ๋๊ธฐ ์๊ฐ ์กฐ์ )
|
|
|
|
|
|
|
|
|
215 |
|
216 |
+
|
217 |
+
#async def create_thread_and_send_replies(message, video_id, comments, replies, session):
|
218 |
+
# thread = await message.channel.create_thread(name=f"{message.author.name}์ ๋๊ธ ๋ต๊ธ", message=message)
|
219 |
+
# webhook_data = {"video_id": video_id, "replies": []}
|
220 |
+
# for (comment, comment_id), reply in zip(comments, replies):
|
221 |
+
# embed = discord.Embed(description=f"**๋๊ธ**: {comment}\n**๋ต๊ธ**: {reply}")
|
222 |
+
# await thread.send(embed=embed)
|
223 |
+
# ์นํ
๋ฐ์ดํฐ ์ค๋น (comment id ํฌํจ)
|
224 |
+
# webhook_data["replies"].append({"comment": comment, "reply": reply, "comment_id": comment_id})
|
225 |
+
# ๋ฐ์ดํฐ๋ฅผ ์ฌ๋ฌ ๋ฒ ๋๋์ด ์ ์ก
|
226 |
+
# chunk_size = 1 # ์ ์กํ ๋ฐ์ดํฐ์ ๊ฐ์๋ฅผ 1๋ก ์ค์ ํ์ฌ ๊ฐ ๋ฐ์ดํฐ๋ฅผ ๋ณ๋๋ก ์ ์ก
|
227 |
+
# for i in range(0, len(webhook_data["replies"]), chunk_size):
|
228 |
+
# chunk = webhook_data["replies"][i:i+chunk_size]
|
229 |
+
# chunk_data = {"video_id": video_id, "replies": chunk}
|
230 |
+
# success = await send_webhook_data(session, chunk_data, i // chunk_size + 1)
|
231 |
+
# if not success:
|
232 |
+
# logging.error(f"๋ฐ์ดํฐ ์ ์ก ์คํจ: {i // chunk_size + 1} ๋ฒ์งธ ์ฒญํฌ")
|
233 |
|
234 |
if __name__ == "__main__":
|
235 |
discord_client = MyClient(intents=intents)
|