|
| 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