我有一个电报机器人,应该在/faq
命令和每个/faq
键盘选项上显示keyboard1以可视化一些文本(文本尚未添加)。>>
这是我正在创建的第一个机器人,并且存在一些问题:
/faq
处的keyboard1import telebot from tkinter import * from telegram.ext import Updater from telegram.ext import CommandHandler, CallbackQueryHandler from telegram import InlineKeyboardButton, InlineKeyboardMarkup bot = telebot.TeleBot('TOKEN') updater = Updater('TOKEN', use_context=True) updater.dispatcher.add_handler(CommandHandler('start', ...)) @bot.message_handler(commands=['help','start']) def send_welcome(message): if message.text == "/start": updater.send_message(message.chat.id,'Some welcome text') elif message.text == "/help": updater.send_message(message.chat.id, 'list of all commands') elif message.text == "/lastin": updater.send_message(message.chat.id, 'some text') def build_menu(buttons, n_cols, header_buttons=None, footer_buttons=None): menu = [buttons[i:i + n_cols] for i in range(0, len(buttons), n_cols)] if header_buttons: menu.insert(0, [header_buttons]) if footer_buttons: menu.append([footer_buttons]) return menu keyboard1 = [[InlineKeyboardButton('Question 1', callback_data='q1')], [InlineKeyboardButton('Question 2', callback_data='q2')], [InlineKeyboardButton('Question 3', callback_data='q3')], [InlineKeyboardButton('Question 4', callback_data='q4')]] reply_markup = InlineKeyboardMarkup(build_menu(keyboard1, n_cols=2)) @bot.message_handler(content_types=['text']) def send_text(message): if message.text == "/faq": bot.send_message(message.chat.id, text = 'FAQ', reply_markup = reply_markup) elif message.text == "/lastin": bot.send_photo(message.chat.id, photo='https://telegram.org/img/t_logo.png') updater.start_polling()
我有一个电报自动程序,应该在/ faq命令和每个/ faq键盘选项上显示keyboard1at以使某些文本可视化(该文本尚未添加)。这是我创建的第一个机器人,...
您似乎同时使用python-telegram-bot和telebot,这可能会引起问题。