|
|
@@ -1,6 +1,12 @@
|
|
|
import os
|
|
|
import logging
|
|
|
+
|
|
|
+import discord.utils
|
|
|
+
|
|
|
+discord.utils.setup_logging = lambda *args, **kwargs: None
|
|
|
+
|
|
|
import discord
|
|
|
+
|
|
|
import json
|
|
|
import urllib3
|
|
|
import base64
|
|
|
@@ -45,7 +51,12 @@ WHISPER_WS_URL = os.getenv("WHISPER_WS_URL", "ws://whisper-stt:8000/ws/transcrib
|
|
|
# Initialiser le client OpenAI asynchrone ici
|
|
|
openai_client = AsyncOpenAI(api_key=OPENAI_API_KEY, base_url=URL_OPENAI_API)
|
|
|
|
|
|
-BOT_VERSION = "3.0.0-alpha1"
|
|
|
+BOT_VERSION = "3.0.0-alpha2"
|
|
|
+
|
|
|
+# Vérifier la version de Discord
|
|
|
+if not sys.version_info[:2] >= (3, 13):
|
|
|
+ print("ERROR: Requires python 3.13 or newer.")
|
|
|
+ exit(1)
|
|
|
|
|
|
# Vérifier que les tokens et le prompt de personnalité sont récupérés
|
|
|
if DISCORD_TOKEN is None or OPENAI_API_KEY is None or DISCORD_CHANNEL_ID is None:
|
|
|
@@ -59,7 +70,7 @@ with open(PERSONALITY_PROMPT_FILE, 'r', encoding='utf-8') as f:
|
|
|
PERSONALITY_PROMPT = f.read().strip()
|
|
|
|
|
|
# Log configuration
|
|
|
-log_format = '%(asctime)-13s : %(name)-15s : %(levelname)-8s : %(message)s'
|
|
|
+log_format = '%(asctime)-13s : %(name)-25s : %(levelname)-8s : %(message)s'
|
|
|
logging.basicConfig(handlers=[logging.FileHandler("./chatbot.log", 'a', 'utf-8')], format=log_format, level=LOG_LEVEL)
|
|
|
|
|
|
console = logging.StreamHandler()
|
|
|
@@ -71,6 +82,10 @@ logger.setLevel("DEBUG")
|
|
|
|
|
|
logging.getLogger('').addHandler(console)
|
|
|
|
|
|
+discord_logger = logging.getLogger("discord")
|
|
|
+discord_logger.handlers.clear()
|
|
|
+discord_logger.propagate = True
|
|
|
+
|
|
|
httpx_logger = logging.getLogger('httpx')
|
|
|
httpx_logger.setLevel(logging.DEBUG)
|
|
|
|