【发布时间】:2021-12-08 03:26:47
【问题描述】:
我正在使用 Python-Telegram-Bot 包。我的电报机器人无法接收状态为FIRST 的消息。发送我的机器人/start 后,我会收到start_command 中所示的短信提示。但是,在向机器人发送 url 后,机器人无法接收消息,如我的消息右下角的“单勾”所示。
# Stages
FIRST, SECOND = range(2)
def start_command(update: Update, context: CallbackContext):
update.message.reply_text("""
To use:
1. Send the google sheets URL and sheet name to this telegram bot in the following format:
your_google_sheets_url (your_sheet_name)
""")
global user_id
user_id = update.message.from_user['id']
return FIRST
def select(update: Update, context: CallbackContext):
if update.message.text:
user_input = update.message.text
update.message.reply_text('I have received your Google Sheets!')
reply_markup = InlineKeyboardMarkup(build_menu(button_list, n_cols=1))
update.message.reply_text('Please choose the headers:', reply_markup=reply_markup)
return SECOND
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start_command))
conv_handler = ConversationHandler(
entry_points=[CommandHandler('start', start_command)],
states={
FIRST: [MessageHandler(Filters.text, select)],
SECOND: [CallbackQueryHandler(display)],
},
fallbacks=[CommandHandler('cancel', cancel)],
)
dp.add_handler(conv_handler)
【问题讨论】:
-
您需要首先澄清一些事情,例如您正在使用哪个 telegram Bot 包,然后添加您的错误以及更多关于问题的上下文。
-
@SumitJaiswal 谢谢。
标签: telegram telegram-bot python-telegram-bot