8a1da13383
Dockerfile fixes: - edu_master/phpsessid-bot: add --no-install-recommends, pin pip versions - edu_master/webinar-checker: pin pip versions with --no-cache-dir - userbot: add SHELL with pipefail for pipe operations Ruff fixes (173 → 0): - W293/W291/W292: whitespace clean via ruff format - N806: camelCase → snake_case (anilist, safone, hearts, flux, etc.) - ARG001/ARG002: prefix unused params with _ - SIM115: use context managers for file I/O - SIM117: combine nested with statements - S608: noqa on SQL f-strings (module name is validated) - E402/N812/N817: import fixes - B023: pass loop variable as argument - I001: auto-sorted imports - syntax: fixed = vs == in dtek_notif/main.py
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
import os
|
|
import time
|
|
|
|
import requests
|
|
from pyrogram import Client, filters
|
|
from pyrogram.types import Message
|
|
from utils.misc import modules_help, prefix
|
|
from utils.scripts import format_exc, progress
|
|
|
|
|
|
def schellwithflux(args):
|
|
api_url = 'https://randydev-ryuzaki-api.hf.space/api/v1/akeno/fluxai'
|
|
payload = {'user_id': 1191668125, 'args': args} # Please don't edit here
|
|
response = requests.post(api_url, json=payload, timeout=10)
|
|
if response.status_code != 200:
|
|
print(f'Error status {response.status_code}')
|
|
return None
|
|
return response.content
|
|
|
|
|
|
@Client.on_message(filters.command('fluxai', prefix) & filters.me)
|
|
async def imgfluxai_(_client: Client, message: Message):
|
|
question = message.text.split(' ', 1)[1] if len(message.command) > 1 else None
|
|
if not question:
|
|
return await message.reply_text('Please provide a question for Flux.')
|
|
try:
|
|
image_bytes = schellwithflux(question)
|
|
if image_bytes is None:
|
|
return await message.reply_text('Failed to generate an image.')
|
|
pro = await message.reply_text('Generating image, please wait...')
|
|
|
|
# Write the image bytes directly to a file
|
|
with open('flux_gen.jpg', 'wb') as f:
|
|
f.write(image_bytes)
|
|
|
|
ok = await pro.edit_text('Uploading image...')
|
|
await message.reply_photo(
|
|
'flux_gen.jpg',
|
|
progress=progress,
|
|
progress_args=(ok, time.time(), 'Uploading image...'),
|
|
)
|
|
await ok.delete()
|
|
if os.path.exists('flux_gen.jpg'):
|
|
os.remove('flux_gen.jpg')
|
|
except Exception as e:
|
|
await message.edit_text(format_exc(e))
|
|
|
|
|
|
modules_help['fluxai'] = {
|
|
'fluxai [prompt]*': 'text to image fluxai',
|
|
}
|