td icon indicating copy to clipboard operation
td copied to clipboard

This library is crap!!! '_client != null': is not true

Open timoshechkin opened this issue 7 months ago • 11 comments

This library is crap. It doesn't work. I keep getting an error when sending a method to TdLib: Unhandled Exception: 'package:tdlib/src/client/platform/io/io_platform.dart': Failed assertion: line 60 pos 12: '_client != null': is not true. There is no support.

timoshechkin avatar Jun 19 '25 17:06 timoshechkin

The error if from the Dart code and not from the library.

levlam avatar Jun 19 '25 19:06 levlam

This is the tdlib library in dart. It is taken from the repository as is. And it does not work. After executing the 'send' method, after some time the console displays the message 'stop td' and the library does not work.

timoshechkin avatar Jun 20 '25 05:06 timoshechkin

You use a third-party wrapper for TDLib.

The error likely means that you are trying to send requests to a closed TDLib instance.

levlam avatar Jun 20 '25 06:06 levlam

The example with the library was taken from the repository: https://github.com/ivk1800/tdlib-dart.git. Is this a third-party wrapper? The link to this repository with examples is in the current section. The first "send" request with the "GetMe()" function is sent and a response arrives in the console with data about the current user. After some time, the TdLib instance apparently closes itself and subsequent requests are not sent. Where can I get a working example of TdLib with Dart?

timoshechkin avatar Jun 20 '25 08:06 timoshechkin

Yes, this is a third-party wrapper as the most examples of TDLib usage.

Where can I get a working example of TdLib with Dart?

Likely, there is no issue with the wrapper. TDLib instance can't be closed without a reason. But you are free to modify the wrapper or write your own using the interface described at https://core.telegram.org/tdlib/docs/td__json__client_8h.html.

levlam avatar Jun 20 '25 11:06 levlam

I'm trying to get a chat after authorization "_client?.send(const td.GetChat(chatId: 1219159675))". I get the error: "Failed to load chat 1219159675 from database from load_dialog: Not found. Receive error for query: [Error : 400 : Chat not found]"

The same error occurs when trying to send a message to the chat: "_client?.send(const td.SendMessage( chatId: 1219159675, messageThreadId: 0, inputMessageContent: td.InputMessageText(text: td.FormattedText(text: "TEST", entities: []), clearDraft: false) ));"

Using GET requests (in the format: https://api.telegram.org/bot<YOUR_BOT_TOKEN>/sendMessage?chat_id=<chat_id>&text=) to the API, messages are sent to the chat without problems.

What's the problem here?

timoshechkin avatar Jun 23 '25 04:06 timoshechkin

You can use only identifiers received from the same TDLib instance. For this you must find the chat in exactly the same way you would do this in a regular app.

levlam avatar Jun 23 '25 06:06 levlam

How can I find the chat?

timoshechkin avatar Jun 23 '25 06:06 timoshechkin

How can I get a list of chats so that I can select the desired chat to send a message? I can't find a working example that shows the entire mechanism for sending a message.

timoshechkin avatar Jun 23 '25 08:06 timoshechkin

See https://core.telegram.org/tdlib/getting-started, which covers loading of the chat list among other details.

levlam avatar Jun 23 '25 10:06 levlam

This library is crap. It doesn't work. I keep getting an error when sending a method to TdLib: Unhandled Exception: 'package:tdlib/src/client/platform/io/io_platform.dart': Failed assertion: line 60 pos 12: '_client != null': is not true. There is no support.

it's a library from dart, if you want to use it you need to add a shared library depending on the OS.

ainslyfandradev avatar Jul 05 '25 21:07 ainslyfandradev