Skip to content

Fix get_chats parameters for tdlib 1.8#665

Merged
alexander-akhmetov merged 1 commit into
mainfrom
alexander-akhmetov/get-chats-params
Jul 24, 2026
Merged

Fix get_chats parameters for tdlib 1.8#665
alexander-akhmetov merged 1 commit into
mainfrom
alexander-akhmetov/get-chats-params

Conversation

@alexander-akhmetov

Copy link
Copy Markdown
Owner

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.

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.
Copilot AI review requested due to automatic review settings July 24, 2026 22:30
@alexander-akhmetov
alexander-akhmetov merged commit 8091866 into main Jul 24, 2026
11 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_chats to use limit + chat_list and add load_chats for TDLib loadChats.
  • Expand tests to cover get_chats(chat_list=...) and the new load_chats method.
  • 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_chats and to prevent accidental positional misuse (e.g., passing a chat_list dict as the second positional argument), consider making load_chats parameters keyword-only and typing chat_list as dict[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.

Comment thread telegram/client.py
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:
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

Successfully merging this pull request may close these issues.

2 participants