Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on photo sending (400) #32

Closed
alexandrov-va opened this issue Jan 13, 2016 · 8 comments
Closed

Error on photo sending (400) #32

alexandrov-va opened this issue Jan 13, 2016 · 8 comments

Comments

@alexandrov-va
Copy link

My bot can't send a photo.

#initialization above
image_file = File.new('selection.png')
p "BeforeBot"
Telegram::Bot::Client.run(token) do |bot|
  bot.listen do |message|
    case message.text
    when '/fetch'
      p "BeforeResponse"
      bot.api.send_photo(chat_id: message.chat.id, photo: image_file)
      p "AfterResponse"
    end
  end
end
p "AfterBot"

It sticks on "BeforeResponse" stage. Then after 1-2 minutes console says:

/home/vova/.rvm/gems/ruby-2.2.1/gems/telegram-bot-ruby-0.4.0/lib/telegram/bot/api.rb:49:in `call': Telegram API has returned the error. (ok: "false", error_code: "400", description: "[Error]: Bad Request: Wrong persistent file_id specified: contains wrong characters or have wrong length"(Telegram::Bot::Exceptions::ResponseError)

@hmage
Copy link

hmage commented Jan 13, 2016

Same here. Sending photos does not work anymore. This happened after updating all gems.

Output of bundle show below:

$ bundle show
Gems included by the bundle:
  * axiom-types (0.1.1)
  * bundler (1.7.4)
  * coercible (1.0.0)
  * descendants_tracker (0.0.4)
  * equalizer (0.0.11)
  * gene_pool (1.4.1)
  * httmultiparty (0.3.16)
  * httparty (0.13.7)
  * ice_nine (0.11.1)
  * json (1.8.1)
  * mimemagic (0.3.1)
  * multi_xml (0.5.5)
  * multipart-post (2.0.0)
  * persistent_http (1.0.6)
  * persistent_httparty (0.1.2)
  * telegram-bot-ruby (0.4.0)
  * thread_safe (0.3.5)
  * virtus (1.0.5)

@markkuit
Copy link

Same here. I'm getting a different error but it happens when sending photo/documents.

/usr/local/share/gems/gems/persistent_http-1.0.6/lib/persistent_http.rb:335:in rescue in block in request': too many connection resets (due to end of file reached - EOFError)`

Every gem is up-to-date.

EDIT: just to be sure, same behavior happens with example code and on two different machines on two far away networks.

@zeracode
Copy link

I solved the problem for myself (telegram-bot-ruby 0.4.0) as follows:

class Telegram::Bot::Api
  private 
  def jsonify_inline_query_results(value)
    return value unless value.class == Array
    return value unless Array(value).all? { |i| INLINE_QUERY_RESULT_TYPES.include?(i.class) }
    value.map { |i| i.to_h.select { |_, v| v } }.to_json
  end
end

@atipugin
Copy link
Owner

@zeracode yeah, the issue was exactly here, thanks. I've released 0.4.1 with fix. Please update the gem.

@AbdullahAs
Copy link

Same issue here, I have v0.5.2

@atipugin
Copy link
Owner

Please show your code.

@AbdullahAs
Copy link

AbdullahAs commented May 25, 2016

Alright after looking for other closed issue it appears that we have to use now the Faraday::UploadIO.new instead of File.new which caused the issue in a code that was running just fine before.
Maybe it would be a good idea if this change was highlighted with few details in the changelog. Thanks.

@atipugin
Copy link
Owner

It is highlighted in README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants