o
    ZzjQ'  ã                   @   sä   d Z ddlZddlmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ erHddlmZ G dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )zFThis module contains the classes that represent Telegram MessageOigin.é    N)ÚTYPE_CHECKINGÚFinal)Ú	constants)ÚChat)ÚTelegramObject)ÚUser)Úenum)Úde_json_optional)Úextract_tzinfo_from_defaultsÚfrom_timestamp)ÚJSONDict)ÚBotc                       s¸   e Zd ZU dZdZejjZee	 e
d< 	 ejjZee	 e
d< 	 ejjZee	 e
d< 	 ejjZee	 e
d< 	 ddœd	e	d
ejdedB f‡ fdd„Zeddedddd f‡ fdd„ƒZ‡  ZS )ÚMessageOriginaŸ  
    Base class for telegram MessageOrigin object, it can be one of:

    * :class:`MessageOriginUser`
    * :class:`MessageOriginHiddenUser`
    * :class:`MessageOriginChat`
    * :class:`MessageOriginChannel`

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`type` and :attr:`date` are equal.

    .. versionadded:: 20.8

    Args:
        type (:obj:`str`): Type of the message origin, can be on of:
            :attr:`~telegram.MessageOrigin.USER`, :attr:`~telegram.MessageOrigin.HIDDEN_USER`,
            :attr:`~telegram.MessageOrigin.CHAT`, or :attr:`~telegram.MessageOrigin.CHANNEL`.
        date (:obj:`datetime.datetime`): Date the message was sent originally.
            |datetime_localization|

    Attributes:
        type (:obj:`str`): Type of the message origin, can be on of:
            :attr:`~telegram.MessageOrigin.USER`, :attr:`~telegram.MessageOrigin.HIDDEN_USER`,
            :attr:`~telegram.MessageOrigin.CHAT`, or :attr:`~telegram.MessageOrigin.CHANNEL`.
        date (:obj:`datetime.datetime`): Date the message was sent originally.
            |datetime_localization|
    )ÚdateÚtypeÚUSERÚHIDDEN_USERÚCHATÚCHANNELN©Ú
api_kwargsr   r   r   c                   s@   t ƒ j|d� t tj||¡| _|| _| j| jf| _|  	¡  d S )Nr   )
ÚsuperÚ__init__r   Ú
get_memberr   ÚMessageOriginTyper   r   Ú	_id_attrsÚ_freeze)Úselfr   r   r   ©Ú	__class__© úR/var/www/kodo/tsheker/venv/lib/python3.10/site-packages/telegram/_messageorigin.pyr   P   s   þzMessageOrigin.__init__ÚdataÚbotz
Bot | NoneÚreturnc                    sÜ   |   |¡}| jt| jt| jt| jti}| t	u r*| 
d¡|v r*|| d¡ j||d�S t|ƒ}t| 
d¡|d�|d< d|v rHt| 
d¡t|ƒ|d< d|v rWt| 
d¡t|ƒ|d< d|v rft| 
d¡t|ƒ|d< tƒ j||d�S )zˆConverts JSON data to the appropriate :class:`MessageOrigin` object, i.e. takes
        care of selecting the correct subclass.
        r   )r"   r#   r   )ÚtzinfoÚsender_userÚsender_chatÚchat)Ú_parse_datar   ÚMessageOriginUserr   ÚMessageOriginHiddenUserr   ÚMessageOriginChatr   ÚMessageOriginChannelr   ÚgetÚpopÚde_jsonr
   r   r	   r   r   r   )Úclsr"   r#   Ú_class_mappingÚ
loc_tzinfor   r    r!   r0   b   s"   
üzMessageOrigin.de_json©N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   r   ÚstrÚ__annotations__r   r   r   ÚdtmÚdatetimer   r   Úclassmethodr0   Ú__classcell__r    r    r   r!   r   %   s*   
 ûþýû&r   c                       ó>   e Zd ZdZdZddœdejdededB f‡ fdd	„Z	‡  Z
S )
r*   av  
    The message was originally sent by a known user.

    .. versionadded:: 20.8

    Args:
        date (:obj:`datetime.datetime`): Date the message was sent originally.
            |datetime_localization|
        sender_user (:class:`telegram.User`): User that sent the message originally.

    Attributes:
        type (:obj:`str`): Type of the message origin. Always
            :tg-const:`~telegram.MessageOrigin.USER`.
        date (:obj:`datetime.datetime`): Date the message was sent originally.
            |datetime_localization|
        sender_user (:class:`telegram.User`): User that sent the message originally.
    )r&   Nr   r   r&   r   c                   óH   t ƒ j| j||d� |  ¡ � || _W d   ƒ d S 1 sw   Y  d S ©N)r   r   r   )r   r   r   Ú	_unfrozenr&   )r   r   r&   r   r   r    r!   r   –   ó   
