Telegram bot api 自定义键盘消息

Telegram bot api custom keyboard message

我在 php 中安装了电报机器人,我展示了自定义键盘正在执行的操作:

$replyMarkup = array(
      'keyboard' => array(
           array('/help')
       )
);

$keyboard = json_encode($replyMarkup)

$this->client->request('POST', 'sendmessage', ['query' => ['chat_id' => $chatId, 'text' => $text, 'reply_markup' => $keyboard]]);

一切正常。
我的问题是:有没有办法将键盘命令映射到不同的消息?
所以在这种情况下,我想显示显示 "Help" 的自定义键盘,然后单击发送 /help.

谢谢。

目前,自定义键盘按钮只是消息的模板,因此 "No, it's not possible"。

使用InlineKeyboardMarkup可以解决这个问题。

C# 的基本用法

   public static InlineKeyboardMarkup TestInlineKeyboard { get; } = new InlineKeyboardMarkup           
    {
        InlineKeyboard = new []{new[] {new InlineKeyboardButton("Text1","Data1"),    
                                       new InlineKeyboardButton("text1","data2")} }
    };    

where "Text1" and "text1" is captions on inline buttons, "Data1" and "data2" is CallbackQuery text that your bot will recieve when user clicks inline button. Note that bot not send any message to user when he clicks inline button. If you need to send any message at that moment - you can do that programmatically.
Warning: Inline keyboards are currently being tested and are not available in channels yet. For now, feel free to use them in one-on-one chats or groups. but very good to know.

取自