0

I work with python telegram bot version more than 20. I'm trying to make when I choose option 1 it would send a message with my function and when i choose for example option 2 it would return other function.

from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import 

async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
keyboard = [
[
InlineKeyboardButton("Option 1", callback_data="1"),
InlineKeyboardButton("Option 2", callback_data="2"),
],
[InlineKeyboardButton("Option 3", callback_data="3"),]
]

    reply_markup1 = InlineKeyboardMarkup(keyboard)

    await update.message.reply_text('Hello!')
    await update.message.reply_text('Choose one of options',reply_markup=reply_markup1)

async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text("how can i help you")

async def button(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
query = update.callback_query
await query.answer()
await query.edit_message_text(text=f'Selected option: {query.data}')
if query.data == "1":
    await query.message.reply_text(help_command)

It would look something like this in telegram:

Hello!

Choose one of options

(option 1)(option 2) ( option 3 )

[i select option 1]

how can i help you

Here's what error i get:

telegram.error.NetworkError: Unknown error in HTTP implementation: TypeError('Object of type function is not JSON serializable')

I don't remeber what i tried but i also got this error before:

AttributeError: 'NoneType' object has no attribute 'reply_text'

I saw a similar question but there is still no answer

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.