"ÿzMessageOriginUser.__init__)r5   r6   r7   r8   r9   r<   r=   r   r   r   r?   r    r    r   r!   r*   �   ó    ûþýûr*   c                       r@   )
r+   aŠ  
    The message was originally sent by an unknown user.

    .. versionadded:: 20.8

    Args:
        date (:obj:`datetime.datetime`): Date the message was sent originally.
            |datetime_localization|
        sender_user_name (:obj:`str`): Name of the user that sent the message originally.

    Attributes:
        type (:obj:`str`): Type of the message origin. Always
            :tg-const:`~telegram.MessageOrigin.HIDDEN_USER`.
        date (:obj:`datetime.datetime`): Date the message was sent originally.
            |datetime_localization|
        sender_user_name (:obj:`str`): Name of the user that sent the message originally.
    )Úsender_user_nameNr   r   rF   r   c                   rA   rB   )r   r   r   rC   rF   )r   r   rF   r   r   r    r!   r   ¸   rD   z MessageOriginHiddenUser.__init__)r5   r6   r7   r8   r9   r<   r=   r:   r   r   r?   r    r    r   r!   r+   £   rE   r+   c                       sJ   e Zd ZdZdZ	dddœdejdededB de	dB f‡ fd	d
„Z
‡  ZS )r,   aÊ  
    The message was originally sent on behalf of a chat to a group chat.

    .. versionadded:: 20.8

    Args:
        date (:obj:`datetime.datetime`): Date the message was sent originally.
            |datetime_localization|
        sender_chat (:class:`telegram.Chat`): Chat that sent the message originally.
        author_signature (:obj:`str`, optional): For messages originally sent by an anonymous chat
            administrator, original message author signature

    Attributes:
        type (:obj:`str`): Type of the message origin. Always
            :tg-const:`~telegram.MessageOrigin.CHAT`.
        date (:obj:`datetime.datetime`): Date the message was sent originally.
            |datetime_localization|
        sender_chat (:class:`telegram.Chat`): Chat that sent the message originally.
        author_signature (:obj:`str`): Optional. For messages originally sent by an anonymous chat
            administrator, original message author signature
    )Úauthor_signaturer'   Nr   r   r'   rG   r   c                   sN   t ƒ j| j||d� |  ¡ � || _|| _W d   ƒ d S 1 s w   Y  d S rB   )r   r   r   rC   r'   rG   )r   r   r'   rG   r   r   r    r!   r   á   s
   
"þzMessageOriginChat.__init__r4   )r5   r6   r7   r8   r9   r<   r=   r   r:   r   r   r?   r    r    r   r!   r,   Å   s    	üúþýüúr,   c                       sN   e Zd ZdZdZ	dddœdejdedede	dB d	e
dB f
‡ fd
d„Z‡  ZS )r-   aÕ  
    The message was originally sent to a channel chat.

    .. versionadded:: 20.8

    Args:
        date (:obj:`datetime.datetime`): Date the message was sent originally.
            |datetime_localization|
        chat (:class:`telegram.Chat`): Channel chat to which the message was originally sent.
        message_id (:obj:`int`): Unique message identifier inside the chat.
        author_signature (:obj:`str`, optional): Signature of the original post author.

    Attributes:
        type (:obj:`str`): Type of the message origin. Always
            :tg-const:`~telegram.MessageOrigin.CHANNEL`.
        date (:obj:`datetime.datetime`): Date the message was sent originally.
            |datetime_localization|
        chat (:class:`telegram.Chat`): Channel chat to which the message was originally sent.
        message_id (:obj:`int`): Unique message identifier inside the chat.
        author_signature (:obj:`str`): Optional. Signature of the original post author.
    )rG   r(   Ú
message_idNr   r   r(   rH   rG   r   c                   sT   t ƒ j| j||d� |  ¡ � || _|| _|| _W d   ƒ d S 1 s#w   Y  d S rB   )r   r   r   rC   r(   rH   rG   )r   r   r(   rH   rG   r   r   r    r!   r     s   	
"ýzMessageOriginChannel.__init__r4   )r5   r6   r7   r8   r9   r<   r=   r   Úintr:   r   r   r?   r    r    r   r!   r-   ð   s"    ûùþýüûùr-   )r8   r=   r<   Útypingr   r   Útelegramr   Útelegram._chatr   Útelegram._telegramobjectr   Útelegram._userr   Útelegram._utilsr   Útelegram._utils.argumentparsingr	   Útelegram._utils.datetimer
   r   Útelegram._utils.typesr   r   r   r*   r+   r,   r-   r    r    r    r!   Ú<module>   s$   \""+