add prompting
This commit is contained in:
parent
a6d58ebf6b
commit
2bb1e2dccb
9 changed files with 277 additions and 48 deletions
17
bot.py
17
bot.py
|
@ -5,6 +5,7 @@ import logging
|
|||
|
||||
from tgbot.config import TOKEN
|
||||
from tgbot.shit.handlers import handle_xitter, handle_red_ebalo, handle_hentai, handle_cute_button
|
||||
from tgbot.shit.prompting import gen_image
|
||||
from tgbot.shit.render import render_text_on_image, image_to_string
|
||||
from io import BytesIO
|
||||
|
||||
|
@ -20,9 +21,13 @@ async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||
'AND I AM A PERSON OF COMPLETE AND TOTAL DELUSION!')
|
||||
|
||||
|
||||
async def respond_with_picture(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
file = render_text_on_image("tgbot/assets/red_ebalo.png", update.message.text)
|
||||
await context.bot.send_sticker(chat_id=update.effective_chat.id, sticker=file)
|
||||
async def handle_text(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
|
||||
if not update.message.text.startswith("prompting"):
|
||||
file = render_text_on_image("tgbot/assets/red_ebalo.png", update.message.text)
|
||||
await context.bot.send_sticker(chat_id=update.effective_chat.id, sticker=file)
|
||||
else:
|
||||
await gen_image(update, context)
|
||||
|
||||
|
||||
async def image2string(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
|
@ -52,7 +57,6 @@ async def callback_query_handler(update: Update, context: CallbackContext):
|
|||
else:
|
||||
await query.answer()
|
||||
|
||||
|
||||
async def handle_inline(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
query = update.inline_query.query
|
||||
if not query:
|
||||
|
@ -72,17 +76,16 @@ async def handle_inline(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||
|
||||
await handle_red_ebalo(update, context)
|
||||
|
||||
|
||||
def main():
|
||||
application = ApplicationBuilder().token(TOKEN).build()
|
||||
|
||||
start_handler = CommandHandler('start', start)
|
||||
picture_handler = MessageHandler(filters.TEXT & ~filters.COMMAND, respond_with_picture)
|
||||
text_handler = MessageHandler(filters.TEXT & ~filters.COMMAND, handle_text)
|
||||
|
||||
application.add_handler(start_handler)
|
||||
|
||||
application.add_handler(MessageHandler(filters.PHOTO, image2string))
|
||||
application.add_handler(picture_handler)
|
||||
application.add_handler(text_handler)
|
||||
application.add_handler(InlineQueryHandler(handle_inline))
|
||||
application.add_handler(CallbackQueryHandler(callback_query_handler))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue