Skip to content
Advertisement

How to get only unread messages from chat using telethon?

I have client.get_messages(dialog.entity) but its return just messages without “read/unread mark”… So, how can I get unread new messages only? Anybody know? 😥

Advertisement

Answer

Each dialog has unread_count

x = [[d.unread_count, d.title] for d in client.get_dialogs() if not getattr(d.entity, 'is_private', False) and d.unread_count != 0]
x = [[d.unread_count, d.title] for d in client.get_dialogs() if not getattr(d.entity, 'megagroup', False) and d.unread_count != 0]
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement