Update Akeno/plugins/imageai.py
Browse files- Akeno/plugins/imageai.py +6 -5
Akeno/plugins/imageai.py
CHANGED
@@ -47,19 +47,20 @@ async def schellwithflux(args):
|
|
47 |
& ~filters.forwarded
|
48 |
)
|
49 |
async def imgfluxai_(client: Client, message: Message):
|
|
|
50 |
question = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
|
51 |
if not question:
|
52 |
-
return await
|
53 |
try:
|
54 |
if not HUGGING_TOKEN:
|
55 |
-
return await
|
56 |
image_bytes = await schellwithflux(question)
|
57 |
if image_bytes is None:
|
58 |
-
return await
|
59 |
-
|
60 |
with Image.open(io.BytesIO(image_bytes)) as img:
|
61 |
img.save("testing.jpg", format="JPEG")
|
62 |
-
ok = await
|
63 |
await message.reply_photo("testing.jpg", progress=progress, progress_args=(ok, time.time(), "Uploading image..."))
|
64 |
await ok.delete()
|
65 |
except Exception as e:
|
|
|
47 |
& ~filters.forwarded
|
48 |
)
|
49 |
async def imgfluxai_(client: Client, message: Message):
|
50 |
+
ok = await message.reply_text("Processing...")
|
51 |
question = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
|
52 |
if not question:
|
53 |
+
return await ok.edit_text("Please provide a question for Flux.")
|
54 |
try:
|
55 |
if not HUGGING_TOKEN:
|
56 |
+
return await ok.edit_text("`HUGGING_TOKEN` is required to use this feature.")
|
57 |
image_bytes = await schellwithflux(question)
|
58 |
if image_bytes is None:
|
59 |
+
return await ok.edit_text("Failed to generate an image.")
|
60 |
+
# await ok.edit_text("Generating image, please wait...")
|
61 |
with Image.open(io.BytesIO(image_bytes)) as img:
|
62 |
img.save("testing.jpg", format="JPEG")
|
63 |
+
# ok = await ok.edit_text("Uploading image...")
|
64 |
await message.reply_photo("testing.jpg", progress=progress, progress_args=(ok, time.time(), "Uploading image..."))
|
65 |
await ok.delete()
|
66 |
except Exception as e:
|