Bug: answerInlineQuery error
AliMD opened this issue · 4 comments
AliMD commented
This is my code for test answerInlineQuery
:
onInlineQuery = (query) => {
console.log("===> onInlineQuery: ", stringify(query));
var
post = data.posts['test'].messages[0],
results = [{
type: "photo",
id: 1,
photo_file_id: post.photo.id,
title: "title1",
description: "description1",
caption: "caption1",
input_message_content: {
message_text: "message_text1"
}
}]
;
console.log("results: " + stringify(results));
bot.answerInlineQuery({
inline_query_id: query.id,
results: results,
cache_time: 1,
is_personal: false,
next_offset: ""
}, (err, data) => {
console.log("answerInlineQueryCallback: " + stringify({err: err, query: query}));
})
.then((data) => {
console.log("answerInlineQuerySuccess: " + stringify(data))
})
.catch((err) => {
console.log("answerInlineQueryError: " + stringify({err: err, query: query}));
})
;
}
And this is console error
===> onInlineQuery: {
"id": "250780611822216560",
"from": {
"id": 58389411,
"first_name": "Ali",
"last_name": "Mihandoost",
"username": "Al1MD"
},
"query": "",
"offset": ""
}
results: [
{
"type": "photo",
"id": 1,
"photo_file_id": "AgADBAADQagxG3Y-EwLpdVrRB_1FdXWoYzAABII7tf8pCsFbQ1gBAAEC",
"title": "title1",
"description": "description1",
"caption": "caption1",
"input_message_content": {
"message_text": "message_text1"
}
}
]
[TelegramBot]: Failed to get updates from Telegram servers
_http_outgoing.js:443
throw new TypeError('first argument must be a string or Buffer');
^
TypeError: first argument must be a string or Buffer
at ClientRequest.OutgoingMessage.write (_http_outgoing.js:443:11)
at Request.write (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/request/request.js:1385:25)
at FormData.ondata (stream.js:31:26)
at emitOne (events.js:90:13)
at FormData.emit (events.js:182:7)
at FormData.CombinedStream.write (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/combined-stream/lib/combined_stream.js:118:8)
at FormData.CombinedStream._pipeNext (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/combined-stream/lib/combined_stream.js:106:8)
at FormData.CombinedStream._getNext (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/combined-stream/lib/combined_stream.js:79:10)
at FormData.CombinedStream._pipeNext (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/combined-stream/lib/combined_stream.js:107:8)
at FormData.CombinedStream._getNext (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/combined-stream/lib/combined_stream.js:79:10)
at FormData.CombinedStream._pipeNext (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/combined-stream/lib/combined_stream.js:107:8)
at FormData.<anonymous> (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/combined-stream/lib/combined_stream.js:91:10)
at FormData.<anonymous> (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/form-data/lib/form_data.js:246:5)
at FormData.CombinedStream._getNext (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/combined-stream/lib/combined_stream.js:84:3)
at FormData.CombinedStream._pipeNext (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/combined-stream/lib/combined_stream.js:107:8)
at FormData.CombinedStream._getNext (/Volumes/Repositories/metrofrq_bot/node_modules/telegram-bot-api/node_modules/combined-stream/lib/combined_stream.js:79:10)
AliMD commented
mast commented
@AliMD cant verify it right now, i'm travelling.
Just as an idea, can you try to stringify 'results' before passing it to bot.answerInlineQuery?
AliMD commented
Not worked.
I double check the source, it stringifyed!
AliMD commented
Problem solved finally.
All args must be converted to string.
is_personal
is not booealn ist string!
I will make a PR for fix in all api's