Closed phykos closed 4 years ago
TD::ClientMethods:send_message
. Class/module method calls can be performed with Class.method
or Class::method
, but not with single colon.1. There's no such syntax in Ruby: `TD::ClientMethods:send_message`. Class/module method calls can be performed with `Class.method` or `Class::method`, but not with single colon. 2. You use client methods in a wrong way. You should create TD::Client instance and then call client methods through it (see [example](https://github.com/southbridgeio/tdlib-ruby#basic-authentication-example) in Readme)
yea, Ik I also tried TD::ClientMethods.send_message
but the error is the same, now I am going to fix it (or at least trying to)
edit
both TD::ClientMethods.send_message
and TD::ClientMethods::send_message
are "undefined method `send_message' for TD::ClientMethods:Module (NoMethodError)".
btw I didnt really understood what you mean with "You should create TD::Client instance and then call client methods through it "
Please, read README and don't try to use library in uncodumented way.
both TD::ClientMethods.send_message and TD::ClientMethods::send_message are "undefined method `send_message' for TD::ClientMethods:Module (NoMethodError)"
Because they are not supposed to be used as static module functions. TD::ClientMethods is just a mixin, and its methods are available only for instances of TD::Client.
btw I didnt really understood what you mean with "You should create TD::Client instance and then call client methods through it "
It means that you should write something like this:
TD.configure do |config|
config.lib_path = 'path_to_dir_containing_libtdjson'
config.client.api_id = 'your_api_id'
config.client.api_hash = 'your_api_hash'
end
client = TD::Client.new
client.connect
promise = client.get_me.then do |me|
message_content = TD::Types::InputMessageContent::Text.new(text: TD::Types::FormattedText.new(text: 'hello', entities: []),
disable_web_page_preview: true,
clear_draft: false)
client.send_message(me.id, message_content)
end
message = promise.flat.value!
Please, open another issue if you have any further questions.
my code is:
the given error is:
its like 30 minutes I am trying to understand why the code gives me this error.