Skip to content

Commit 04cf4e6

Browse files
Add mark_chat_unread() method (pyrogram#322)
* Add mark_chat_unread() method * Add bound method for mark_chat_unread * Update mark_chat_unread.py * Update chat.py Apply Dans suggested changes * Update mark_chat_unread.py * Update chat.py * Update compiler.py Co-authored-by: Dan <14043624+delivrance@users.noreply.github.com>
1 parent 23b1450 commit 04cf4e6

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

compiler/docs/compiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ def get_title_list(s: str) -> list:
216216
delete_channel
217217
delete_supergroup
218218
set_slow_mode
219+
mark_chat_unread
219220
""",
220221
users="""
221222
Users
@@ -459,6 +460,7 @@ def get_title_list(s: str) -> list:
459460
Chat.add_members
460461
Chat.join
461462
Chat.leave
463+
Chat.mark_unread
462464
""",
463465
user="""
464466
User

pyrogram/client/methods/chats/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from .unban_chat_member import UnbanChatMember
5151
from .unpin_chat_message import UnpinChatMessage
5252
from .update_chat_username import UpdateChatUsername
53+
from .mark_chat_unread import MarkChatUnread
5354

5455

5556
class Chats(
@@ -86,6 +87,7 @@ class Chats(
8687
DeleteSupergroup,
8788
GetNearbyChats,
8889
SetAdministratorTitle,
89-
SetSlowMode
90+
SetSlowMode,
91+
MarkChatUnread
9092
):
9193
pass
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-2020 Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from typing import Union
20+
21+
from pyrogram.raw import functions
22+
from pyrogram.scaffold import Scaffold
23+
24+
25+
class MarkChatUnread(Scaffold):
26+
async def mark_chat_unread(
27+
self,
28+
chat_id: Union[int, str],
29+
) -> bool:
30+
"""Mark a chat as unread.
31+
32+
Parameters:
33+
chat_id (``int`` | ``str``):
34+
Unique identifier (int) or username (str) of the target chat.
35+
36+
Returns:
37+
``bool``: On success, True is returned.
38+
"""
39+
40+
return await self.send(
41+
functions.messages.MarkDialogUnread(
42+
peer=await self.resolve_peer(chat_id),
43+
unread=True
44+
)
45+
)

0 commit comments

Comments
 (0)