lukefx / hubot-telegram

Hubot adapter for Telegram
MIT License
160 stars 42 forks source link

Add callback query handler #60

Closed jazarja closed 4 years ago

wgcv commented 5 years ago

How do you get the callback from hubot? robot.answerCallbackQuery ? The data of the CallbackQuery is the message so you can make something like

// {inline_keyboard: [[ {"text": "Yes", "callback_data":'/yes ' }}
robot.respond(/yes/i, msg => {
console.log("The user says YES");
})
wgcv commented 5 years ago

You need to add if req.body.message || req.body.callback_query in telegram.coffee to support webhook

Like this:

     if @webhook

      endpoint = @webhook + '/' + @token
      @robot.logger.debug 'Listening on ' + endpoint

      @api.invoke 'setWebHook', {url: endpoint}, (err, result) ->
        if (err)
          self.emit 'error', err

      @robot.router.post "/" + @token, (req, res) =>
        console.log(req.body)
        if req.body.message || req.body.callback_query
          self.handleUpdate req.body
        res.send 'OK'
lukefx commented 4 years ago

@jazarja @wgcv Hi guys, sorry for the super late reply but... during the quarantine I rewrote the adapter completely in typescript. It should also address this case... do you mind to check the other PR #72 ? Thx