add button
This commit is contained in:
parent
ef18f67115
commit
219e28b420
2 changed files with 42 additions and 3 deletions
25
bot.py
25
bot.py
|
@ -1,9 +1,10 @@
|
|||
from telegram import Update
|
||||
from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler, MessageHandler, filters, InlineQueryHandler
|
||||
from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler, MessageHandler, filters, InlineQueryHandler, \
|
||||
CallbackContext, CallbackQueryHandler
|
||||
import logging
|
||||
|
||||
from tgbot.config import TOKEN
|
||||
from tgbot.shit.handlers import handle_xitter, handle_red_ebalo, handle_hentai
|
||||
from tgbot.shit.handlers import handle_xitter, handle_red_ebalo, handle_hentai, handle_cute_button
|
||||
from tgbot.shit.render import render_text_on_image, image_to_string
|
||||
from io import BytesIO
|
||||
|
||||
|
@ -12,6 +13,7 @@ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
await context.bot.send_message(chat_id=update.effective_chat.id,
|
||||
text='WE ARE A PARTY OF UTTER MADNESS, '
|
||||
|
@ -37,6 +39,20 @@ async def image2string(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||
await update.message.reply_text(s)
|
||||
|
||||
|
||||
async def callback_query_handler(update: Update, context: CallbackContext):
|
||||
query = update.callback_query
|
||||
|
||||
if query.data == "show_cute_popup":
|
||||
await context.bot.answer_callback_query(
|
||||
callback_query_id=query.id,
|
||||
text="Hey! This button is for you! Thank you for clicking it, you are awesome!",
|
||||
show_alert=True
|
||||
)
|
||||
|
||||
else:
|
||||
await query.answer()
|
||||
|
||||
|
||||
async def handle_inline(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
query = update.inline_query.query
|
||||
if not query:
|
||||
|
@ -50,6 +66,10 @@ async def handle_inline(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||
await handle_hentai(update, context)
|
||||
return
|
||||
|
||||
if query.startswith("button!"):
|
||||
await handle_cute_button(update, context)
|
||||
return
|
||||
|
||||
await handle_red_ebalo(update, context)
|
||||
|
||||
|
||||
|
@ -64,6 +84,7 @@ def main():
|
|||
application.add_handler(MessageHandler(filters.PHOTO, image2string))
|
||||
application.add_handler(picture_handler)
|
||||
application.add_handler(InlineQueryHandler(handle_inline))
|
||||
application.add_handler(CallbackQueryHandler(callback_query_handler))
|
||||
|
||||
application.run_polling()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue