From 6b1f4cda851038d563cd5ff23f16ff9b1693711d Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Thu, 25 Dec 2025 19:17:22 -0800 Subject: [PATCH] fix: detect manually marked unread chats in list_chats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously list_chats only checked dialog.unread_count, missing chats that were manually marked as unread via Telegram's "mark as unread" feature. Now also checks dialog.dialog.unread_mark flag: - unread_count > 0: shows "Unread: N" - unread_mark = True: shows "Unread: marked" This matches the behavior of Telegram's "Unread" folder filter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- main.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 1562f3b..cc590c2 100644 --- a/main.py +++ b/main.py @@ -940,8 +940,18 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: chat_info += f", Username: @{entity.username}" # Add unread count if available - if hasattr(dialog, "unread_count") and dialog.unread_count > 0: - chat_info += f", Unread: {dialog.unread_count}" + unread_count = getattr(dialog, "unread_count", 0) + # Also check unread_mark (manual "mark as unread" flag) + unread_mark = ( + getattr(dialog.dialog, "unread_mark", False) + if hasattr(dialog, "dialog") + else False + ) + + if unread_count > 0: + chat_info += f", Unread: {unread_count}" + elif unread_mark: + chat_info += ", Unread: marked" results.append(chat_info)