Source code for pyrogram.methods.messages.send_screenshot_notification

#  Pyrogram - Telegram MTProto API Client Library for Python
#  Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
#  This file is part of Pyrogram.
#
#  Pyrogram is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Lesser General Public License as published
#  by the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  Pyrogram is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public License
#  along with Pyrogram.  If not, see <http://www.gnu.org/licenses/>.


from __future__ import annotations

import pyrogram
from pyrogram import raw, types, utils


class SendScreenshotNotification:
    async def send_screenshot_notification(
        self: pyrogram.Client,
        chat_id: int | str,
        reply_to_message_id: int = 0,
        reply_parameters: types.ReplyParameters | None = None,
    ) -> types.Message:
        """Notify the other user that you took a screenshot.

        .. include:: /_includes/usable-by/users.rst

        Parameters:

            reply_to_message_id (int, *optional*): Message ID to reply to

            chat_id (``int`` | ``str``):
                Unique identifier (int) or username (str) of the target chat.

            reply_parameters (:obj:`~pyrogram.types.ReplyParameters`, *optional*):
                Describes the message the notification replies to.



        Returns:
            :obj:`~pyrogram.types.Message`

        Example:
            .. code-block:: python

                await app.send_screenshot_notification(chat_id, ...)
        """

        if reply_parameters is None and reply_to_message_id:
            reply_parameters = types.ReplyParameters(message_id=reply_to_message_id)

        r = await self.invoke(
            raw.functions.messages.SendScreenshotNotification(
                peer=await self.resolve_peer(chat_id),
                reply_to=await utils.get_reply_to(self, reply_parameters),
                random_id=self.rnd_id(),
            )
        )

        for i in r.updates:
            if isinstance(
                i,
                (
                    raw.types.UpdateNewMessage,
                    raw.types.UpdateNewChannelMessage,
                    raw.types.UpdateNewScheduledMessage,
                ),
            ):
                return await types.Message._parse(
                    self,
                    i.message,
                    {i.id: i for i in r.users},
                    {i.id: i for i in r.chats},
                    is_scheduled=isinstance(i, raw.types.UpdateNewScheduledMessage),
                )