我一直在制作一个机器人,我用于filters=Filters.privatestart_command 然后我在 a 中使用它MessageHandler,它是代码: dp.add_handler(CommandHandler('start', start_command, filters=Filters.private)) dp.add_handler(MessageHandler(Filters) .private, start_keyboard_answers))
它工作得很好,但问题是我需要在第二个过滤器内制作另一个过滤器,代码应该是这样的:
dp.add_handler(CommandHandler('start', start_command, filters=Filters.private)) dp.add_handler(MessageHandler(Filters.private, start_keyboard_answers, filters=Filters.private)) dp.add_handler(MessageHandler(Filters.private, start_keyboard_answers) )
但这是不可能的,我在第二行有两个过滤器,我该如何处理?如果你想知道我在做什么,我会把整个项目放在这里(我在第二个键盘之后寻找其他按钮,就像我对第一个和第二个键盘所做的一样):
from telegram.ext import Updater, Filters, CommandHandler, MessageHandler
from telegram import ReplyKeyboardMarkup
BOT_TOKEN = ''
def start_command(update, context):
chat_id = update.message.chat.id
context.bot.send_message(
chat_id=chat_id,
text='Hey, welcome to Chocolate Coffee!'
)
keyboard = [
['Make an Order']
]
context.bot.send_message(
chat_id=chat_id,
text='How can I help you?',
reply_markup=ReplyKeyboardMarkup(keyboard, one_time_keyboard=True, resize_keyboard=True)
)
def start_keyboard_answers(update, context):
message_text = str(update.message.text)
if message_text.lower() == …Run Code Online (Sandbox Code Playgroud)