more tests
This commit is contained in:
parent
a288d06345
commit
f530071bb2
16
src/main.py
16
src/main.py
@ -1,5 +1,6 @@
|
|||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import random
|
import random
|
||||||
import zipfile
|
import zipfile
|
||||||
import logging
|
import logging
|
||||||
@ -12,14 +13,13 @@ NOVELAI_API_TOKEN = os.getenv("NOVELAI_API_TOKEN")
|
|||||||
BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
|
BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
|
||||||
ALLOWED_CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID", "0")) # falls nicht gesetzt → 0
|
ALLOWED_CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID", "0")) # falls nicht gesetzt → 0
|
||||||
|
|
||||||
root = logging.getLogger()
|
logging.basicConfig(
|
||||||
root.setLevel(logging.INFO)
|
stream=sys.stdout,
|
||||||
|
level=logging.INFO,
|
||||||
|
format="%(asctime)s - %(levelname)s - %(message)s"
|
||||||
|
)
|
||||||
|
|
||||||
handler = logging.StreamHandler(sys.stdout)
|
logger = logging.getLogger(__name__)
|
||||||
handler.setLevel(logging.DEBUG)
|
|
||||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
||||||
handler.setFormatter(formatter)
|
|
||||||
root.addHandler(handler)
|
|
||||||
|
|
||||||
if not all([NOVELAI_API_TOKEN, BOT_TOKEN, ALLOWED_CHANNEL_ID]):
|
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.")
|
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:
|
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}")
|
logging.info("Generated image, current antlas: {antlas}")
|
||||||
response_bytes = response.content
|
response_bytes = response.content
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user