Naltox / telegram-node-bot

Node module for creating Telegram bots.
MIT License
723 stars 143 forks source link

answerInlineQuery not working? #14

Closed Montoya closed 8 years ago

Montoya commented 8 years ago

Hi, I'm trying to do something very simple with inlineMode and not getting any results...

Here's my code:

tg.inlineMode(($) => {
  var msg = $.query
  tg.answerInlineQuery($.id, [{
    text: msg
  }])
})

I already registered inlineMode with BotFather, by the way. When I try using inlineMode the spinner works for a while and then nothing happens. Not seeing any errors in the logs either...

Naltox commented 8 years ago

Hey!

[{ text: msg }]

is not valid, you can find answer types here: https://core.telegram.org/bots/api#inlinequeryresult

For your example you can use this:

tg.inlineMode(($) => { 
    var msg = $.query
    tg.answerInlineQuery($.id, [{
        type: "article",
        title: msg,
        input_message_content: {
            message_text: msg
        }
    }]) 
})
Montoya commented 8 years ago

Thank you! That fixed it. It works perfectly now :)