Fix get_chats parameters for tdlib 1.8#665
Merged
Merged
Conversation
getChats dropped offset_order and offset_chat_id in tdlib 1.8.0, and its JSON parser ignores fields it does not know, so we kept sending two dead parameters and nobody noticed. The clear_group_messages example passed 2^62-1 as an offset for years with no effect. Take limit and chat_list instead, which is the current signature. The chat list argument also makes the archive and chat folders reachable; before this the main list was the only thing you could read. Add load_chats for the loadChats method, which is what tdlib recommends for keeping a chat list in sync through updates. The README and the send_message example said get_chats preloads all chats. It loads up to limit chats, so say that instead.
There was a problem hiding this comment.
Pull request overview
Updates the Telegram client’s chat-list retrieval APIs to match TDLib 1.8+ (getChats signature change) and adds a wrapper for loadChats, aligning the library’s high-level synchronous interface with current TDLib recommendations.
Changes:
- Update
get_chatsto uselimit+chat_listand addload_chatsfor TDLibloadChats. - Expand tests to cover
get_chats(chat_list=...)and the newload_chatsmethod. - Refresh README/examples/changelog to reflect the new behavior and limits.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
telegram/client.py |
Updates get_chats parameters and adds load_chats wrapper. |
tests/test_telegram_methods.py |
Adjusts get_chats expectations and adds coverage for chat_list + load_chats. |
README.md |
Clarifies that get_chats loads up to a limit (not “all chats”). |
examples/send_message.py |
Updates example to call get_chats(limit=100) before sending. |
examples/clear_group_messages.py |
Replaces legacy positional offset usage with the new limit call. |
docs/source/changelog.rst |
Documents the breaking get_chats signature change and adds load_chats. |
Comments suppressed due to low confidence (1)
telegram/client.py:436
- For consistency with
get_chatsand to prevent accidental positional misuse (e.g., passing achat_listdict as the second positional argument), consider makingload_chatsparameters keyword-only and typingchat_listasdict[str, Any] | None.
def load_chats(self, limit: int = 100, chat_list: dict | None = None) -> AsyncResult:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return self.call_method("getUserFullInfo", params={"user_id": user_id}) | ||
|
|
||
| def get_chats(self, offset_order: int = 0, offset_chat_id: int = 0, limit: int = 100) -> AsyncResult: | ||
| def get_chats(self, limit: int = 100, chat_list: dict | None = None) -> AsyncResult: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getChats dropped offset_order and offset_chat_id in tdlib 1.8.0, and its JSON parser ignores fields it does not know, so we kept sending two dead parameters and nobody noticed. The clear_group_messages example passed 2^62-1 as an offset for years with no effect.
Take limit and chat_list instead, which is the current signature. The chat list argument also makes the archive and chat folders reachable; before this the main list was the only thing you could read.
Add load_chats for the loadChats method, which is what tdlib recommends for keeping a chat list in sync through updates.
The README and the send_message example said get_chats preloads all chats. It loads up to limit chats, so say that instead.