fix prompting
This commit is contained in:
parent
adae98a7b0
commit
05baa4a473
@ -5,7 +5,7 @@ httpcore==1.0.6
|
|||||||
httpx==0.27.2
|
httpx==0.27.2
|
||||||
idna==3.10
|
idna==3.10
|
||||||
pillow==11.0.0
|
pillow==11.0.0
|
||||||
python-telegram-bot==21.6
|
python-telegram-bot==21.11.1
|
||||||
sniffio==1.3.1
|
sniffio==1.3.1
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
Pybooru==4.2.2
|
Pybooru==4.2.2
|
||||||
|
@ -4,8 +4,11 @@ import json
|
|||||||
import random
|
import random
|
||||||
import shlex
|
import shlex
|
||||||
import threading
|
import threading
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import httpx
|
||||||
|
import requests
|
||||||
import telegram
|
import telegram
|
||||||
import websockets
|
import websockets
|
||||||
from telegram import Update
|
from telegram import Update
|
||||||
@ -47,10 +50,22 @@ async def ws_task():
|
|||||||
|
|
||||||
print(f"Received message: {message}")
|
print(f"Received message: {message}")
|
||||||
|
|
||||||
|
# Download the image
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
response = await client.get(image_url)
|
||||||
|
response.raise_for_status() # Raise an exception for HTTP errors
|
||||||
|
|
||||||
|
# Create a BytesIO object from the image data
|
||||||
|
image_bytes = BytesIO(response.content)
|
||||||
|
|
||||||
bot = telegram.Bot(TOKEN)
|
bot = telegram.Bot(TOKEN)
|
||||||
|
|
||||||
async with bot:
|
async with bot:
|
||||||
await bot.send_photo(chat_id=chat_id, photo=image_url, caption=str(message))
|
await bot.send_document(
|
||||||
|
chat_id=chat_id,
|
||||||
|
document=image_bytes,
|
||||||
|
caption=str(message)
|
||||||
|
)
|
||||||
|
|
||||||
del scheduled_prompts[prompt_id]
|
del scheduled_prompts[prompt_id]
|
||||||
|
|
||||||
@ -232,7 +247,7 @@ async def gen_image(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||||||
models = await list_models()
|
models = await list_models()
|
||||||
return await context.bot.send_message(chat_id=update.effective_chat.id, text=models)
|
return await context.bot.send_message(chat_id=update.effective_chat.id, text=models)
|
||||||
|
|
||||||
query = query.replace("prompting", "").replace("—", "--").replace("\n", "")
|
query = update.message.text.replace("prompting", "").replace("—", "--").replace("\n", "")
|
||||||
|
|
||||||
parser = create_prompting_parser()
|
parser = create_prompting_parser()
|
||||||
|
|
||||||
@ -274,4 +289,5 @@ async def gen_image(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
return await context.bot.send_message(chat_id=update.effective_chat.id,
|
return await context.bot.send_message(chat_id=update.effective_chat.id,
|
||||||
text="Some weird incomprehensible error occurred :<")
|
text="Some weird incomprehensible error occurred :<\n"
|
||||||
|
+ json.dumps(result))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user