I am creating a telegram bot in python (using this pyTelegramBotAPI framework ). And I ran into a problem with user input. I need to save user input (this can be any text) after a specific bot message. For instance:
Bot: - Describe your problem.
User: - Our computer is not working.
Then I need to save this text “Our computer is not working” with some variable and go to the next step. Here is my code:
import telebot
import constants
from telebot import types
bot = telebot.TeleBot(constants.token)
@bot.message_handler(commands=['start'])
def handle_start(message):
keyboard = types.InlineKeyboardMarkup()
callback_button = types.InlineKeyboardButton(text="Help me!", callback_data="start")
keyboard.add(callback_button)
bot.send_message(message.chat.id, "Welcome I am helper bot!", reply_markup=keyboard)
@bot.inline_handler(lambda query: len(query.query) > 0)
def query_text(query):
kb = types.InlineKeyboardMarkup()
kb.add(types.InlineKeyboardButton(text="Help me!", callback_data="start"))
results = []
single_msg = types.InlineQueryResultArticle(
id="1", title="Press me",
input_message_content=types.InputTextMessageContent(message_text="Welcome I am helper bot!"),
reply_markup=kb
)
results.append(single_msg)
bot.answer_inline_query(query.id, results)
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
if call.message:
if call.data == "start":
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Please describe your problem.")
I have an idea using message_id in an instruction, but I still cannot implement it. How can i solve this? Any ideas? Thank.