
    iQ'                     "   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rddlmZ  G d de          Z G d de          Z G d de          Z G d de          Z G 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                   6    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z  f fdZeddedddd f fd            Z x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                    t                                          |           t          j        t          j        ||          | _        || _        | j        | j        f| _        | 	                                 d S )Nr   )
super__init__r	   
get_memberr   MessageOriginTyper   r   	_id_attrs_freeze)selfr   r   r   	__class__s       W/Users/shanyulin/my-agent/.venv/lib/python3.11/site-packages/telegram/_messageorigin.pyr   zMessageOrigin.__init__P   sg     	J///)DdDQQ	"&	 II
 	    databotz
Bot | Nonereturnc                    |                      |          }| j        t          | j        t          | j        t          | j        t          i}| t          u rG|
                    d          |v r0||                    d                                       ||          S t          |          }t          |
                    d          |          |d<   d|v r,t          |
                    d          t           |          |d<   d|v r,t          |
                    d          t"          |          |d<   d|v r,t          |
                    d          t"          |          |d<   t%                                          ||          S )zConverts 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!   s        r"   r3   zMessageOrigin.de_jsonb   s[   
 t$$ H'O4H'K-	:
 -DHHV$4$4$F$F!$((6"2"23;;3;OOO1#66
%dhhv&6&6zJJJVD  "2488M3J3JDRU"V"VDD  "2488M3J3JDRU"V"VDT>>+DHHV,<,<dCHHDLwwDc222r#   N)__name__
__module____qualname____doc__	__slots__r   r   r   r   str__annotations__r   r   r   dtmdatetimer   r   classmethodr3   __classcell__r!   s   @r"   r   r   %   s;         8I
 !27D%*777<'9EKsEEEC 27D%*777<#5=GU3Z===? '+   l
 tO     $ 3 38 3, 3/ 3 3 3 3 3 [3 3 3 3 3r#   r   c                   J     e Zd ZdZdZdddej        dededz  f fdZ	 x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                    t                                          | j        ||           |                                 5  || _        d d d            d S # 1 swxY w Y   d S N)r   r   r   )r   r   r   	_unfrozenr)   )r    r   r)   r   r!   s       r"   r   zMessageOriginUser.__init__   s     	didzJJJ^^ 	1 	1%0D	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1   AAA)r8   r9   r:   r;   r<   r?   r@   r   r   r   rB   rC   s   @r"   r-   r-      s         $ !I '+
1 
1 
1l
1 
1
 tO
1 
1 
1 
1 
1 
1 
1 
1 
1 
1r#   r-   c                   J     e Zd ZdZdZdddej        dededz  f fdZ	 xZ
S )	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   rJ   r   c                    t                                          | j        ||           |                                 5  || _        d d d            d S # 1 swxY w Y   d S rF   )r   r   r   rG   rJ   )r    r   rJ   r   r!   s       r"   r   z MessageOriginHiddenUser.__init__   s     	d.TjQQQ^^ 	: 	:)9D!	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:rH   )r8   r9   r:   r;   r<   r?   r@   r=   r   r   rB   rC   s   @r"   r.   r.      s         $ &I '+
: 
: 
:l
: 
:
 tO
: 
: 
: 
: 
: 
: 
: 
: 
: 
:r#   r.   c                   X     e Zd ZdZdZ	 d
dddej        dededz  de	dz  f fd	Z
 x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*   rM   r   c                    t                                          | j        ||           |                                 5  || _        || _        d d d            d S # 1 swxY w Y   d S rF   )r   r   r   rG   r*   rM   )r    r   r*   rM   r   r!   s        r"   r   zMessageOriginChat.__init__   s     	didzJJJ^^ 	A 	A%0D0@D!	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	As   AA"Ar7   )r8   r9   r:   r;   r<   r?   r@   r   r=   r   r   rB   rC   s   @r"   r/   r/      s         ,I (,	A '+A A AlA A *	A tOA A A A A A A A A Ar#   r/   c                   \     e Zd ZdZdZ	 ddddej        dedede	dz  d	e
dz  f
 fd
Z xZS )r0   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.
    )rM   r+   
message_idNr   r   r+   rP   rM   r   c                    t                                          | j        ||           |                                 5  || _        || _        || _        d d d            d S # 1 swxY w Y   d S rF   )r   r   r   rG   r+   rP   rM   )r    r   r+   rP   rM   r   r!   s         r"   r   zMessageOriginChannel.__init__  s     	dl*MMM^^ 	A 	A"DI#-DO0@D!	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	As   A""A&)A&r7   )r8   r9   r:   r;   r<   r?   r@   r   intr=   r   r   rB   rC   s   @r"   r0   r0      s         ,I (,A '+A A AlA A 	A
 *A tOA A A A A A A A A Ar#   r0   )r;   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/   r0    r#   r"   <module>r]      s  & M L     ' ' ' ' ' ' ' '             3 3 3 3 3 3                   < < < < < < Q Q Q Q Q Q Q Q * * * * * * Y3 Y3 Y3 Y3 Y3N Y3 Y3 Y3x1 1 1 1 1 1 1 1D: : : : :m : : :D(A (A (A (A (A (A (A (AV+A +A +A +A +A= +A +A +A +A +Ar#   