seawolf2357 commited on
Commit
21f9522
β€’
1 Parent(s): 127fdb2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -89,7 +89,7 @@ class MyClient(discord.Client):
89
  transcript = await get_best_available_transcript(video_id)
90
  reply = await generate_reply(comment[0], transcript)
91
  logging.info(f"μƒμ„±λœ λ‹΅λ³€: {reply}")
92
- await send_reply(message, video_id, comment, reply)
93
  old_comments.append(comment)
94
  self.processed_comments.add(comment[1])
95
  self.last_comments[video_id] = old_comments
@@ -99,6 +99,16 @@ class MyClient(discord.Client):
99
  await self.session.close()
100
  await super().close()
101
 
 
 
 
 
 
 
 
 
 
 
102
  def extract_video_id(url):
103
  youtube_regex = (
104
  r'(https?://)?(www\.)?'
@@ -159,17 +169,6 @@ async def generate_reply(comment, transcript):
159
  logging.error(f"Error generating reply: {e}")
160
  return "닡변을 생성할 수 μ—†μŠ΅λ‹ˆλ‹€."
161
 
162
- async def send_reply(message, video_id, comment, reply):
163
- try:
164
- embed = discord.Embed(description=f"**λ‹΅κΈ€**: {reply}")
165
- await message.channel.send(embed=embed)
166
-
167
- webhook_data = {"video_id": video_id, "replies": [{"comment": comment[0], "reply": reply, "comment_id": comment[1]}]}
168
- await send_webhook_data(webhook_data)
169
- self.replied_comments.add(comment[1])
170
- except discord.HTTPException as e:
171
- logging.error(f"Error in reply sending: {e}")
172
-
173
  async def send_webhook_data(data):
174
  async with aiohttp.ClientSession() as session:
175
  data_json = json.dumps(data)
 
89
  transcript = await get_best_available_transcript(video_id)
90
  reply = await generate_reply(comment[0], transcript)
91
  logging.info(f"μƒμ„±λœ λ‹΅λ³€: {reply}")
92
+ await self.send_reply(message, video_id, comment, reply)
93
  old_comments.append(comment)
94
  self.processed_comments.add(comment[1])
95
  self.last_comments[video_id] = old_comments
 
99
  await self.session.close()
100
  await super().close()
101
 
102
+ async def send_reply(self, message, video_id, comment, reply):
103
+ try:
104
+ embed = discord.Embed(description=f"**λ‹΅κΈ€**: {reply}")
105
+ await message.channel.send(embed=embed)
106
+ webhook_data = {"video_id": video_id, "replies": [{"comment": comment[0], "reply": reply, "comment_id": comment[1]}]}
107
+ await send_webhook_data(webhook_data)
108
+ self.replied_comments.add(comment[1])
109
+ except discord.HTTPException as e:
110
+ logging.error(f"Error in reply sending: {e}")
111
+
112
  def extract_video_id(url):
113
  youtube_regex = (
114
  r'(https?://)?(www\.)?'
 
169
  logging.error(f"Error generating reply: {e}")
170
  return "닡변을 생성할 수 μ—†μŠ΅λ‹ˆλ‹€."
171
 
 
 
 
 
 
 
 
 
 
 
 
172
  async def send_webhook_data(data):
173
  async with aiohttp.ClientSession() as session:
174
  data_json = json.dumps(data)