【问题标题】:Telegram bot Keyboard not working电报机器人键盘不起作用
【发布时间】:2017-08-01 04:17:11
【问题描述】:

我在 GAS 上创建了 Telegram 机器人,但我的自定义键盘无法正常工作。 我的功能发送消息如下。 谢谢。

function sendText(text,chatId){

var 有效负载 = { '方法':'发送消息', 'chat_id':字符串(chatId), '文本':文本, 'parse_mode': 'HTML' }

    var data = {
      "method": "post",
      "payload": payload,
      "reply_markup": JSON.stringify({
        'keyboard': [['Store username']],
        'resize_keyboard':true,
        'one_time_keyboard': true
      })
    }

    // Replace with your token
    var API_TOKEN = '**********************';
    UrlFetchApp.fetch('https://api.telegram.org/bot' + API_TOKEN + '/', data);

}

【问题讨论】:

    标签: google-apps-script telegram


    【解决方案1】:

    根据电报官方api,您的键盘格式必须是:

    按钮行数组,每行由一个 KeyboardButton 对象数组表示

    例如:

    "reply_markup": JSON.stringify({
        'keyboard': [
                     [ ['row1-col1'] ],//row 1
                     [ ['row2-col1'],['row2-col2'] ] //row 2
                     ],
        'resize_keyboard':true,
        'one_time_keyboard': true
      })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-23
      • 2016-03-22
      • 2020-10-08
      • 1970-01-01
      • 2018-09-25
      • 2022-10-05
      • 1970-01-01
      • 2022-07-02
      相关资源
      最近更新 更多