douju9272 2019-05-21 22:46
浏览 283

有没有办法在电报机器人中发送带有消息的回叫按钮?

I am making telegram bot with https://github.com/irazasyed/telegram-bot-sdk . Bot sends pictures and videos, however, I want to send 2 buttons like in this image for callbacks.

sd

I have tried keyboards, however, they are not good, as my bot can send 10-15 images simultaneously and the user cannot reply one-by-one. If it is like in the photo, the user will be able to update information any time.

$keyboard = [
    ['7', '8', '9'],
    ['4', '5', '6'],
    ['1', '2', '3'],
    ['0']
];

$reply_markup = $this->telegram->replyKeyboardMarkup([
    'keyboard' => $keyboard,
    'resize_keyboard' => true,
    'one_time_keyboard' => true
]);

How can I do that? Thanks in advance!

  • 写回答

1条回答 默认 最新

  • doulu3865 2019-06-25 07:22
    关注

    change $keyboard to:

    $keyboard = array('inline_keyboard'=>array(
    array(
        array('text'=>'Cancel','callback_data'=>'key=cancel'),
        array('text'=>'Download','callback_data'=>'key=download')
    )));
    

    and change keyboard to inline_keyboard

    评论

报告相同问题?

悬赏问题

  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