Skip to content

Commit b2b636a

Browse files
authored
Add the method send_screenshot_notification
KurimuzonAkuma/kurigram@60f055d
1 parent 81b2853 commit b2b636a

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

compiler/docs/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ def get_title_list(s: str) -> list:
228228
translate_text
229229
translate_message_text
230230
delete_chat_history
231+
send_screenshot_notification
231232
""",
232233
chats="""
233234
Chats

docs/source/releases/changes-in-this-fork.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Changes in this Fork
3434
| Scheme layer used: 200 |
3535
+------------------------+
3636

37+
- Add :meth:`~pyrogram.Client.send_screenshot_notification`.
3738
- Add ``media`` in :obj:`~pyrogram.types.ExternalReplyInfo`.
3839
- Add :obj:`~pyrogram.enums.MessageOriginType` as enum instead of str, and updated the appropriate filters.
3940
- Document about `the issue #161 <https://github.com/TelegramPlayGround/pyrogram/issues/161>`__.

pyrogram/methods/messages/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
from .search_public_messages_by_tag import SearchPublicMessagesByTag
7474
from .count_public_messages_by_tag import CountPublicMessagesByTag
7575
from .translate_text import TranslateText
76+
from .send_screenshot_notification import SendScreenshotNotification
7677

7778
class Messages(
7879
CopyMediaGroup,
@@ -119,6 +120,7 @@ class Messages(
119120
SendPaidMedia,
120121
SendPhoto,
121122
SendPoll,
123+
SendScreenshotNotification,
122124
SendSticker,
123125
SendVenue,
124126
SendVideo,
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present <https://github.com/TelegramPlayground>
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+
import pyrogram
22+
from pyrogram import types, raw, utils
23+
24+
25+
class SendScreenshotNotification:
26+
async def send_screenshot_notification(
27+
self: "pyrogram.Client",
28+
chat_id: Union[int, str],
29+
message_thread_id: int = None,
30+
reply_parameters: "types.ReplyParameters" = None,
31+
) -> "types.Message":
32+
"""Notify the other user in a chat that screenshot of the chat was taken.
33+
34+
.. include:: /_includes/usable-by/users.rst
35+
36+
Parameters:
37+
chat_id (``int`` | ``str``):
38+
Unique identifier (int) or username (str) of the target chat.
39+
For your personal cloud (Saved Messages) you can simply use "me" or "self".
40+
For a contact that exists in your Telegram address book you can use his phone number (str).
41+
42+
message_thread_id (``int``, *optional*):
43+
If the message is in a thread, ID of the original message.
44+
45+
reply_parameters (:obj:`~pyrogram.types.ReplyParameters`, *optional*):
46+
Description of the message to reply to
47+
48+
Returns:
49+
:obj:`~pyrogram.types.Message`: On success, the sent service message is returned.
50+
51+
"""
52+
53+
reply_to = await utils._get_reply_message_parameters(
54+
self,
55+
message_thread_id,
56+
reply_parameters
57+
)
58+
r = await self.invoke(
59+
raw.functions.messages.SendScreenshotNotification(
60+
peer=await self.resolve_peer(chat_id),
61+
reply_to=reply_to,
62+
random_id=self.rnd_id()
63+
)
64+
)
65+
66+
for i in r.updates:
67+
if isinstance(
68+
i,
69+
(
70+
raw.types.UpdateNewMessage,
71+
raw.types.UpdateNewChannelMessage
72+
)
73+
):
74+
return await types.Message._parse(
75+
self, i.message,
76+
{i.id: i for i in r.users},
77+
{i.id: i for i in r.chats}
78+
)

0 commit comments

Comments
 (0)