seawolf2357 commited on
Commit
9b4ddbd
ยท
verified ยท
1 Parent(s): 1075703

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -86,12 +86,14 @@ class MyClient(discord.Client):
86
 
87
  self.is_processing = True
88
  try:
 
 
89
  if self.is_math_question(message.content):
90
  text_response = await self.handle_math_question(message.content)
91
- await self.send_message_with_latex(message.channel, text_response)
92
  else:
93
  response = await self.generate_response(message)
94
- await self.send_message_with_latex(message.channel, response)
95
  finally:
96
  self.is_processing = False
97
 
@@ -156,18 +158,18 @@ class MyClient(discord.Client):
156
 
157
  async def send_message_with_latex(self, channel, message):
158
  try:
159
- # ํ…์ŠคํŠธ์™€ LaTeX ์ˆ˜์‹ ๋ถ„๋ฆฌ
160
  text_parts = re.split(r'(\$\$.*?\$\$|\$.*?\$)', message, flags=re.DOTALL)
161
 
162
  for part in text_parts:
163
  if part.startswith('$'):
164
- # LaTeX ์ˆ˜์‹ ์ฒ˜๋ฆฌ ๋ฐ ์ด๋ฏธ์ง€๋กœ ์ถœ๋ ฅ
165
  latex_content = part.strip('$')
166
  image_base64 = latex_to_image(latex_content)
167
  image_binary = base64.b64decode(image_base64)
168
  await channel.send(file=discord.File(BytesIO(image_binary), 'equation.png'))
169
  else:
170
- # ํ…์ŠคํŠธ ์ถœ๋ ฅ
171
  if part.strip():
172
  await self.send_long_message(channel, part.strip())
173
 
@@ -185,4 +187,4 @@ class MyClient(discord.Client):
185
 
186
  if __name__ == "__main__":
187
  discord_client = MyClient(intents=intents)
188
- discord_client.run(os.getenv('DISCORD_TOKEN'))
 
86
 
87
  self.is_processing = True
88
  try:
89
+ # ์ƒˆ๋กœ์šด ์Šค๋ ˆ๋“œ ์ƒ์„ฑ
90
+ thread = await message.channel.create_thread(name=f"์งˆ๋ฌธ: {message.author.name}", message=message)
91
  if self.is_math_question(message.content):
92
  text_response = await self.handle_math_question(message.content)
93
+ await self.send_message_with_latex(thread, text_response)
94
  else:
95
  response = await self.generate_response(message)
96
+ await self.send_message_with_latex(thread, response)
97
  finally:
98
  self.is_processing = False
99
 
 
158
 
159
  async def send_message_with_latex(self, channel, message):
160
  try:
161
+ # ํ…์ŠคํŠธ์™€ LaTeX ์ˆ˜์‹ ๋ถ„๋ฆฌ
162
  text_parts = re.split(r'(\$\$.*?\$\$|\$.*?\$)', message, flags=re.DOTALL)
163
 
164
  for part in text_parts:
165
  if part.startswith('$'):
166
+ # LaTeX ์ˆ˜์‹ ์ฒ˜๋ฆฌ ๋ฐ ์ด๋ฏธ์ง€๋กœ ์ถœ๋ ฅ
167
  latex_content = part.strip('$')
168
  image_base64 = latex_to_image(latex_content)
169
  image_binary = base64.b64decode(image_base64)
170
  await channel.send(file=discord.File(BytesIO(image_binary), 'equation.png'))
171
  else:
172
+ # ํ…์ŠคํŠธ ์ถœ๋ ฅ
173
  if part.strip():
174
  await self.send_long_message(channel, part.strip())
175
 
 
187
 
188
  if __name__ == "__main__":
189
  discord_client = MyClient(intents=intents)
190
+ discord_client.run(os.getenv('DISCORD_TOKEN'))