B
    fdU                 @   s6   d dl mZ d dlZd dlmZmZ G dd dZdS )    )UnionN)rawtypesc               @   s.   e Zd Zddeeef eeeddddZdS )	PinChatMessageFzpyrogram.Clientztypes.Message)selfchat_id
message_iddisable_notification
both_sidesreturnc       	         s   |  tjjj| |I dH ||p"d| p*ddI dH }dd |jD }dd |jD }x>|jD ]4}t	|tj
jtj
jfr`t
j| |j||I dH S q`W dS )a_  Pin a message in a group, channel or your own chat.
        You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin right in
        the supergroup or "can_edit_messages" admin right in the channel.

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

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

            message_id (``int``):
                Identifier of a message to pin.

            disable_notification (``bool``, *optional*):
                Pass True, if it is not necessary to send a notification to all chat members about the new pinned
                message. Notifications are always disabled in channels.

            both_sides (``bool``, *optional*):
                Pass True to pin the message for both sides (you and recipient).
                Applicable to private chats only. Defaults to False.

        Returns:
            :obj:`~pyrogram.types.Message`: On success, the service message is returned.

        Example:
            .. code-block:: python

                # Pin with notification
                await app.pin_chat_message(chat_id, message_id)

                # Pin without notification
                await app.pin_chat_message(chat_id, message_id, disable_notification=True)
        N)ZpeeridZsilentZ
pm_onesidec             S   s   i | ]}||j qS  )r   ).0ur   r   K/tmp/pip-unpacked-wheel-rcokkf2l/pyrogram/methods/chats/pin_chat_message.py
<dictcomp>K   s    z3PinChatMessage.pin_chat_message.<locals>.<dictcomp>c             S   s   i | ]}||j qS r   )r   )r   cr   r   r   r   L   s    )Zinvoker   Z	functionsmessagesZUpdatePinnedMessageZresolve_peeruserschatsZupdates
isinstancer   ZUpdateNewMessageZUpdateNewChannelMessageMessage_parsemessage)	r   r   r   r	   r
   rr   r   ir   r   r   pin_chat_message   s    (
zPinChatMessage.pin_chat_messageN)FF)__name__
__module____qualname__r   intstrboolr   r   r   r   r   r      s    r   )typingr   Zpyrogramr   r   r   r   r   r   r   <module>   s   