diff --git a/src/main.py b/src/main.py index 2ea5dac..fe34491 100644 --- a/src/main.py +++ b/src/main.py @@ -1,5 +1,6 @@ import io import os +import sys import random import zipfile import logging @@ -12,14 +13,13 @@ NOVELAI_API_TOKEN = os.getenv("NOVELAI_API_TOKEN") BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN") ALLOWED_CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID", "0")) # falls nicht gesetzt → 0 -root = logging.getLogger() -root.setLevel(logging.INFO) +logging.basicConfig( + stream=sys.stdout, + level=logging.INFO, + format="%(asctime)s - %(levelname)s - %(message)s" +) -handler = logging.StreamHandler(sys.stdout) -handler.setLevel(logging.DEBUG) -formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') -handler.setFormatter(formatter) -root.addHandler(handler) +logger = logging.getLogger(__name__) if not all([NOVELAI_API_TOKEN, BOT_TOKEN, ALLOWED_CHANNEL_ID]): raise ValueError("Environment-Variablen NOVELAI_API_TOKEN, DISCORD_BOT_TOKEN und DISCORD_CHANNEL_ID müssen gesetzt sein.") @@ -160,7 +160,7 @@ async def generate( ) if response.status_code == 200: - antlas = get_available_antlas(NOVELAI_API_TOKEN) + antlas = await get_available_antlas(NOVELAI_API_TOKEN) logging.info("Generated image, current antlas: {antlas}") response_bytes = response.content