|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import time |
|
import os |
|
from pyrogram import * |
|
from pyrogram import Client, filters |
|
from pyrogram.types import * |
|
from pyrogram.errors import * |
|
from akn import log_detailed_error |
|
from akn.utils.handler import * |
|
from akn.utils.logger import LOGS |
|
from akn.utils.scripts import progress |
|
from config import * |
|
from akn.utils.prefixprem import command |
|
from akenoai import * |
|
from akenoai.types import DifferentAPIDefault |
|
from . import ReplyCheck |
|
|
|
custom_loading = "<emoji id=5974235702701853774>๐ฟ</emoji>" |
|
|
|
@Akeno( |
|
command(["fluxai"]) |
|
& filters.me |
|
& ~filters.forwarded |
|
) |
|
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.") |
|
if client.me.is_premium: |
|
pro = await message.reply_text(f"{custom_loading}Generating image, please wait...") |
|
else: |
|
pro = await message.reply_text("Generating image, please wait...") |
|
try: |
|
js = AkenoXJs(DifferentAPIDefault()).connect() |
|
response = await js.image.create( |
|
"black-forest-labs/flux-1-schnell", |
|
image_read=True, |
|
params_data={"query": question}, |
|
) |
|
file_path = "randydev.jpg" |
|
with open(file_path, "wb") as f: |
|
f.write(response) |
|
await pro.edit_text("Uploading image...") |
|
await message.reply_photo( |
|
file_path, |
|
progress=progress, |
|
progress_args=( |
|
pro, |
|
time.time(), |
|
"Uploading image..." |
|
), |
|
reply_to_message_id=ReplyCheck(message) |
|
) |
|
await pro.delete() |
|
if os.path.exists(file_path): |
|
os.remove(file_path) |
|
except ChatSendPhotosForbidden: |
|
return await pro.edit_text("You can't send photos in this chat") |
|
except Exception as e: |
|
await log_detailed_error(e, where=client.me.id, who=message.chat.title) |
|
await pro.edit_text("error generating the image.") |
|
|
|
module = modules_help.add_module("fluxai", __file__) |
|
module.add_command("fluxai", "to question flux image generator.") |