tdlib / td

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

How are chats related between TDLib and Http BotAPI? #2591

Closed wowka1319 closed 1 year ago

wowka1319 commented 1 year ago
  1. Are Chat ID in Http Bot API and TDLib the same?
  2. Bot API describes "private”, “group”, “supergroup”, “channel”. Is the table correct?
    Http Bot API  |   TDLib
    private       | user
    group         | basic group
    supergroup    | supergroup
    channel       | supergroup
levlam commented 1 year ago

Are Chat ID in Http Bot API and TDLib the same?

If the same bot is logged in TDLib, then yes. Otherwise, the question doesn't make sense, because chat identifiers are user-specific.

Is the table correct?

Mostly. Private chats have chatTypePrivate in TDLib.

wowka1319 commented 1 year ago
  1. I hasn't understood. For example: my account via TDLib searchs or joins @addmeto channel and I see it's chat_id == -1001005993407. Then I via another account get bot token and make HTTP GET request https://api.telegram.org/bot<?>:<?>/getChat?chat_id=@addmeto and get the chat object when id is the same = -1001005993407. Are these chat ids of the same supergroup always the same between TDLib and HttpAPI?
levlam commented 1 year ago

This isn't guaranteed. There are no reasons to guarantee chat_id persistence between different accounts.

wowka1319 commented 1 year ago

That's unexpected. Ok, thank you.

  1. Are supergroup_id, basic_group_id and user_id persistence between different accounts unlike chat_id?
  2. Is chat_id for the same account persistence forever regardless of joining/leaving/chat removing/joining again?
levlam commented 1 year ago

Are supergroup_id, basic_group_id and user_id persistence between different accounts unlike chat_id?

Currently, yes, but this can be changed in the future.

Is chat_id for the same account persistence forever regardless of joining/leaving/chat removing/joining again?

Currently, yes.

wowka1319 commented 1 year ago

Currently, yes, but this can be changed in the future.

  1. What can that be necessary for?
  2. Will some unique id (persistence among accounts) remain after this change?
levlam commented 1 year ago

What can that be necessary for?

It is the opposite, for example, there are no reasons for basic group identifiers to be the same for different people.

Will some unique id (persistence among accounts) remain after this change?

Noone knows.

wowka1319 commented 1 year ago

Is the message id persistence between accounts?

levlam commented 1 year ago

Is the message id persistence between accounts?

No and they never were the same for different users.

wowka1319 commented 1 year ago

Is that true for messages of public channels too?

levlam commented 1 year ago

No, messages in public chats have the same message identifiers for all users.

wowka1319 commented 1 year ago

For clarity, public chats are supergroups, that have active username only? What about supergroup without it (that have invite link only)?

levlam commented 1 year ago

Public chats are supergroups/channels with username or location. In private supergroups some users may not have access to some messages, but if the users have access to a message, then they will see the same message identifier.

wowka1319 commented 1 year ago

Here you said message.date of the same message can be different for different users. Why can that be possible? Is not it server side timestamp? Or you add inaccuracy to date intentionally?

levlam commented 1 year ago

It is just a server-side timestamp, which can be different for different users, expecially for users in different datacenters.