atipugin / telegram-bot-ruby

Ruby wrapper for Telegram's Bot API
https://core.telegram.org/bots/api
Do What The F*ck You Want To Public License
1.35k stars 218 forks source link

Faraday::Request (Faraday::Error) #241

Closed natandiasm closed 2 years ago

natandiasm commented 2 years ago

My code:

require 'telegram/bot'

token = 'real_token'

Telegram::Bot::Client.run(token) do |bot| bot.listen do |message| case message.text when '/start' bot.api.send_message(chat_id: message.chat.id, text: "Hello, #{message.from.first_name}") when '/stop' bot.api.send_message(chat_id: message.chat.id, text: "Bye, #{message.from.first_name}") end end end

error:

/usr/local/lib/ruby/gems/3.0.0/gems/faraday-2.0.0/lib/faraday/middleware_registry.rb:57:in lookup_middleware': :multipart is not registered on Faraday::Request (Faraday::Error) from /usr/local/lib/ruby/gems/3.0.0/gems/faraday-2.0.0/lib/faraday/rack_builder.rb:242:inuse_symbol' from /usr/local/lib/ruby/gems/3.0.0/gems/faraday-2.0.0/lib/faraday/rack_builder.rb:103:in request' from /usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0/forwardable.rb:238:inrequest' from /usr/local/lib/ruby/gems/3.0.0/gems/telegram-bot-ruby-0.16.0/lib/telegram/bot/api.rb:86:in block in conn' from /usr/local/lib/ruby/gems/3.0.0/gems/faraday-2.0.0/lib/faraday/connection.rb:91:ininitialize' from /usr/local/lib/ruby/gems/3.0.0/gems/faraday-2.0.0/lib/faraday.rb:94:in new' from /usr/local/lib/ruby/gems/3.0.0/gems/faraday-2.0.0/lib/faraday.rb:94:innew' from /usr/local/lib/ruby/gems/3.0.0/gems/telegram-bot-ruby-0.16.0/lib/telegram/bot/api.rb:85:in conn' from /usr/local/lib/ruby/gems/3.0.0/gems/telegram-bot-ruby-0.16.0/lib/telegram/bot/api.rb:49:incall' from /usr/local/lib/ruby/gems/3.0.0/gems/telegram-bot-ruby-0.16.0/lib/telegram/bot/api.rb:37:in method_missing' from /usr/local/lib/ruby/gems/3.0.0/gems/telegram-bot-ruby-0.16.0/lib/telegram/bot/client.rb:30:infetch_updates' from /usr/local/lib/ruby/gems/3.0.0/gems/telegram-bot-ruby-0.16.0/lib/telegram/bot/client.rb:25:in listen' from main.rb:6:inblock in

' from /usr/local/lib/ruby/gems/3.0.0/gems/telegram-bot-ruby-0.16.0/lib/telegram/bot/client.rb:18:in run' from /usr/local/lib/ruby/gems/3.0.0/gems/telegram-bot-ruby-0.16.0/lib/telegram/bot/client.rb:8:inrun' from main.rb:5:in `
'

L-Eugene commented 2 years ago

Looks like multipart middleware was removed from Faraday 2.0.0 version (released today). You can avoid this error by using 1.8 version (add next line to your Gemfile: gem "faraday", "~> 1.8.0").

natandiasm commented 2 years ago

this work, thks.

ShockwaveNN commented 2 years ago

But I think this issue should not be closed and telegram-bot-ruby should be adapted to latest stable version of faraday?

natandiasm commented 2 years ago

yes I agree with you