from telegram.ext import CommandHandler, MessageHandler, Filters
from telegram import ReplyKeyboardMarkup, InlineKeyboardMarkup,
InlineKeyboardButton
from django_telegrambot.apps import DjangoTelegramBot
def me(bot, update):
keyboard = [
[
InlineKeyboardButton("Option 1", callback_data='1'),
InlineKeyboardButton("Option 2", callback_data='2')
],
[ InlineKeyboardButton("Option 3", callback_data='3')
]
]
reply_markup = InlineKeyboardMarkup(keyboard)
# THIS IS PRINTING TEXT BUT Not keyboard!
update.message.reply_text('Please choose:',
reply_markup=reply_markup)
# Again sent text
bot.sendMessage(update.message.chat_id, text='text works' ,reply_markup=markup)
这个问题我已经坚持了3天。
答案 0 :(得分:0)
这对我有用
def echo(bot, update):
keyboard = [
[
InlineKeyboardButton("Option 1", callback_data='1'),
InlineKeyboardButton("Option 2", callback_data='2')
],
[InlineKeyboardButton("Option 3", callback_data='3')
]
]
reply_markup = InlineKeyboardMarkup(keyboard)
bot.sendMessage(update.message.chat_id, text=update.message.text,reply_markup=reply_markup)
你似乎在reply_markup=markup
部分中犯了错误。