|
@@ -11,6 +11,7 @@ import httpx
|
|
|
import base64
|
|
import base64
|
|
|
import re
|
|
import re
|
|
|
import signal
|
|
import signal
|
|
|
|
|
+import asyncio
|
|
|
import sys
|
|
import sys
|
|
|
|
|
|
|
|
from dotenv import load_dotenv
|
|
from dotenv import load_dotenv
|
|
@@ -252,6 +253,8 @@ class MyDiscordClient(discord.Client):
|
|
|
async def close(self):
|
|
async def close(self):
|
|
|
global openai_client
|
|
global openai_client
|
|
|
|
|
|
|
|
|
|
+ update_status.cancel()
|
|
|
|
|
+
|
|
|
if openai_client is not None:
|
|
if openai_client is not None:
|
|
|
await openai_client.close()
|
|
await openai_client.close()
|
|
|
openai_client = None
|
|
openai_client = None
|
|
@@ -690,14 +693,14 @@ async def before_update_status():
|
|
|
|
|
|
|
|
# Démarrer le bot Discord
|
|
# Démarrer le bot Discord
|
|
|
async def exit_app(signum=None):
|
|
async def exit_app(signum=None):
|
|
|
- globals.logger.debug("Received signal {}".format(signum))
|
|
|
|
|
- globals.logger.info("Closing all tasks...")
|
|
|
|
|
|
|
+ logger.debug("Received signal {}".format(signum))
|
|
|
|
|
+ logger.info("Closing all tasks...")
|
|
|
|
|
|
|
|
# On ferme la connexion à Discord
|
|
# On ferme la connexion à Discord
|
|
|
if client_discord:
|
|
if client_discord:
|
|
|
await client_discord.close()
|
|
await client_discord.close()
|
|
|
|
|
|
|
|
- globals.logger.critical("Script halted.")
|
|
|
|
|
|
|
+ logger.critical("Script halted.")
|
|
|
|
|
|
|
|
def handle_signal(signum, frame):
|
|
def handle_signal(signum, frame):
|
|
|
loop = asyncio.get_event_loop()
|
|
loop = asyncio.get_event_loop()
|
|
@@ -713,4 +716,4 @@ if __name__ == "__main__":
|
|
|
# Démarrer le bot Discord
|
|
# Démarrer le bot Discord
|
|
|
client_discord.run(DISCORD_TOKEN)
|
|
client_discord.run(DISCORD_TOKEN)
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
- globals.logger.error("Encountered exception while running the bot: {}".format(e))
|
|
|
|
|
|
|
+ logger.error("Encountered exception while running the bot: {}".format(e))
|