Merge pull request #46 from BayramAnnakov/fix/unread-mark-detection

fix: detect manually marked unread chats in list_chats
This commit is contained in:
Eugene Evstafev 2025-12-26 22:51:54 +00:00 committed by GitHub
commit ff8d19b59c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

15
main.py
View file

@ -940,8 +940,19 @@ 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) 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
)
if unread_count > 0:
chat_info += f", Unread: {unread_count}"
elif unread_mark:
chat_info += ", Unread: marked"
else:
chat_info += ", No unread messages"
results.append(chat_info)