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 to imitate method messages.getDialogs using tdlib? #3072

Closed n1ppl3 closed 4 weeks ago

n1ppl3 commented 1 month ago

Hi, I'm new to tdlib and wondering how to get the same result as using method messages.getDialogs

I'm interested in online user information especialy actual online status UserStatus I tried getChats + getChat but I get stale information...

Thanks!

levlam commented 1 month ago

See https://core.telegram.org/tdlib/getting-started for the way to fetch chat list.

You can't fetch a user's status from the server using TDLib. It is updated whenever appropriate.

n1ppl3 commented 4 weeks ago

I got desired data by listening to UpdateUserStatus event, thanks for hint!

    clientBuilder.addUpdateHandler(TdApi.UpdateUserStatus.class, this::onUpdateNewMessage);
    // 
    private void onUpdateNewMessage(TdApi.UpdateUserStatus update) {
        logger.info("{}: {}", update.userId, update.status);
    }

(I'm using tdlight-java version 3.3.1+td.1.8.25)