Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASK] getChat delayed #2856

Closed
andigian16 opened this issue Apr 23, 2024 · 5 comments
Closed

[ASK] getChat delayed #2856

andigian16 opened this issue Apr 23, 2024 · 5 comments

Comments

@andigian16
Copy link

andigian16 commented Apr 23, 2024

Hi, I need help here.

I use getChats to get the chats IDs. And then I use getChat for each chatID to get latest message.
the issue is the message that i got from tdlib is diff with that showing in apps.

lets say I send a new message to my account using another account.
in my apps showing the latest message, but when using tdlib, what i got is not the last message. the latest message still the previous message. not the one i sent.

`await client.login();
const chats = await client.invoke({
_: 'getChats',
limit: 10
});

if (chats && chats.chat_ids.length > 0) {
for (const chatID of chats.chat_ids) {
chat = await fetchTelegramChat(chatID, client)
// Handle the message here
}
}

await client.close();`

can anyone help me what happen with this?

@levlam
Copy link
Contributor

levlam commented Apr 23, 2024

You need to handle updateChatLastMessage updates to always know the last messages of chats. In some cases you need to open the chat using openChat to update its last message.

@andigian16
Copy link
Author

@levlam, I did test with your suggestion, seems the openChat didn't work for my case. fetchTelegramChat still cant get latest message.

@levlam
Copy link
Contributor

levlam commented Apr 24, 2024

You need to handle updateChatLastMessage after calling openChat. If you receive no updates, then there are no new messages for your account in the chat.

@andigian16
Copy link
Author

@levlam. I did try your suggestion above. but I got this error when testing it. can you give me example how to do that?
image
image

@levlam
Copy link
Contributor

levlam commented Apr 29, 2024

updateChatLastMessage isn't a request. See https://core.telegram.org/tdlib/getting-started.

@levlam levlam closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants