eljojo / telegram_bot

A charismatic Ruby client for Telegram's Bot API
MIT License
298 stars 82 forks source link

uninitialized constant TelegramBot::ApiResponse::ResponseError #44

Open vpereira opened 6 years ago

vpereira commented 6 years ago

tried to access with

bot = TelegramBot.new token: MY_TOKEN
bot.get_updates(fail_silently: true)

and the traceback looks like:

Traceback (most recent call last):
        8: from /home/vpereira/.rvm/rubies/ruby-2.5.0/bin/irb:11:in `<main>'
        7: from (irb):5
        6: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:29:in `get_updates'
        5: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:83:in `get_last_messages'
        4: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:72:in `get_last_updates'
        3: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `request'
        2: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `new'
        1: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/api_response.rb:13:in `initialize'
NameError (uninitialized constant TelegramBot::ApiResponse::ResponseError)

gem installed:

telegram_bot (0.0.8)

eljojo commented 6 years ago

Hmmm... This sucks, I'll try to take a look tonight.

eljojo commented 6 years ago

@schwad wanna take this over?

vpereira commented 6 years ago

thank you. To reproduce it, just pass a wrong key to the bot.

eljojo commented 6 years ago

I think we might have forgotten to require https://github.com/eljojo/telegram_bot/blob/master/lib/telegram_bot/response_error.rb

If you wanna give it a shot it shouldn't be a hard PR to open.

Schwad commented 6 years ago

Hi @vpereira @eljojo ! 👋

Here's my replication, actually getting the telegram bot response error:

bot = TelegramBot.new token: 'totatgibberish'

bot.get_updates(fail_silently: true)

With result of:

TelegramBot::ResponseError: An error has occurred: {"ok"=>false, "error_code"=>404, "description"=>"Not Found"}
    from /Users/nickschwaderer/.rvm/gems/ruby-2.4.4/gems/telegram_bot-0.0.9/lib/telegram_bot/bot.rb:68:in `new'
    from /Users/nickschwaderer/.rvm/gems/ruby-2.4.4/gems/telegram_bot-0.0.9/lib/telegram_bot/bot.rb:68:in `request'
    from /Users/nickschwaderer/.rvm/gems/ruby-2.4.4/gems/telegram_bot-0.0.9/lib/telegram_bot/bot.rb:72:in `get_last_updates'
    from /Users/nickschwaderer/.rvm/gems/ruby-2.4.4/gems/telegram_bot-0.0.9/lib/telegram_bot/bot.rb:83:in `get_last_messages'
    from /Users/nickschwaderer/.rvm/gems/ruby-2.4.4/gems/telegram_bot-0.0.9/lib/telegram_bot/bot.rb:29:in `get_updates'
    from (irb):5
    from /Users/nickschwaderer/.rvm/rubies/ruby-2.4.4/bin/irb:11:in `<main>'

Which seems to me it is behaving as expected.

Maybe we need more information. This was tried against ruby-2.4.4, and I see you are on 2.5.0. If you like tomorrow I can run this same check against a different version, happy to do a deeper dive on the code if anyone else has some thoughts! 😄

vpereira commented 6 years ago

Hi @Schwad, you are right, running your reproducer, I get the same error as before.

note: ruby 2.5.0 from rvm.

2.5.0 :001 > require 'telegram_bot'
 => true 
2.5.0 :002 > bot = TelegramBot.new token: 'totatgibberish'
 => #<TelegramBot::Bot:0x00000000010e7710 @token="totatgibberish", @timeout=50, @offset=0, @logger=#<TelegramBot::NullLogger:0x00000000010e76e8>, @proxy=nil, @connection=#<Excon::Connection:10e7440 @data={:chunk_size=>1048576, :ciphers=>"ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS", :connect_timeout=>60, :debug_request=>false, :debug_response=>false, :headers=>{"User-Agent"=>"excon/0.62.0"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>false, :persistent=>true, :read_timeout=>60, :retry_limit=>4, :ssl_verify_peer=>true, :ssl_uri_schemes=>["https"], :stubs=>:global, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.62.0 (x86_64-linux) ruby/2.5.0", :write_timeout=>60, :host=>"api.telegram.org", :hostname=>"api.telegram.org", :path=>"/", :port=>443, :query=>nil, :scheme=>"https"} @socket_key="https://api.telegram.org:443" @_excon_sockets={3778120=>{}}>> 
2.5.0 :003 > 
2.5.0 :004 > bot.get_updates(fail_silently: true)
Traceback (most recent call last):
        8: from /home/vpereira/.rvm/rubies/ruby-2.5.0/bin/irb:11:in `<main>'
        7: from (irb):4
        6: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:29:in `get_updates'
        5: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:83:in `get_last_messages'
        4: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:72:in `get_last_updates'
        3: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `request'
        2: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `new'
        1: from /home/vpereira/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/api_response.rb:13:in `initialize'
