From 6b1f4cda851038d563cd5ff23f16ff9b1693711d Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Thu, 25 Dec 2025 19:17:22 -0800 Subject: [PATCH 01/11] 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) From 943f66a67cc71264030c7fa14a531b94ef597dbf Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Fri, 26 Dec 2025 13:45:28 -0800 Subject: [PATCH 02/11] Apply suggestions from code review Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com> --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index cc590c2..5420bc6 100644 --- a/main.py +++ b/main.py @@ -942,6 +942,7 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: # Add unread count if available unread_count = getattr(dialog, "unread_count", 0) # Also check unread_mark (manual "mark as unread" flag) + inner_dialog = getattr(dialog, "dialog", None) unread_mark = ( getattr(dialog.dialog, "unread_mark", False) if hasattr(dialog, "dialog") From 78a21ef2d096325408707f71952191bc85970aa5 Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Fri, 26 Dec 2025 13:46:31 -0800 Subject: [PATCH 03/11] Update main.py Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com> --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 5420bc6..327d255 100644 --- a/main.py +++ b/main.py @@ -944,7 +944,7 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: # Also check unread_mark (manual "mark as unread" flag) inner_dialog = getattr(dialog, "dialog", None) unread_mark = ( - getattr(dialog.dialog, "unread_mark", False) + getattr(inner_dialog, "unread_mark", False)) if hasattr(dialog, "dialog") else False ) From 041bf0dbeca7038687260d7bff3dea6801fa3e4e Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Fri, 26 Dec 2025 13:46:38 -0800 Subject: [PATCH 04/11] Update main.py Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com> --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 327d255..f9741da 100644 --- a/main.py +++ b/main.py @@ -945,7 +945,7 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: inner_dialog = getattr(dialog, "dialog", None) unread_mark = ( getattr(inner_dialog, "unread_mark", False)) - if hasattr(dialog, "dialog") + if inner_dialog else False else False ) From adc6ef4c7c59351be1e149c62b794399d8355006 Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Fri, 26 Dec 2025 13:46:46 -0800 Subject: [PATCH 05/11] Update main.py Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com> --- main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/main.py b/main.py index f9741da..3c8992c 100644 --- a/main.py +++ b/main.py @@ -947,7 +947,6 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: getattr(inner_dialog, "unread_mark", False)) if inner_dialog else False else False - ) if unread_count > 0: chat_info += f", Unread: {unread_count}" From fe8dcb3797c4ad4129de0ea0f3ef096a631016d0 Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Fri, 26 Dec 2025 13:46:53 -0800 Subject: [PATCH 06/11] Update main.py Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com> --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 3c8992c..965b275 100644 --- a/main.py +++ b/main.py @@ -940,7 +940,7 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: chat_info += f", Username: @{entity.username}" # Add unread count if available - unread_count = getattr(dialog, "unread_count", 0) + unread_count = getattr(dialog, "unread_count", 0) or 0 # Also check unread_mark (manual "mark as unread" flag) inner_dialog = getattr(dialog, "dialog", None) unread_mark = ( From 700c01b2d33ada1d4896e6bc59281d8a9fcc5db1 Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Fri, 26 Dec 2025 13:46:59 -0800 Subject: [PATCH 07/11] Update main.py Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com> --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 965b275..37cb5ba 100644 --- a/main.py +++ b/main.py @@ -943,7 +943,7 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: unread_count = getattr(dialog, "unread_count", 0) or 0 # Also check unread_mark (manual "mark as unread" flag) inner_dialog = getattr(dialog, "dialog", None) - unread_mark = ( + unread_mark = bool( getattr(inner_dialog, "unread_mark", False)) if inner_dialog else False else False From d504e5fa451b49d0de9c82107b2e6e559b3ae381 Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Fri, 26 Dec 2025 13:47:05 -0800 Subject: [PATCH 08/11] Update main.py Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com> --- main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 37cb5ba..bb698e4 100644 --- a/main.py +++ b/main.py @@ -952,7 +952,9 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: chat_info += f", Unread: {unread_count}" elif unread_mark: chat_info += ", Unread: marked" - + else: + chat_info += ", No unread messages" + results.append(chat_info) if not results: From 182e3684ddae488f5957d0c61d37cfaf8d7592c3 Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Fri, 26 Dec 2025 13:47:11 -0800 Subject: [PATCH 09/11] Update main.py Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com> --- main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/main.py b/main.py index bb698e4..1607c26 100644 --- a/main.py +++ b/main.py @@ -946,7 +946,6 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: unread_mark = bool( getattr(inner_dialog, "unread_mark", False)) if inner_dialog else False - else False if unread_count > 0: chat_info += f", Unread: {unread_count}" From aabe9d8bc08c49b6ab88553d1cea2e668b8810e1 Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Fri, 26 Dec 2025 13:48:36 -0800 Subject: [PATCH 10/11] fix: correct syntax error from suggestion application MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The individual line suggestions created invalid Python when applied separately. Combined the ternary expression properly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 1607c26..515c58a 100644 --- a/main.py +++ b/main.py @@ -943,9 +943,11 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: unread_count = getattr(dialog, "unread_count", 0) or 0 # Also check unread_mark (manual "mark as unread" flag) inner_dialog = getattr(dialog, "dialog", None) - unread_mark = bool( - getattr(inner_dialog, "unread_mark", False)) - if inner_dialog else False + unread_mark = ( + bool(getattr(inner_dialog, "unread_mark", False)) + if inner_dialog + else False + ) if unread_count > 0: chat_info += f", Unread: {unread_count}" From 11bfca7083942845c126f1ca2abda46a98474d63 Mon Sep 17 00:00:00 2001 From: Bayram Annakov Date: Fri, 26 Dec 2025 13:51:20 -0800 Subject: [PATCH 11/11] style: apply black formatting to match project standards --- main.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 515c58a..dee671a 100644 --- a/main.py +++ b/main.py @@ -944,9 +944,7 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: # Also check unread_mark (manual "mark as unread" flag) inner_dialog = getattr(dialog, "dialog", None) unread_mark = ( - bool(getattr(inner_dialog, "unread_mark", False)) - if inner_dialog - else False + bool(getattr(inner_dialog, "unread_mark", False)) if inner_dialog else False ) if unread_count > 0: @@ -955,7 +953,7 @@ async def list_chats(chat_type: str = None, limit: int = 20) -> str: chat_info += ", Unread: marked" else: chat_info += ", No unread messages" - + results.append(chat_info) if not results: