Python电报机器人如何通过url发送InlineKeyboard
试图发送带有回拨键Bord的邮件,但效果不佳。给我打电话Python电报机器人如何通过url发送InlineKeyboard,python,telegram,telegram-bot,python-telegram-bot,Python,Telegram,Telegram Bot,Python Telegram Bot,试图发送带有回拨键Bord的邮件,但效果不佳。给我打电话 TypeError: must be str, not ReplyKeyboardMarkup 找不到任何正确的例子 keyboard = [[InlineKeyboardButton("Выполнено", callback_data='Done')], [InlineKeyboardButton("MAC", callback_data='MAC'), Inline
TypeError: must be str, not ReplyKeyboardMarkup
找不到任何正确的例子
keyboard = [[InlineKeyboardButton("Выполнено", callback_data='Done')],
[InlineKeyboardButton("MAC", callback_data='MAC'),
InlineKeyboardButton("Phone", callback_data='Phone'),
InlineKeyboardButton("История", callback_data='History')]]
reply_markup = ReplyKeyboardMarkup(keyboard)
requests.post(url='https://api.telegram.org/bot{blah}/'
'sendMessage?chat_id=' + str(query.message.chat_id) + '&text="TEST"&reply_markup=' + reply_markup)
首先,您应该使用
InlineKeyboardMarkup
而不是ReplyKeyboardMarkup
来创建由InlineKeyboardButton
s组成的标记对象
然后,您可能应该简单地使用bot
对象,通过bot.send\u message(query.message.chat\u id,'TEST',reply\u markup=reply\u markup)
发送消息
最后,如果确实需要使用请求
执行手动HTTP请求,则应在请求.post()的数据中提供参数
import json
import requests
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
keyboard = [[InlineKeyboardButton("Выполнено", callback_data='Done')],
[InlineKeyboardButton("MAC", callback_data='MAC'),
InlineKeyboardButton("Phone", callback_data='Phone'),
InlineKeyboardButton("История", callback_data='History')]]
reply_markup = InlineKeyboardMarkup(keyboard)
data = {"chat_id": query.message.chat_id,
"text": "TEST",
"reply_markup": json.dumps(reply_markup.to_dict())}
requests.post(url='https://api.telegram.org/bot{blah}/sendMessage', data=data)