Spaces:
seawolf2357
/
Running on CPU Upgrade

seawolf2357 commited on
Commit
cf85588
โ€ข
1 Parent(s): 669bbdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -157,27 +157,28 @@ class MyClient(discord.Client):
157
  return f"{user_mention}, {full_response}"
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
  # ํ…์ŠคํŠธ ๋จผ์ € ์ถœ๋ ฅ
165
- for part in text_parts:
166
- if not part.startswith('$'):
167
- if part.strip():
168
- await self.send_long_message(channel, part.strip())
169
 
170
  # LaTeX ์ˆ˜์‹ ์ฒ˜๋ฆฌ ๋ฐ ์ด๋ฏธ์ง€๋กœ ์ถœ๋ ฅ
171
- for part in text_parts:
172
- if part.startswith('$'):
173
- latex_content = part.strip('$')
174
- image_base64 = latex_to_image(latex_content)
175
- image_binary = base64.b64decode(image_base64)
176
- await channel.send(file=discord.File(BytesIO(image_binary), 'equation.png'))
 
 
 
 
177
 
178
- except Exception as e:
179
- logging.error(f"Error in send_message_with_latex: {str(e)}")
180
- await channel.send("An error occurred while processing the message.")
181
 
182
 
183
  async def send_long_message(self, channel, message):
 
157
  return f"{user_mention}, {full_response}"
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
  # ํ…์ŠคํŠธ ๋จผ์ € ์ถœ๋ ฅ
165
+ for part in text_parts:
166
+ if not part.startswith('$'):
167
+ if part.strip():
168
+ await self.send_long_message(channel, part.strip())
169
 
170
  # LaTeX ์ˆ˜์‹ ์ฒ˜๋ฆฌ ๋ฐ ์ด๋ฏธ์ง€๋กœ ์ถœ๋ ฅ
171
+ for part in text_parts:
172
+ if part.startswith('$'):
173
+ latex_content = part.strip('$')
174
+ image_base64 = latex_to_image(latex_content)
175
+ image_binary = base64.b64decode(image_base64)
176
+ await channel.send(file=discord.File(BytesIO(image_binary), 'equation.png'))
177
+
178
+ except Exception as e:
179
+ logging.error(f"Error in send_message_with_latex: {str(e)}")
180
+ await channel.send("An error occurred while processing the message.")
181
 
 
 
 
182
 
183
 
184
  async def send_long_message(self, channel, message):