Telegram Bot:自定义键盘发送代码

Telegram Bot: Custom Keyboard to send Codes

当我检查 here 时,电报中的 KeyboardButton 对象没有任何内容,例如 tagdata 字段。我的机器人键盘有这个实现:

$keyboardArray = array('Hello', 'Hi');
apiRequestJson("sendMessage", array('chat_id' => $chat_id, "text" => 'Hello', 'reply_markup' => array(
  'keyboard' => array($keyboardArray),
  'one_time_keyboard' => true,
  'resize_keyboard' => true)));

当前正在按下键盘按钮,将按钮标签发送到我的机器人。 我想知道电报键盘是否有任何选项,除了键盘按钮的标签外,它还可以向机器人发送特殊消息?例如,当我按下 hello 时它会发送 100,当我按下 Hi 按钮时它会发送 200。

不,不可能,这些键盘只能发送自己的标签。可能的是 InlineKeyboards (see this). There you can specify callback_data, which is given to your server when the key is pressed. You could also specify a URL to be opened on button click. See documentation for InlineKeyboardButton here.