NameError (uninitialized constant TelegramBot::ApiResponse::ResponseError)
2.5.0 :005 > 
eljojo commented 6 years ago

This comes to mind but I think it's a red-herring.

I think the key is that it's trying to look for TelegramBot::ApiResponse::ResponseError, and the correct constant name is TelegramBot::ResponseError, so maybe just being explicit about raising TelegramBot::ResponseError could be enough here: https://github.com/eljojo/telegram_bot/blob/b54549683e045f4b1bef422c8d9ecb5dad03ff5d/lib/telegram_bot/api_response.rb#L13-L14

edikbekir commented 6 years ago

Maybe I acted stupid, but I put the ResponseError class in ApiResponse class, and the problem was solved. @eljojo Thank you for pushing the problem

eljojo commented 6 years ago

@edikbekir I don't think that was stupid. I really wish to understand what's making this fail, though.

If someone wants to open-up a PR that fixes the problem I'd be happy to merge it, moving ResponseError inside ApiResponse is a valid alternative as well.

ZhKostev commented 6 years ago

@eljojo @edikbekir I've created PR to fix issue https://github.com/eljojo/telegram_bot/pull/45

Schwad commented 6 years ago

@eljojo since I didn't get the failure I'm gonna try this same again today with 2.5.1.

Schwad commented 6 years ago

