tdlib-ruby icon indicating copy to clipboard operation
tdlib-ruby copied to clipboard

AuthorizationState is not updating from WaitTdlibParameters

Open gourshete opened this issue 4 years ago • 4 comments

I am trying to run the ruby program given in readme. I have api_id and api_hash. But the authorization_state is set to WaitTdlibParameters initially and I am not sure how would it get updated to one of the states mentioned in the case when block.

Here is code snippet from my local file -

p '-----------------------------after config-----------------------------'
TD::Api.set_log_verbosity_level(1)
client = TD::Client.new
p '-----------------------------after client.new-----------------------------'

begin
  state = nil
  p '-----------------------------before client.on-----------------------------'
  client.on(TD::Types::Update::AuthorizationState) do |update|
    p '-----------------------------before case-----------------------------'
    p "update.authorization_state - #{update.authorization_state}"
    state = case update.authorization_state
            when TD::Types::AuthorizationState::WaitPhoneNumber
              :wait_phone_number
            when TD::Types::AuthorizationState::WaitCode
              :wait_code
            when TD::Types::AuthorizationState::WaitPassword
              :wait_password
            when TD::Types::AuthorizationState::Ready
              :ready
            else
              nil
            end
    p '-----------------------------end of case-----------------------------'
  end

Output

"-----------------------------before case-----------------------------"
"update.authorization_state - #<TD::Types::AuthorizationState::WaitTdlibParameters:0x00007fb7feb08d18>"

I tried few things like calling client.set_tdlib_parameters, but it is not getting me the correct result. Please let me know if I am missing something.

gourshete avatar Jun 13 '21 06:06 gourshete

Hi, I've just faced the same problem, my solution is: https://github.com/m3xq/tdlib-ruby/commit/17f578a6ea866f362bca267c41d5d7894362a1cd

m3xq avatar Aug 22 '21 20:08 m3xq

Same for me on the latest version

Mehonoshin avatar May 29 '22 13:05 Mehonoshin

@m3xq unfortunately your patch does not solve the issue for me :(

Mehonoshin avatar May 29 '22 14:05 Mehonoshin

Maybe my comment from other issue will help somehow https://github.com/southbridgeio/tdlib-ruby/issues/63#issuecomment-2210922485

tilvin avatar Jul 05 '24 14:07 tilvin