from telegram import Update
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
from telegram.ext import (
Application,
CommandHandler,
ContextTypes,
ConversationHandler,
MessageHandler,
filters,
)
app = ApplicationBuilder().token("TOKEN").build()
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text('Name')
async def name_add(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
name = update.message.text
print("Name:" ,name)
app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, start_last))
app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, name_add))
async def start_last(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text('age')
age = update.message.text
print(age)
app.add_handler(CommandHandler("start", start))
app.run_polling()
Hello I want to pull the messages written by the user. example bot:
user- /start
enter your bot-name
user- mike
bot- enetr your age
user- 18
bot - name: mike age:18
it will work like this, I get the name but it does not come out of the function. I can get the name but not the age because the name does not come out of the function I get