This is my response on 2.5.0, which I think is expected (remember they reversed tracebacks here:

Traceback (most recent call last):
        6: from /Users/nickschwaderer/.rvm/rubies/ruby-2.5.0/bin/irb:11:in `<main>'
        5: from (irb):4
        4: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:29:in `get_updates'
        3: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:72:in `get_last_updates'
        2: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `request'
        1: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `new'
TelegramBot::ResponseError (An error has occurred: {"ok"=>false, "error_code"=>404, "description"=>"Not Found"})
Schwad commented 6 years ago

Completely full stack:

2.5.0 :002 > require 'telegram_bot'
 => true 
2.5.0 :003 > bot = TelegramBot.new token: 'totatgibberish'
 => #<TelegramBot::Bot:0x00007ff83da37ef0 @token="totatgibberish", @timeout=50, @offset=0, @logger=#<TelegramBot::NullLogger:0x00007ff83da37ec8>, @proxy=nil, @connection=#<Excon::Connection:7ff83da37c20 @data={:chunk_size=>1048576, :ciphers=>"ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS", :connect_timeout=>60, :debug_request=>false, :debug_response=>false, :headers=>{"User-Agent"=>"excon/0.62.0"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>false, :persistent=>true, :read_timeout=>60, :retry_limit=>4, :ssl_verify_peer=>true, :ssl_uri_schemes=>["https"], :stubs=>:global, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.62.0 (x86_64-darwin16) ruby/2.5.0", :write_timeout=>60, :host=>"api.telegram.org", :hostname=>"api.telegram.org", :path=>"/", :port=>443, :query=>nil, :scheme=>"https"} @socket_key="https://api.telegram.org:443" @_excon_sockets={70352080465640=>{}}>> 
2.5.0 :004 > bot.get_updates(fail_silently: true)
Traceback (most recent call last):
        6: from /Users/nickschwaderer/.rvm/rubies/ruby-2.5.0/bin/irb:11:in `<main>'
        5: from (irb):4
        4: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:29:in `get_updates'
        3: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:72:in `get_last_updates'
        2: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `request'
        1: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `new'
TelegramBot::ResponseError (An error has occurred: {"ok"=>false, "error_code"=>404, "description"=>"Not Found"})
Schwad commented 6 years ago

Okay, going a bit creative here. Thought maybe there was a break on original 0.0.8 push that was resolved in later commits (thinking maybe we need another bump) so ran against that specific commit and still passing:

2.5.0 :002 > gem 'telegram_bot', git: 'https://github.com/eljojo/telegram_bot.git', ref: '69a26e3fc224afef3af4df8dbb249bc6d7dd6b99'
 => true 
2.5.0 :003 > require 'telegram_bot'
 => true 
2.5.0 :004 > bot = TelegramBot.new token: 'totatgibberish'
 => #<TelegramBot::Bot:0x00007fee3e102258 @token="totatgibberish", @timeout=50, @offset=0, @logger=#<TelegramBot::NullLogger:0x00007fee3e102230>, @proxy=nil, @connection=#<Excon::Connection:7fee3e101f88 @data={:chunk_size=>1048576, :ciphers=>"ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS", :connect_timeout=>60, :debug_request=>false, :debug_response=>false, :headers=>{"User-Agent"=>"excon/0.62.0"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>false, :persistent=>true, :read_timeout=>60, :retry_limit=>4, :ssl_verify_peer=>true, :ssl_uri_schemes=>["https"], :stubs=>:global, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.62.0 (x86_64-darwin16) ruby/2.5.0", :write_timeout=>60, :host=>"api.telegram.org", :hostname=>"api.telegram.org", :path=>"/", :port=>443, :query=>nil, :scheme=>"https"} @socket_key="https://api.telegram.org:443" @_excon_sockets={70330605629160=>{}}>> 
2.5.0 :005 > bot.get_updates(fail_silently: true)
Traceback (most recent call last):
        6: from /Users/nickschwaderer/.rvm/rubies/ruby-2.5.0/bin/irb:11:in `<main>'
        5: from (irb):5
        4: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:29:in `get_updates'
        3: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:72:in `get_last_updates'
        2: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `request'
        1: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `new'
TelegramBot::ResponseError (An error has occurred: {"ok"=>false, "error_code"=>404, "description"=>"Not Found"})
Schwad commented 6 years ago

And ran same again against bleeding edge commit

2.5.0 :001 > gem 'telegram_bot', git: 'https://github.com/eljojo/telegram_bot.git', ref: 'b54549683e045f4b1bef422c8d9ecb5dad03ff5d'
 => true 
2.5.0 :002 > require 'telegram_bot'
 => true 
2.5.0 :004 > bot = TelegramBot.new token: 'totatgibberish'
 => #<TelegramBot::Bot:0x00007feda882a580 @token="totatgibberish", @timeout=50, @offset=0, @logger=#<TelegramBot::NullLogger:0x00007feda882a558>, @proxy=nil, @connection=#<Excon::Connection:7feda882a2b0 @data={:chunk_size=>1048576, :ciphers=>"ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS", :connect_timeout=>60, :debug_request=>false, :debug_response=>false, :headers=>{"User-Agent"=>"excon/0.62.0"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>false, :persistent=>true, :read_timeout=>60, :retry_limit=>4, :ssl_verify_peer=>true, :ssl_uri_schemes=>["https"], :stubs=>:global, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.62.0 (x86_64-darwin16) ruby/2.5.0", :write_timeout=>60, :host=>"api.telegram.org", :hostname=>"api.telegram.org", :path=>"/", :port=>443, :query=>nil, :scheme=>"https"} @socket_key="https://api.telegram.org:443" @_excon_sockets={70329359920840=>{}}>> 
2.5.0 :005 > bot.get_updates(fail_silently: true)
Traceback (most recent call last):
        6: from /Users/nickschwaderer/.rvm/rubies/ruby-2.5.0/bin/irb:11:in `<main>'
        5: from (irb):5
        4: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:29:in `get_updates'
        3: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:72:in `get_last_updates'
        2: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `request'
        1: from /Users/nickschwaderer/.rvm/gems/ruby-2.5.0/gems/telegram_bot-0.0.8/lib/telegram_bot/bot.rb:68:in `new'
TelegramBot::ResponseError (An error has occurred: {"ok"=>false, "error_code"=>404, "description"=>"Not Found"})
Schwad commented 6 years ago

My only thought at the minute is wondering if @vpereira have you tried nuking and reinstalling the gem? @eljojo may have more thoughts here I'll keep thinking on it and trying to replicate.

ZhKostev commented 6 years ago

@Schwad 404 stands for wrong token I have same in the beginning. Token is not just hash, but id as well. it should look like this number:token. Hope this will help

Schwad commented 6 years ago

Ruby: 2.4.4 Rails: 5.2.0

2.4.4 :001 > bot = TelegramBot.new token: 'totatgibberish'
 => #<TelegramBot::Bot:0x00007f98bbe1e2f8 @token="totatgibberish", @timeout=50, @offset=0, @logger=#<TelegramBot::NullLogger:0x00007f98bbe1e2d0>, @proxy=nil, @connection=#<Excon::Connection:7f98bbe1e000 @data={:chunk_size=>1048576, :ciphers=>"ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS", :connect_timeout=>60, :debug_request=>false, :debug_response=>false, :headers=>{"User-Agent"=>"excon/0.62.0"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>false, :persistent=>true, :read_timeout=>60, :retry_limit=>4, :ssl_verify_peer=>true, :ssl_uri_schemes=>["https"], :stubs=>:global, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.62.0 (x86_64-darwin16) ruby/2.4.4", :write_timeout=>60, :host=>"api.telegram.org", :hostname=>"api.telegram.org", :path=>"/", :port=>443, :query=>nil, :scheme=>"https"} @socket_key="https://api.telegram.org:443" @_excon_sockets={70146886727520=>{}}>> 
2.4.4 :002 > 
2.4.4 :003 >   bot.get_updates(fail_silently: true)
TelegramBot::ResponseError: An error has occurred: {"ok"=>false, "error_code"=>404, "description"=>"Not Found"}
ZhKostev commented 6 years ago

@Schwad it would be unsecure, but maybe you can post out put from https://telegram.me/botfather about your credentials? You can confirm them here https://api.telegram.org/botID_OF_APP:TOKEN/getMe. I think you have now 404 on this url

ZhKostev commented 6 years ago

@Schwad totatgibberish is not a valid token. It will look like this XXXXX:YYYY

ZhKostev commented 6 years ago

@Schwad sorry. I was thinking that you are trying to make bot working, but you are trying to reproduce issue. I will collect info and post. Please ignore messages above

Schwad commented 6 years ago

I got it! @eljojo , this was replicated using ruby 2.5.1 in Rails 5.2.0 within rails console

2.5.1 :001 > bot = TelegramBot.new token: 'totatgibberish'
 => #<TelegramBot::Bot:0x00007f955c8caef8 @token="totatgibberish", @timeout=50, @offset=0, @logger=#<TelegramBot::NullLogger:0x00007f955c8caed0>, @proxy=nil, @connection=#<Excon::Connection:7f955c8cac28 @data={:chunk_size=>1048576, :ciphers=>"ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS", :connect_timeout=>60, :debug_request=>false, :debug_response=>false, :headers=>{"User-Agent"=>"excon/0.62.0"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>false, :persistent=>true, :read_timeout=>60, :retry_limit=>4, :ssl_verify_peer=>true, :ssl_uri_schemes=>["https"], :stubs=>:global, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.62.0 (x86_64-darwin16) ruby/2.5.1", :write_timeout=>60, :host=>"api.telegram.org", :hostname=>"api.telegram.org", :path=>"/", :port=>443, :query=>nil, :scheme=>"https"} @socket_key="https://api.telegram.org:443" @_excon_sockets={70139634773520=>{}}>> 
2.5.1 :002 > bot.get_updates(fail_silently: true)
Traceback (most recent call last):
        1: from (irb):2
NameError (uninitialized constant TelegramBot::ApiResponse::ResponseError)
Schwad commented 6 years ago

Now that we have the reproduction conditions down we can get to work with fixing it :)

Schwad commented 6 years ago

Okay, here's a thought I have. To break this down a bit I might first to replicate this within each of the main Rails gems (activesupport, activerecord, activemodel, etc.) to see if there's a particular one triggering this problem.

After that, I will most likely pull down a rails for to try and find where we're colliding here.

stupied4ever commented 5 years ago

Any update on this?

I am with the same error.

emilianodellacasa commented 5 years ago

I solved the problem by adding the ResponseError class inside inside ApiResponse, the PR that was created didn't solve anything for me

rodgco commented 5 years ago

To solve the issue simply add a require "telegram_bot/response_error" in lib\telegram_bot.rb.

I would send a pull request, but the published GEM version (0.0.8) is different than the one tagged here with the same number.

McBruno712 commented 3 years ago

To solve the issue simply add a require "telegram_bot/response_error" in lib\telegram_bot.rb.

I would send a pull request, but the published GEM version (0.0.8) is different than the one tagged here with the same number.

THANK YOU!