I've been trying to create a telegram bot. I coded in Python, following is what I did so far.
import logging
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
@app.route("/")
def start(bot, update):
help_text = 'text'
keyboard = [[InlineKeyboardButton("Button_1", url=('url'))]]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text(help_text, reply_markup=reply_markup)
def button(bot, update):
query = update.callback_query
bot.edit_message_text(text="Selected option: {}".format(query.data),
chat_id=query.message.chat_id,
message_id=query.message.message_id)
def error(bot, update, error):
logger.warning('Update "%s" caused error "%s"', update, error)
def main():
updater = Updater(<TOKEN>)
updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CallbackQueryHandler(button))
updater.dispatcher.add_error_handler(error)
updater.start_polling()
updater.idle()
if __name__ == "__main__":
main()
I've been trying to implement user input when Button_1 is clicked i.e., on clicking Button_1 the user should receive a message with the input field (eg: please enter your favorite song). Any pointers or suggestions?