Naltox / telegram-node-bot

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

Fix typo about Id property name in InlineQueryResult #120

Closed aguiraf closed 7 years ago

aguiraf commented 7 years ago

it should be "id", not "_id"

Naltox commented 7 years ago

@aguiraf Actually you are wrong, InlineQueryResult dont have any getter for id property

aguiraf commented 7 years ago

Hi @Naltox, let me try to explain better:

here in line 66 https://github.com/Naltox/telegram-node-bot/blob/master/lib/mvc/InlineScope.js#L66 you are providing a random value for id, in the event the api-user didn't provided himself; but you are assigning it to "_id" , I assume it should be "id".

Actually, when my bot replies to an inlineQuery without providing explicit id values to the InlineQueryResults, the response is sent with an unknown _id but without the required id property and is discarded by Telegram api. Applying my patch it works as expected.

hope have been clearer and not have done a big mistake; if so, sorry

Naltox commented 7 years ago

@aguiraf Hey, as you can see result is instatce of InlineQueryResult, InlineQueryResult have _id property and id getter for that property, but there is no setter for _id so you cant do .id = 123

aguiraf commented 7 years ago

ok, there's no setter, so perhaps the getter isn't working properly; again, the underlying problem is that the result is being sent without id; my logs:

[warn]   
Api error: Body: { ok: false,
  error_code: 400,
  description: 'Bad Request: Can\'t find field "id"' }

my code:

class MyInlineController extends TelegramBaseInlineQueryController {
  handle($) {
            $.answer([{
                type: "article",
                title: 'article1',    
                input_message_content: {message_text: 'text article1' }
              },
              {
                type: "article",
                title: 'article2',
                input_message_content: {message_text: 'text article2' }
              }
            ],
            {cache_time:10}
            )
    }