Compare commits

..

28 Commits
v0.1.3 ... main

Author SHA1 Message Date
c8bb6681c7 Merge pull request 'dev' (#24) from dev into main
Some checks failed
Code Quality Check / quality-check (push) Failing after -40s
Safety Check / safety-check (push) Successful in -41s
Cleanup old Docker images / cleanup (push) Failing after -54s
Reviewed-on: #24
2025-12-11 09:41:20 +01:00
c0d5bff873 Merge pull request 'Update actions/setup-python action to v6' (#20) from renovate/actions-setup-python-6.x into dev
Some checks failed
Safety Check / safety-check (pull_request) Successful in -53s
Code Quality Check / quality-check (pull_request) Failing after 1m19s
Reviewed-on: #20
2025-12-11 09:35:51 +01:00
ff7b33b952 Merge pull request 'Update python Docker tag to v3.14.2' (#23) from renovate/python-3.x into dev
Reviewed-on: #23
2025-12-11 09:35:39 +01:00
702e62973a
Update python Docker tag to v3.14.2 2025-12-09 00:00:11 +00:00
c3dd3fa7b0 Merge pull request 'Update dependency python to v3.14.0' (#18) from renovate/python-3.x into dev
Reviewed-on: #18
2025-11-24 09:43:48 +01:00
b4954b082e Merge pull request 'Update actions/upload-artifact action to v5' (#21) from renovate/major-github-artifact-actions into dev
Reviewed-on: #21
2025-11-24 09:43:35 +01:00
54713ed346 Merge pull request 'Update actions/checkout action to v6' (#22) from renovate/actions-checkout-6.x into dev
Reviewed-on: #22
2025-11-24 09:43:14 +01:00
673fc0deaf
Update actions/checkout action to v6 2025-11-21 00:00:23 +00:00
f80cc18294
Update actions/upload-artifact action to v5 2025-10-25 00:15:07 +00:00
e03b26da0f
Update dependency python to v3.14.0 2025-10-08 00:13:55 +00:00
9eef597c8d
Update actions/setup-python action to v6 2025-09-05 00:11:19 +00:00
57acaef1b2 Merge pull request 'dev' (#17) from dev into main
Some checks failed
Code Quality Check / quality-check (push) Successful in 4m58s
Safety Check / safety-check (push) Successful in -52s
Cleanup old Docker images / cleanup (push) Failing after -1m5s
Reviewed-on: #17
2025-06-25 16:42:29 +02:00
aa2382f3b4 Merge pull request 'Update python Docker tag to v3.13.5' (#16) from renovate/python-3.x into dev
All checks were successful
Safety Check / safety-check (pull_request) Successful in 4m41s
Code Quality Check / quality-check (pull_request) Successful in 5m5s
Reviewed-on: #16
2025-06-25 16:41:15 +02:00
a8d83c8768
Update python Docker tag to v3.13.5 2025-06-14 00:04:03 +00:00
e7be5553cc Merge pull request 'Update python Docker tag to v3.13.4' (#15) from renovate/python-3.x into dev
Reviewed-on: #15
2025-06-10 17:35:31 +02:00
895b17390d
Update python Docker tag to v3.13.4 2025-06-04 22:04:02 +00:00
9145ac1bb4
pylint, fuck you! 🖕
All checks were successful
Safety Check / safety-check (pull_request) Successful in -2s
Code Quality Check / quality-check (pull_request) Successful in 13s
2025-05-01 19:30:45 +02:00
44d0315059 Merge pull request 'better timeout handling' (#14) from dev into main
Some checks failed
Code Quality Check / quality-check (push) Successful in 13s
Safety Check / safety-check (push) Successful in 4m38s
Cleanup old Docker images / cleanup (push) Failing after 4m27s
Reviewed-on: #14
2025-05-01 19:29:54 +02:00
b3045bf724
reformatted
Some checks failed
Safety Check / safety-check (pull_request) Successful in -1s
Code Quality Check / quality-check (pull_request) Failing after 13s
2025-05-01 19:28:14 +02:00
90c97d3f54
better timeout handling
Some checks failed
Safety Check / safety-check (pull_request) Successful in -1s
Code Quality Check / quality-check (pull_request) Failing after 14s
2025-05-01 19:25:48 +02:00
6bf61fdbf0
removed requests
All checks were successful
Safety Check / safety-check (pull_request) Successful in -3s
Code Quality Check / quality-check (pull_request) Successful in 10s
2025-05-01 15:56:57 +02:00
b2c2d4bcc2 Merge pull request 'switched to atiohttp' (#13) from dev into main
All checks were successful
Safety Check / safety-check (push) Successful in -2s
Code Quality Check / quality-check (push) Successful in 11s
Build and Push Docker Image / build (push) Successful in -9s
Reviewed-on: #13
2025-05-01 15:56:10 +02:00
1ef60193a0
more fixes
Some checks failed
Safety Check / safety-check (pull_request) Successful in -2s
Code Quality Check / quality-check (pull_request) Failing after 10s
2025-05-01 15:55:54 +02:00
3fbc996de1
switched to aiohttp
Some checks failed
Safety Check / safety-check (pull_request) Successful in -1s
Code Quality Check / quality-check (pull_request) Failing after 57s
2025-05-01 15:52:18 +02:00
8819489a7d Merge pull request 'Update dependency python to 3.13' (#10) from renovate/python-3.x into dev
Reviewed-on: #10
2025-05-01 15:18:11 +02:00
3c979d855e
Update dependency python to 3.13 2025-05-01 13:16:48 +00:00
5d42ab65e6
Added renovate
All checks were successful
Safety Check / safety-check (pull_request) Successful in -1s
Code Quality Check / quality-check (pull_request) Successful in 15s
2025-05-01 15:15:21 +02:00
fa70c064cf Merge pull request 'Added renovate' (#9) from dev into main
All checks were successful
Safety Check / safety-check (push) Successful in -2s
Code Quality Check / quality-check (push) Successful in 13s
Reviewed-on: #9
2025-05-01 15:14:56 +02:00
6 changed files with 54 additions and 26 deletions

View File

@ -15,12 +15,12 @@ jobs:
GITHUB: ${{ secrets.GITHUB }} GITHUB: ${{ secrets.GITHUB }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v6
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v6
with: with:
python-version: '3.10' python-version: '3.14'
- name: Install dependencies - name: Install dependencies
run: | run: |
@ -85,7 +85,7 @@ jobs:
# Ergebnisse als Artefakte speichern # Ergebnisse als Artefakte speichern
- name: Upload results as artifacts - name: Upload results as artifacts
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v5
with: with:
name: quality-reports name: quality-reports
path: /tmp/results path: /tmp/results

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v6
- name: Verify Docker installation - name: Verify Docker installation
run: docker --version run: docker --version

20
.github/renovate.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
],
"baseBranches": [
"dev"
],
"packageRules": [
{
"matchUpdateTypes": [
"minor",
"patch",
"pin",
"digest"
],
"automerge": false
}
]
}

View File

@ -1,4 +1,4 @@
FROM python:3.13.3-slim FROM python:3.14.2-slim
WORKDIR /app WORKDIR /app

View File

@ -10,8 +10,8 @@ import sys
import time import time
import zipfile import zipfile
import aiohttp
import discord import discord
import requests
from discord import app_commands from discord import app_commands
from discord.ext import commands from discord.ext import commands
@ -30,7 +30,7 @@ logger = logging.getLogger(__name__)
if not all([NOVELAI_API_TOKEN, BOT_TOKEN, ALLOWED_CHANNEL_ID]): if not all([NOVELAI_API_TOKEN, BOT_TOKEN, ALLOWED_CHANNEL_ID]):
raise ValueError( raise ValueError(
"NOVELAI_API_TOKEN, DISCORD_BOT_TOKEN und DISCORD_CHANNEL_ID müssen gesetzt sein." "NOVELAI_API_TOKEN, DISCORD_BOT_TOKEN and DISCORD_CHANNEL_ID have to be set."
) )
intents = discord.Intents.default() intents = discord.Intents.default()
@ -43,9 +43,9 @@ async def on_ready():
print(f"Bot gestartet als {bot.user}") print(f"Bot gestartet als {bot.user}")
try: try:
synced = await bot.tree.sync() synced = await bot.tree.sync()
logger.info("%d Slash-Commands synchronisiert.", len(synced)) logger.info("%d Slash-Commands synchronized.", len(synced))
except Exception as err: # pylint: disable=W0718 except Exception as err: # pylint: disable=W0718
logger.error("Fehler beim Synchronisieren der Commands: %s", err) logger.error("error while syncing the command: %s", err)
activity = discord.Game(name="generating juicy NovelAI images 🥵") activity = discord.Game(name="generating juicy NovelAI images 🥵")
await bot.change_presence(status=discord.Status.online, activity=activity) await bot.change_presence(status=discord.Status.online, activity=activity)
@ -58,7 +58,7 @@ async def on_ready():
orientation="portrait or landscape (Standard: portrait)", orientation="portrait or landscape (Standard: portrait)",
seed="Optional seed (integer). If empty, a random one will be generated", seed="Optional seed (integer). If empty, a random one will be generated",
) )
# pylint: disable=too-many-locals,too-many-return-statements # pylint: disable=too-many-locals,too-many-return-statements,too-many-statements
async def generate( async def generate(
interaction: discord.Interaction, interaction: discord.Interaction,
prompt: str, prompt: str,
@ -159,17 +159,25 @@ async def generate(
} }
start_time = time.monotonic() start_time = time.monotonic()
response = requests.post( try:
async with aiohttp.ClientSession() as session:
async with session.post(
"https://image.novelai.net/ai/generate-image", "https://image.novelai.net/ai/generate-image",
json=payload, json=payload,
headers=headers, headers=headers,
timeout=120, timeout=aiohttp.ClientTimeout(total=120),
) ) as response:
response_bytes = await response.read()
status_code = response.status
except aiohttp.TimeoutError:
await interaction.followup.send("Error: the request timed out.")
except aiohttp.ClientError as e:
await interaction.followup.send(f"Error: {e}")
duration = time.monotonic() - start_time duration = time.monotonic() - start_time
logger.info("Image creation took %.2f seconds", duration) logger.info("Image creation took %.2f seconds", duration)
if response.status_code == 200: if status_code == 200:
response_bytes = response.content
param_text = ( param_text = (
f"```Prompt: {prompt}\n" f"```Prompt: {prompt}\n"
f"Undesired prompt: {negative_prompt}\n" f"Undesired prompt: {negative_prompt}\n"
@ -206,13 +214,13 @@ async def generate(
return return
try: try:
error_data = response.json() error_data = response_bytes.decode("utf-8")
except Exception: # pylint: disable=W0718 except Exception: # pylint: disable=W0718
error_data = {"error": response.text} error_data = "error message unreadable"
error_message = f"Error {response.status_code} at API-request.\n" error_message = (
for key, value in error_data.items(): f"Error {status_code} at API-request.\n" f"Answer: {error_data}\n"
error_message += f"**{key}**: {value}\n" )
await interaction.followup.send(error_message) await interaction.followup.send(error_message)

View File

@ -1,2 +1,2 @@
discord discord
requests aiohttp