changed docker name #2

Merged
wirehack7 merged 1 commits from dev into main 2025-05-01 12:14:01 +02:00
Owner
No description provided.
wirehack7 added 1 commit 2025-05-01 12:13:57 +02:00
changed docker name
Some checks failed
Safety Check / safety-check (pull_request) Successful in -1s
Code Quality Check / quality-check (pull_request) Failing after 15s
b7fda36d7a
wirehack7 merged commit 2423ddbb90 into main 2025-05-01 12:14:01 +02:00
First-time contributor

🛡️ Code Quality Report

🔍 black

--- /workspace/wirehack7/novelai-bot/src/main.py	2025-05-01 10:13:45.620000+00:00
+++ /workspace/wirehack7/novelai-bot/src/main.py	2025-05-01 10:13:50.802501+00:00
@@ -7,43 +7,48 @@
 from discord.ext import commands
 import requests
 
 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
+ALLOWED_CHANNEL_ID = int(
+    os.getenv("DISCORD_CHANNEL_ID", "0")
+)  # falls nicht gesetzt → 0
 
 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."
+    )
 
 intents = discord.Intents.default()
 bot = commands.Bot(command_prefix=commands.when_mentioned, intents=intents)
+
 
 @bot.event
 async def on_ready():
     print(f"Bot gestartet als {bot.user}")
     try:
         synced = await bot.tree.sync()
         print(f"{len(synced)} Slash-Commands synchronisiert.")
     except Exception as e:
         print(e)
 
+
 @bot.tree.command(name="generate", description="Generiere ein Bild mit NovelAI v4")
 @app_commands.describe(
     prompt="Was soll dargestellt werden?",
     undesired_prompt="Was soll vermieden werden? (optional)",
-    orientation="portrait oder landscape (Standard: portrait)"
+    orientation="portrait oder landscape (Standard: portrait)",
 )
 async def generate(
     interaction: discord.Interaction,
     prompt: str,
     undesired_prompt: str = "",
-    orientation: str = "portrait"
+    orientation: str = "portrait",
 ):
     if interaction.channel.id != ALLOWED_CHANNEL_ID:
         await interaction.response.send_message(
-            "Dieser Befehl ist in diesem Kanal nicht erlaubt.",
-            ephemeral=True
+            "Dieser Befehl ist in diesem Kanal nicht erlaubt.", ephemeral=True
         )
         return
 
     await interaction.response.defer(thinking=True)
 
@@ -91,43 +96,40 @@
             "legacy_v3_extend": False,
             "skip_cfg_above_sigma": None,
             "use_coords": False,
             "legacy_uc": False,
             "normalize_reference_strength_multiple": True,
-            #"seed": seed,
+            # "seed": seed,
             "characterPrompts": [],
             "v4_prompt": {
-                "caption": {
-                    "base_caption": prompt,
-                    "char_captions": []
-                },
+                "caption": {"base_caption": prompt, "char_captions": []},
                 "use_coords": False,
-                "use_order": True
+                "use_order": True,
             },
             "v4_negative_prompt": {
                 "caption": {
                     "base_caption": default_negative + undesired_prompt.strip(),
-                    "char_captions": []
+                    "char_captions": [],
                 },
-                "legacy_uc": False
+                "legacy_uc": False,
             },
             "negative_prompt": default_negative + undesired_prompt.strip(),
             "deliberate_euler_ancestral_bug": False,
-            "prefer_brownian": True
-        }
+            "prefer_brownian": True,
+        },
     }
 
     headers = {
         "Authorization": f"Bearer {NOVELAI_API_TOKEN}",
-        "Content-Type": "application/json"
+        "Content-Type": "application/json",
     }
 
     response = requests.post(
         "https://image.novelai.net/ai/generate-image",
         json=payload,
         headers=headers,
-        timeout=120
+        timeout=120,
     )
 
     if response.status_code == 200:
         response_bytes = response.content
 
