tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

How are we supposed to use `MessageSender` class? #2728

Closed mahmoud-syr closed 8 months ago

mahmoud-syr commented 10 months ago

Hi everyone, The API isn't really very well document if you ask me, I need to delete all messages by sender id. I have the user id, now the class itself doesn't tell you anything on how it supposed to be used. I am trying to call DeleteChatMessagesBySenderAsync which expect a chat id and a MessageSender That class has two very vague and confusing properties DataType and Extra I tried to supply the value userId in all possible combination, it keeps giving me exception that the value is wrong and it's not in json format, but the question is: "What is the correct value format??"

It would be really nice to have a clear documentation as for now it's like trial and error which is a waste of time for everybody, the dev, the people, the maintainers, everyone.

I would appreciate the help Thanks in advance.

levlam commented 10 months ago

Messages can be sent by users, or on behalf of chats. Therefore, MessageSender can be either messageSenderUser or messageSenderChat: https://github.com/tdlib/td/blob/8951949ece7b62bb0efe0025b1d12aa90e579071/td/generate/scheme/td_api.tl#L1134-L1140

If you want to delete all messages sent by a user, then you need to pass messageSenderUser with the corresponding user_id to the method.

For general TDLib usage see https://core.telegram.org/tdlib/getting-started. There you can find a lot of links to documentation and can understand, how the wrapper for your programming language works.