Search code examples
python-telegram-bot

python-telegram-bot keyboard doesn't appear


I'm trying to make a bot for channel management and the keyboard (channel_markup in the code) for the channel selection doesn't appear. Now this keyboard is hard coded but later I want to introduce a used-based keyboard for channel.

    from telegram import ReplyKeyboardMarkup
    from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, RegexHandler, ConversationHandler)
    from Post import Post

MENU, CHANNEL = range(2) menu_markup = ReplyKeyboardMarkup([['POST', 'HTML']], one_time_keyboard=True, resize_keyboard=True) def error(update, context): """Log Errors caused by Updates.""" logger.warning('Update "%s" caused error "%s"', update, error) def start(bot, update, user_data): reply_text = 'Hi!' update.message.reply_text(reply_text, reply_markup=menu_markup) return MENU def new_post(bot, update, user_data): user_data['post'] = Post() channel_markup = ReplyKeyboardMarkup([['Test1', 'Test2']], one_time_keyboard=True, resize_keyboard=True) update.message.reply_text(text="Select channel", replyMarkup=channel_markup) return CHANNEL def channel_choice(bot, update, user_data): channel = update.message.text user_data['post'].channel = channel update.message.reply_text('Hi', reply_markup=menu_markup) return MENU def test_bot(args): pass def main(): updater = Updater("TOKEN") dp = updater.dispatcher conv_handler = ConversationHandler( entry_points=[CommandHandler('start', start, pass_user_data=True)], states={ MENU: [RegexHandler('^POST$', new_post, pass_user_data=True)], CHANNEL: [RegexHandler('^Test1$', channel_choice, pass_user_data=True)] }, fallbacks=[RegexHandler('^fallbacks$', test_bot)]) dp.add_handler(conv_handler) # log all errors dp.add_error_handler(error) # Start the Bot updater.start_polling() # Run the bot until you press Ctrl-C or the process receives SIGINT, # SIGTERM or SIGABRT. This should be used most of the time, since # start_polling() is non-blocking and will stop the bot gracefully. updater.idle()


Solution

  • Replace replyMarkup with reply_markup.

    enter image description here