Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mark_chat_unread() method #322

Merged
merged 9 commits into from
Dec 12, 2020
Merged

Add mark_chat_unread() method #322

merged 9 commits into from
Dec 12, 2020

Conversation

ColinShark
Copy link
Member

Title says all. Mark a chat as unread.

https://t.me/PyrogramChat/123932

Copy link
Contributor

@JosXa JosXa left a comment

Choose a reason for hiding this comment

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

Please also add a convenience method to user_and_chats/chat.py

@delivrance
Copy link
Member

@ColinTheShark Can you confirm this works without the need of an InputDialogPeer object?
If that works, it means the server accepts either types (as it happens in a bunch of other places) and thus I think we can accept the method having chat instead of dialog in its name for convenience.

@delivrance
Copy link
Member

Also, what about marking a chat as read instead? The raw method allows to do that too, but the issue here is the misleading name.

@ColinShark
Copy link
Member Author

Can you confirm this works without the need of an InputDialogPeer object?

I haven't explicitly tested against an InputDialogPeer object but I can confirm that my snippet (same raw method) works both in private- and group chats.


Please also add a convenience method to user_and_chats/chat.py

You mean a bound method, right? If so, I added that already :)


Also, what about marking a chat as read instead?

While read_history can mark up to a specific point (or the latest message if no max_id is given), MarkDialogUnread just marks as unread. I have tried with unread=False as an argument, which didn't remove the unread status. I'm sure there is a raw method to mark a chat as read without using read_history, but I believe Clients just use the raw equivalent to read_history.

@@ -754,3 +754,23 @@ def export_invite_link(self):
"""

return self._client.export_invite_link(self.id)

def mark_chat_unread(self):
Copy link
Member

Choose a reason for hiding this comment

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

When we add a new method we usually name it like app.action_on_type, when it's a bound method we remove "type" because it's redundant (bad: chat.mark_chat_unread, good: chat.mark_unread).

@delivrance delivrance merged commit 04cf4e6 into pyrogram:develop Dec 12, 2020
@ColinShark ColinShark deleted the mark_chat_unread branch December 12, 2020 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants