Closed objective-mj closed 8 years ago
Could you provide your code?
Gonna boil it down to avoid clutter.
This is my main.rb
Telegram::Bot::Client.run(token) do |bot| # line 15
bot.listen do |message| # line 121
case message
when Telegram::Bot::Types::InlineQuery
arr = ComicVine.make_call(message.query)
results = []
count = 0
arr.take(50).each do |char|
results << Telegram::Bot::Types::InlineQueryResultArticle
.new(id: count += 1,
title: char[0],
thumb_url: char[1],
description: char[2],
parse_mode: char[3],
message_text: char[4]
)
end
bot.api.answer_inline_query(inline_query_id: message.id, results: results) # line 135
end
end
end
And this is my ComicVine.rb
def self.make_call(query)
url = "SOME_URL"
url = URI.encode(url)
return (JSON.parse httpclient.get_content(url))['result'] # this call can be slow for large results
end
IMPORTANT NOTE: It is worth noticing that if I have a http call that takes only a couple of seconds, everything works fine. For example, I make an inline query with the text 'owl' and I have results showing without exceptions within 5 seconds. But if I make, say 'Avengers' there are more results from the api that I call and so it will take ~30 seconds before I am returning results. And then upon the bot.api.answer_inline_query method the exception happens
Ok, i've reproduced your error, and i have only one idea - inline query id is valid only for a limited period of time (about ~10 seconds). It's pretty reasonable because inline bots are supposed to be fast.
Anyway, i didn't find anything about it in official docs.
Hey I keep receiving this error when trying to make Inline work
And this is my stacktrace
With my own lines of code looking like this:
As far as I can see it has something to do with the getting update part. The query_id changes when new updates are gathered which means that request take are a bit slow will continue to be computed while the id changes.
EDIT: sorry for the close, reopen - was a mistake Now I have tried parsing an overwriting timeout var to the Client.run method like so:
But it doesn't seem to help.