tdlib-ruby: The README.md example doesn't work

My Gemfile:

gem 'dry-configurable', '0.15.0'
gem 'tdlib-ruby'

Trying to run the example from the current README and getting only the following:

/home/yart/work/alcom/coding/tapp/vendor/bundle/ruby/3.2.0/gems/dry-configurable-0.15.0/lib/dry/configurable/dsl.rb:28:in `initialize' [dry-configurable] passing a constructor as a block is deprecated and will be removed in the next major version
Provide a `constructor:` keyword argument instead

/home/yart/work/alcom/coding/tapp/vendor/bundle/ruby/3.2.0/gems/dry-configurable-0.15.0/lib/dry/configurable/dsl.rb:28:in `initialize' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the nex
t major version
Provide a `default:` keyword argument instead

/home/yart/work/alcom/coding/tapp/vendor/bundle/ruby/3.2.0/gems/dry-configurable-0.15.0/lib/dry/configurable/dsl.rb:28:in `initialize' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the nex
t major version
Provide a `default:` keyword argument instead

I’ve been tried ruby 2.7.8 and 3.2.2 — the same result.

The last warning has been repeated several times. And that’s all this code does.

I’ve changed the dry-configurable version according to this issue: https://github.com/southbridgeio/tdlib-ruby/issues/62. I had the same error before.

Who can help me, guys?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15

Most upvoted comments

this might come in handy. I got the authorisation and method of receiving messages from the channel working(text and photo), but when I’m trying to get a video post:

Uncaught exception in update manager: Attribute :video has already been defined

I saw at the very bottom of the documentation information about using ./bin/parse and tried to run:

C:/tg/tdlib-schema/bin/parser:403:in `sort_by': comparison of NilClass with String failed (ArgumentError)
        from C:/tg/tdlib-schema/bin/parser:403:in `<main>'

be sure to take note of: https://github.com/southbridgeio/tdlib-schema/blob/master/bin/parser#L3 After that, everything worked.

@tilvin thanks for the answer, which version should I use TDLib https://github.com/tdlib/td : master or v1.8.0 master

The most important one is to change set_tdlib_parameters method to cover this changes in TDlib:

Hm, on my machine it doesn’t see .merge method for TD::Types::TdlibParameters, which is a subclass of Dry::Struct:

-----> #<TD::Types::Update::AuthorizationState authorization_state=#<TD::Types::AuthorizationState::WaitTdlibParameters>>
Uncaught exception in handler TD::UpdateHandler (TD::Types::Update::AuthorizationState): undefined method `merge' for an instance of TD::Types::TdlibParameters

I’ve used gem 'dry-configurable', '0.15.0', otherwise it just refuses to load tdlib-ruby with no receiver given message.

Tried to replace .merge with .new, with no luck for now.

Thanks, i forgot this part: a small update set_tdlib_parameters(parameters: TD::Types::TdlibParameters.new(**@config).to_hash) here

Or

def set_tdlib_parameters(parameters:)
   broadcast(parameters.to_hash.merge('@type' => 'setTdlibParameters'))
end

to change only one gem instead of two.

Tdlib changed input params for setTdlibParameters.

https://github.com/tdlib/td/issues/2211#issuecomment-1327625869

@yart did you find a solution?

@KonstantinReido I didn’t have a time for this yet. But I remember about the problem.

@yart Write if you can solve this problem. I’m also struggling with it now, I have no ideas.

Sure. I have an assumption that the problem in one of the following places:

  1. Incorrectly built TDlib — I’ve been built it using g++ v.13.2.1 installed on Archlinux. I have Clang too, but it produces a strange error when I’m trying to compile the library using this one. So, I’m going to do the following to resolve this possible trouble: a. Install TDlib from AUR — it has one b. Try to compile it in a Docker container (or find a ready one) with Ubuntu or Alpine and clang
  2. TDlib was changed and needs another set of parameters, so the current one should be changed to the actual state. Will read the TDlib docs to check it.
  3. Some insignificant changes in dry-rb (like it happened with dry-configurable, but not so fatal) or/and in concurrent-ruby. Will read the sources and the change logs to check it.