Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -179,10 +179,7 @@ class MyClient(discord.Client):
|
|
| 179 |
except Exception as e:
|
| 180 |
logging.error(f"Error in send_message_with_latex: {str(e)}")
|
| 181 |
await channel.send("An error occurred while processing the message.")
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
async def send_long_message(self, channel, message):
|
| 187 |
if len(message) <= 2000:
|
| 188 |
await channel.send(message)
|
|
@@ -191,6 +188,19 @@ class MyClient(discord.Client):
|
|
| 191 |
for part in parts:
|
| 192 |
await channel.send(part)
|
| 193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
if __name__ == "__main__":
|
| 195 |
discord_client = MyClient(intents=intents)
|
| 196 |
discord_client.run(os.getenv('DISCORD_TOKEN'))
|
|
|
|
| 179 |
except Exception as e:
|
| 180 |
logging.error(f"Error in send_message_with_latex: {str(e)}")
|
| 181 |
await channel.send("An error occurred while processing the message.")
|
| 182 |
+
|
|
|
|
|
|
|
|
|
|
| 183 |
async def send_long_message(self, channel, message):
|
| 184 |
if len(message) <= 2000:
|
| 185 |
await channel.send(message)
|
|
|
|
| 188 |
for part in parts:
|
| 189 |
await channel.send(part)
|
| 190 |
|
| 191 |
+
|
| 192 |
+
async def retry_request(self, func, retries=5, delay=2):
|
| 193 |
+
for i in range(retries):
|
| 194 |
+
try:
|
| 195 |
+
return await func()
|
| 196 |
+
except HTTPError as e:
|
| 197 |
+
if e.response.status_code == 503 and i < retries - 1:
|
| 198 |
+
logging.warning(f"503 error encountered. Retrying in {delay} seconds...")
|
| 199 |
+
await asyncio.sleep(delay)
|
| 200 |
+
else:
|
| 201 |
+
raise
|
| 202 |
+
|
| 203 |
+
|
| 204 |
if __name__ == "__main__":
|
| 205 |
discord_client = MyClient(intents=intents)
|
| 206 |
discord_client.run(os.getenv('DISCORD_TOKEN'))
|