@@ -139,16 +141,18 @@
 Steps: 28
 Scale: 3.7
 Model: nai-diffusion-4-full```"""
 
         # Prüfen ob ZIP (PK am Anfang)
-        if response_bytes[:2] == b'PK':
+        if response_bytes[:2] == b"PK":
             # ZIP-Archiv entpacken
             with zipfile.ZipFile(io.BytesIO(response_bytes)) as zip_file:
                 namelist = zip_file.namelist()
                 # Erstes PNG suchen
-                image_name = next((name for name in namelist if name.endswith(".png")), None)
+                image_name = next(
+                    (name for name in namelist if name.endswith(".png")), None
+                )
 
                 if image_name:
                     image_bytes = zip_file.read(image_name)
                     filename = "novelai.png"
                     file = discord.File(io.BytesIO(image_bytes), filename=filename)
@@ -156,11 +160,11 @@
                 else:
                     await interaction.followup.send(
                         "ZIP erhalten, aber kein PNG-Bild gefunden."
                     )
 
-        elif response_bytes[:4] == b'\x89PNG':
+        elif response_bytes[:4] == b"\x89PNG":
             # Direkte PNG-Rückgabe
             filename = "novelai.png"
             file = discord.File(io.BytesIO(response_bytes), filename=filename)
             await interaction.followup.send(content=param_text, file=file)
 
would reformat /workspace/wirehack7/novelai-bot/src/main.py

Oh no! 💥 💔 💥
1 file would be reformatted.

🔍 isort

ERROR: /workspace/wirehack7/novelai-bot/src/main.py Imports are incorrectly sorted and/or formatted.
--- /workspace/wirehack7/novelai-bot/src/main.py:before	2025-05-01 10:13:45.620000
+++ /workspace/wirehack7/novelai-bot/src/main.py:after	2025-05-01 10:13:51.313040
@@ -2,10 +2,11 @@
 import os
 import random
 import zipfile
+
 import discord
+import requests
 from discord import app_commands
 from discord.ext import commands
-import requests
 
 NOVELAI_API_TOKEN = os.getenv("NOVELAI_API_TOKEN")
 BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
Skipped 1 files

🔍 pylint

************* Module src.main
src/main.py:15:0: C0301: Line too long (126/100) (line-too-long)
src/main.py:57:0: C0301: Line too long (105/100) (line-too-long)
src/main.py:58:0: C0301: Line too long (111/100) (line-too-long)
src/main.py:62:0: C0301: Line too long (105/100) (line-too-long)
src/main.py:63:0: C0301: Line too long (111/100) (line-too-long)
src/main.py:169:0: C0301: Line too long (102/100) (line-too-long)
src/main.py:1:0: C0114: Missing module docstring (missing-module-docstring)
src/main.py:21:0: C0116: Missing function or method docstring (missing-function-docstring)
src/main.py:26:11: W0718: Catching too general exception Exception (broad-exception-caught)
src/main.py:35:0: C0116: Missing function or method docstring (missing-function-docstring)
src/main.py:35:0: R0914: Too many local variables (24/15) (too-many-locals)
src/main.py:175:15: W0718: Catching too general exception Exception (broad-exception-caught)

-----------------------------------
Your code has been rated at 8.10/10

🔍 flake8

./src/main.py:12:80: E501 line too long (89 > 79 characters)
./src/main.py:15:80: E501 line too long (126 > 79 characters)
./src/main.py:20:1: E302 expected 2 blank lines, found 1
./src/main.py:29:1: E302 expected 2 blank lines, found 1
./src/main.py:29:80: E501 line too long (83 > 79 characters)
./src/main.py:57:80: E501 line too long (105 > 79 characters)
./src/main.py:58:80: E501 line too long (111 > 79 characters)
./src/main.py:62:80: E501 line too long (105 > 79 characters)
./src/main.py:63:80: E501 line too long (111 > 79 characters)
./src/main.py:96:13: E265 block comment should start with '# '
./src/main.py:108:80: E501 line too long (80 > 79 characters)
./src/main.py:149:80: E501 line too long (93 > 79 characters)
./src/main.py:154:80: E501 line too long (83 > 79 characters)
./src/main.py:155:80: E501 line too long (82 > 79 characters)
./src/main.py:169:80: E501 line too long (102 > 79 characters)
<!-- add-pr-comment:add-pr-comment --> ### 🛡️ Code Quality Report #### 🔍 black ``` --- /workspace/wirehack7/novelai-bot/src/main.py 2025-05-01 10:13:45.620000+00:00 +++ /workspace/wirehack7/novelai-bot/src/main.py 2025-05-01 10:13:50.802501+00:00 @@ -7,43 +7,48 @@ from discord.ext import commands import requests 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 +ALLOWED_CHANNEL_ID = int( + os.getenv("DISCORD_CHANNEL_ID", "0") +) # falls nicht gesetzt → 0 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." + ) intents = discord.Intents.default() bot = commands.Bot(command_prefix=commands.when_mentioned, intents=intents) + @bot.event async def on_ready(): print(f"Bot gestartet als {bot.user}") try: synced = await bot.tree.sync() print(f"{len(synced)} Slash-Commands synchronisiert.") except Exception as e: print(e) + @bot.tree.command(name="generate", description="Generiere ein Bild mit NovelAI v4") @app_commands.describe( prompt="Was soll dargestellt werden?", undesired_prompt="Was soll vermieden werden? (optional)", - orientation="portrait oder landscape (Standard: portrait)" + orientation="portrait oder landscape (Standard: portrait)", ) async def generate( interaction: discord.Interaction, prompt: str, undesired_prompt: str = "", - orientation: str = "portrait" + orientation: str = "portrait", ): if interaction.channel.id != ALLOWED_CHANNEL_ID: await interaction.response.send_message( - "Dieser Befehl ist in diesem Kanal nicht erlaubt.", - ephemeral=True + "Dieser Befehl ist in diesem Kanal nicht erlaubt.", ephemeral=True ) return await interaction.response.defer(thinking=True) @@ -91,43 +96,40 @@ "legacy_v3_extend": False, "skip_cfg_above_sigma": None, "use_coords": False, "legacy_uc": False, "normalize_reference_strength_multiple": True, - #"seed": seed, + # "seed": seed, "characterPrompts": [], "v4_prompt": { - "caption": { - "base_caption": prompt, - "char_captions": [] - }, + "caption": {"base_caption": prompt, "char_captions": []}, "use_coords": False, - "use_order": True + "use_order": True, }, "v4_negative_prompt": { "caption": { "base_caption": default_negative + undesired_prompt.strip(), - "char_captions": [] + "char_captions": [], }, - "legacy_uc": False + "legacy_uc": False, }, "negative_prompt": default_negative + undesired_prompt.strip(), "deliberate_euler_ancestral_bug": False, - "prefer_brownian": True - } + "prefer_brownian": True, + }, } headers = { "Authorization": f"Bearer {NOVELAI_API_TOKEN}", - "Content-Type": "application/json" + "Content-Type": "application/json", } response = requests.post( "https://image.novelai.net/ai/generate-image", json=payload, headers=headers, - timeout=120 + timeout=120, ) if response.status_code == 200: response_bytes = response.content @@ -139,16 +141,18 @@ Steps: 28 Scale: 3.7 Model: nai-diffusion-4-full```""" # Prüfen ob ZIP (PK am Anfang) - if response_bytes[:2] == b'PK': + if response_bytes[:2] == b"PK": # ZIP-Archiv entpacken with zipfile.ZipFile(io.BytesIO(response_bytes)) as zip_file: namelist = zip_file.namelist() # Erstes PNG suchen - image_name = next((name for name in namelist if name.endswith(".png")), None) + image_name = next( + (name for name in namelist if name.endswith(".png")), None + ) if image_name: image_bytes = zip_file.read(image_name) filename = "novelai.png" file = discord.File(io.BytesIO(image_bytes), filename=filename) @@ -156,11 +160,11 @@ else: await interaction.followup.send( "ZIP erhalten, aber kein PNG-Bild gefunden." ) - elif response_bytes[:4] == b'\x89PNG': + elif response_bytes[:4] == b"\x89PNG": # Direkte PNG-Rückgabe filename = "novelai.png" file = discord.File(io.BytesIO(response_bytes), filename=filename) await interaction.followup.send(content=param_text, file=file) would reformat /workspace/wirehack7/novelai-bot/src/main.py Oh no! 💥 💔 💥 1 file would be reformatted. ``` #### 🔍 isort ``` ERROR: /workspace/wirehack7/novelai-bot/src/main.py Imports are incorrectly sorted and/or formatted. --- /workspace/wirehack7/novelai-bot/src/main.py:before 2025-05-01 10:13:45.620000 +++ /workspace/wirehack7/novelai-bot/src/main.py:after 2025-05-01 10:13:51.313040 @@ -2,10 +2,11 @@ import os import random import zipfile + import discord +import requests from discord import app_commands from discord.ext import commands -import requests NOVELAI_API_TOKEN = os.getenv("NOVELAI_API_TOKEN") BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN") Skipped 1 files ``` #### 🔍 pylint ``` ************* Module src.main src/main.py:15:0: C0301: Line too long (126/100) (line-too-long) src/main.py:57:0: C0301: Line too long (105/100) (line-too-long) src/main.py:58:0: C0301: Line too long (111/100) (line-too-long) src/main.py:62:0: C0301: Line too long (105/100) (line-too-long) src/main.py:63:0: C0301: Line too long (111/100) (line-too-long) src/main.py:169:0: C0301: Line too long (102/100) (line-too-long) src/main.py:1:0: C0114: Missing module docstring (missing-module-docstring) src/main.py:21:0: C0116: Missing function or method docstring (missing-function-docstring) src/main.py:26:11: W0718: Catching too general exception Exception (broad-exception-caught) src/main.py:35:0: C0116: Missing function or method docstring (missing-function-docstring) src/main.py:35:0: R0914: Too many local variables (24/15) (too-many-locals) src/main.py:175:15: W0718: Catching too general exception Exception (broad-exception-caught) ----------------------------------- Your code has been rated at 8.10/10 ``` #### 🔍 flake8 ``` ./src/main.py:12:80: E501 line too long (89 > 79 characters) ./src/main.py:15:80: E501 line too long (126 > 79 characters) ./src/main.py:20:1: E302 expected 2 blank lines, found 1 ./src/main.py:29:1: E302 expected 2 blank lines, found 1 ./src/main.py:29:80: E501 line too long (83 > 79 characters) ./src/main.py:57:80: E501 line too long (105 > 79 characters) ./src/main.py:58:80: E501 line too long (111 > 79 characters) ./src/main.py:62:80: E501 line too long (105 > 79 characters) ./src/main.py:63:80: E501 line too long (111 > 79 characters) ./src/main.py:96:13: E265 block comment should start with '# ' ./src/main.py:108:80: E501 line too long (80 > 79 characters) ./src/main.py:149:80: E501 line too long (93 > 79 characters) ./src/main.py:154:80: E501 line too long (83 > 79 characters) ./src/main.py:155:80: E501 line too long (82 > 79 characters) ./src/main.py:169:80: E501 line too long (102 > 79 characters) ```
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wirehack7/novelai-bot#2
No description provided.