chore(userbot): apply ruff check --fix and ruff format
- ruff check --fix: 210 auto-fixed errors (import sorting, trailing whitespace, unused imports, f-string fixups, deprecated annotations) - ruff format: 104 files reformatted to consistent style - 268 non-auto-fixable issues remain (S113 requests timeout, etc.)
This commit is contained in:
+19
-20
@@ -1,52 +1,51 @@
|
||||
import os
|
||||
import io
|
||||
import time
|
||||
import requests
|
||||
from pyrogram import filters, Client
|
||||
from pyrogram.types import Message
|
||||
|
||||
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
|
||||
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)
|
||||
if response.status_code != 200:
|
||||
print(f"Error status {response.status_code}")
|
||||
print(f'Error status {response.status_code}')
|
||||
return None
|
||||
return response.content
|
||||
|
||||
|
||||
@Client.on_message(filters.command("fluxai", prefix) & filters.me)
|
||||
@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
|
||||
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.")
|
||||
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...")
|
||||
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:
|
||||
with open('flux_gen.jpg', 'wb') as f:
|
||||
f.write(image_bytes)
|
||||
|
||||
ok = await pro.edit_text("Uploading image...")
|
||||
ok = await pro.edit_text('Uploading image...')
|
||||
await message.reply_photo(
|
||||
"flux_gen.jpg",
|
||||
'flux_gen.jpg',
|
||||
progress=progress,
|
||||
progress_args=(ok, time.time(), "Uploading image..."),
|
||||
progress_args=(ok, time.time(), 'Uploading image...'),
|
||||
)
|
||||
await ok.delete()
|
||||
if os.path.exists("flux_gen.jpg"):
|
||||
os.remove("flux_gen.jpg")
|
||||
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",
|
||||
modules_help['fluxai'] = {
|
||||
'fluxai [prompt]*': 'text to image fluxai',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user