U
    g?                     @   s<  d Z ddlmZ ddlmZmZmZmZmZ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rd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 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 ) zDThis module contains the classes that represent Telegram ChatBoosts.    )datetime)TYPE_CHECKINGDictFinalOptionalSequenceTupleType)	constants)Chat)TelegramObject)User)enum)parse_sequence_arg)extract_tzinfo_from_defaultsfrom_timestamp)JSONDict)Botc                       s8   e Zd ZdZdZddeee dd fddZ  Z	S )ChatBoostAddeda  
    This object represents a service message about a user boosting a chat.

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

    .. versionadded:: 21.0

    Args:
        boost_count (:obj:`int`): Number of boosts added by the user.

    Attributes:
        boost_count (:obj:`int`): Number of boosts added by the user.

    )boost_countN
api_kwargs)r   r   returnc                   s*   t  j|d || _| jf| _|   d S Nr   )super__init__r   	_id_attrs_freeze)selfr   r   	__class__ 7/tmp/pip-unpacked-wheel-swnnwir2/telegram/_chatboost.pyr   9   s    
zChatBoostAdded.__init__)
__name__
__module____qualname____doc__	__slots__intr   r   r   __classcell__r!   r!   r   r"   r   %   s   r   c                       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< dde	ee d fd	d
Zedee ed ed  d fddZ  ZS )ChatBoostSourcea|  
    Base class for Telegram ChatBoostSource objects. It can be one of:

    * :class:`telegram.ChatBoostSourcePremium`
    * :class:`telegram.ChatBoostSourceGiftCode`
    * :class:`telegram.ChatBoostSourceGiveaway`

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

    .. versionadded:: 20.8

    Args:
        source (:obj:`str`): The source of the chat boost. Can be one of:
            :attr:`~telegram.ChatBoostSource.PREMIUM`, :attr:`~telegram.ChatBoostSource.GIFT_CODE`,
            or :attr:`~telegram.ChatBoostSource.GIVEAWAY`.

    Attributes:
        source (:obj:`str`): The source of the chat boost. Can be one of:
            :attr:`~telegram.ChatBoostSource.PREMIUM`, :attr:`~telegram.ChatBoostSource.GIFT_CODE`,
            or :attr:`~telegram.ChatBoostSource.GIVEAWAY`.
    )sourcePREMIUM	GIFT_CODEGIVEAWAYNr   r+   r   c                   s6   t  j|d ttj||| _| jf| _|   d S r   )	r   r   r   Z
get_memberr
   ChatBoostSourcesr+   r   r   )r   r+   r   r   r!   r"   r   g   s    
zChatBoostSource.__init__r   databotr   c                    s   |  |}|sdS | jt| jt| jti}| tkrV|d|krV||	d j
||dS d|krtt
|d||d< t j
||dS ),See :meth:`telegram.TelegramObject.de_json`.Nr+   r2   r3   user)_parse_datar,   ChatBoostSourcePremiumr-   ChatBoostSourceGiftCoder.   ChatBoostSourceGiveawayr*   getpopde_jsonr   r   )clsr2   r3   Z_class_mappingr   r!   r"   r=   p   s    
   zChatBoostSource.de_json)N)r#   r$   r%   r&   r'   r
   r0   r,   r   str__annotations__r-   r.   r   r   r   classmethodr=   r)   r!   r!   r   r"   r*   F   s   
	  r*   c                       s6   e Zd ZdZdZddeee d fddZ  Z	S )r8   a  
    The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium
    subscription to another user.

    .. versionadded:: 20.8

    Args:
        user (:class:`telegram.User`): User that boosted the chat.

    Attributes:
        source (:obj:`str`): The source of the chat boost. Always
            :attr:`~telegram.ChatBoostSource.PREMIUM`.
        user (:class:`telegram.User`): User that boosted the chat.
    r6   Nr   r6   r   c             	      s0   t  j| j|d |   || _W 5 Q R X d S Nr/   )r   r   r,   	_unfrozenr6   r   r6   r   r   r!   r"   r      s    
zChatBoostSourcePremium.__init__
r#   r$   r%   r&   r'   r   r   r   r   r)   r!   r!   r   r"   r8      s   r8   c                       s6   e Zd ZdZdZddeee d fddZ  Z	S )r9   a)  
    The boost was obtained by the creation of Telegram Premium gift codes to boost a chat. Each
    such code boosts the chat 4 times for the duration of the corresponding Telegram Premium
    subscription.

    .. versionadded:: 20.8

    Args:
        user (:class:`telegram.User`): User for which the gift code was created.

    Attributes:
        source (:obj:`str`): The source of the chat boost. Always
            :attr:`~telegram.ChatBoostSource.GIFT_CODE`.
        user (:class:`telegram.User`): User for which the gift code was created.
    rB   Nr   rC   c             	      s0   t  j| j|d |   || _W 5 Q R X d S rD   )r   r   r-   rE   r6   rF   r   r!   r"   r      s    
z ChatBoostSourceGiftCode.__init__rG   r!   r!   r   r"   r9      s   r9   c                       sJ   e Zd ZdZdZdddeee ee ee ee	 d fddZ
  ZS )	r:   a
  
    The boost was obtained by the creation of a Telegram Premium giveaway or a Telegram Star.
    This boosts the chat 4 times for the duration of the corresponding Telegram Premium
    subscription for Telegram Premium giveaways and :attr:`prize_star_count` / 500 times for
    one year for Telegram Star giveaways.

    .. versionadded:: 20.8

    Args:
        giveaway_message_id (:obj:`int`): Identifier of a message in the chat with the giveaway;
            the message could have been deleted already. May be 0 if the message isn't sent yet.
        user (:class:`telegram.User`, optional): User that won the prize in the giveaway if any;
            for Telegram Premium giveaways only.
        prize_star_count (:obj:`int`, optional): The number of Telegram Stars to be split between
            giveaway winners; for Telegram Star giveaways only.

            .. versionadded:: 21.6
        is_unclaimed (:obj:`bool`, optional): :obj:`True`, if the giveaway was completed, but
            there was no user to win the prize.

    Attributes:
        source (:obj:`str`): Source of the boost. Always
            :attr:`~telegram.ChatBoostSource.GIVEAWAY`.
        giveaway_message_id (:obj:`int`): Identifier of a message in the chat with the giveaway;
            the message could have been deleted already. May be 0 if the message isn't sent yet.
        user (:class:`telegram.User`): Optional. User that won the prize in the giveaway if any.
        prize_star_count (:obj:`int`): Optional. The number of Telegram Stars to be split between
            giveaway winners; for Telegram Star giveaways only.

            .. versionadded:: 21.6
        is_unclaimed (:obj:`bool`): Optional. :obj:`True`, if the giveaway was completed, but
            there was no user to win the prize.
    )giveaway_message_idis_unclaimedprize_star_countr6   Nr   )rH   r6   rI   rJ   r   c             	      sB   t  j| j|d |   || _|| _|| _|| _W 5 Q R X d S rD   )r   r   r.   rE   rH   r6   rJ   rI   )r   rH   r6   rI   rJ   r   r   r!   r"   r      s    	
z ChatBoostSourceGiveaway.__init__)NNN)r#   r$   r%   r&   r'   r(   r   r   boolr   r   r)   r!   r!   r   r"   r:      s   "   r:   c                       sd   e Zd ZdZdZddeeeeee	 d fddZ
edee	 ed ed  d	 fd
dZ  ZS )	ChatBoosta  
    This object contains information about a chat boost.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`boost_id`, :attr:`add_date`, :attr:`expiration_date`,
    and :attr:`source` are equal.

    .. versionadded:: 20.8

    Args:
        boost_id (:obj:`str`): Unique identifier of the boost.
        add_date (:obj:`datetime.datetime`): Point in time when the chat was boosted.
        expiration_date (:obj:`datetime.datetime`): Point in time when the boost
            will automatically expire, unless the booster's Telegram Premium subscription is
            prolonged.
        source (:class:`telegram.ChatBoostSource`): Source of the added boost.

    Attributes:
        boost_id (:obj:`str`): Unique identifier of the boost.
        add_date (:obj:`datetime.datetime`): Point in time when the chat was boosted.
            |datetime_localization|
        expiration_date (:obj:`datetime.datetime`): Point in time when the boost
            will automatically expire, unless the booster's Telegram Premium subscription is
            prolonged. |datetime_localization|
        source (:class:`telegram.ChatBoostSource`): Source of the added boost.
    )add_dateboost_idexpiration_dater+   Nr   )rN   rM   rO   r+   r   c                   sH   t  j|d || _|| _|| _|| _| j| j| j| jf| _|   d S r   )r   r   rN   rM   rO   r+   r   r   )r   rN   rM   rO   r+   r   r   r!   r"   r     s    	zChatBoost.__init__r   r1   c                    sh   |  |}|sdS t|d||d< t|}t|d |d|d< t|d |d|d< t j||dS )r4   Nr+   rM   tzinforO   r5   )r7   r*   r=   r;   r   r   r   r>   r2   r3   Z
loc_tzinfor   r!   r"   r=   $  s    
zChatBoost.de_json)N)r#   r$   r%   r&   r'   r?   r   r*   r   r   r   rA   r=   r)   r!   r!   r   r"   rL      s"   	  rL   c                       s`   e Zd ZdZdZddeeee d fddZ	e
dee ed ed  d	 fd
dZ  ZS )ChatBoostUpdateda;  This object represents a boost added to a chat or changed.

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

    .. versionadded:: 20.8

    Args:
        chat (:class:`telegram.Chat`): Chat which was boosted.
        boost (:class:`telegram.ChatBoost`): Information about the chat boost.

    Attributes:
        chat (:class:`telegram.Chat`): Chat which was boosted.
        boost (:class:`telegram.ChatBoost`): Information about the chat boost.
    )boostchatNr   )rU   rT   r   c                   s6   t  j|d || _|| _| jj| jf| _|   d S r   )r   r   rU   rT   idr   r   )r   rU   rT   r   r   r!   r"   r   I  s
    zChatBoostUpdated.__init__r   r1   c                    sN   |  |}|sdS t|d||d< t|d||d< t j||dS )r4   NrU   rT   r5   )r7   r   r=   r;   rL   r   r>   r2   r3   r   r!   r"   r=   X  s    
zChatBoostUpdated.de_json)N)r#   r$   r%   r&   r'   r   rL   r   r   r   rA   r=   r)   r!   r!   r   r"   rS   6  s     rS   c                       sd   e Zd ZdZdZddeeeee	e
 d fddZede	e
 e	d e	d  d	 fd
dZ  ZS )ChatBoostRemoveda  
    This object represents a boost removed from a chat.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`chat`, :attr:`boost_id`, :attr:`remove_date`, and
    :attr:`source` are equal.

    Args:
        chat (:class:`telegram.Chat`): Chat which was boosted.
        boost_id (:obj:`str`): Unique identifier of the boost.
        remove_date (:obj:`datetime.datetime`): Point in time when the boost was removed.
        source (:class:`telegram.ChatBoostSource`): Source of the removed boost.

    Attributes:
        chat (:class:`telegram.Chat`): Chat which was boosted.
        boost_id (:obj:`str`): Unique identifier of the boost.
        remove_date (:obj:`datetime.datetime`): Point in time when the boost was removed.
            |datetime_localization|
        source (:class:`telegram.ChatBoostSource`): Source of the removed boost.
    )rN   rU   remove_dater+   Nr   )rU   rN   rY   r+   r   c                   sH   t  j|d || _|| _|| _|| _| j| j| j| jf| _|   d S r   )r   r   rU   rN   rY   r+   r   r   )r   rU   rN   rY   r+   r   r   r!   r"   r     s    	zChatBoostRemoved.__init__r   r1   c                    sj   |  |}|sdS t|d||d< t|d||d< t|}t|d |d|d< t j||dS )r4   NrU   r+   rY   rP   r5   )r7   r   r=   r;   r*   r   r   r   rR   r   r!   r"   r=     s    
zChatBoostRemoved.de_json)N)r#   r$   r%   r&   r'   r   r?   r   r*   r   r   r   rA   r=   r)   r!   r!   r   r"   rX   h  s"   	  rX   c                       sb   e Zd ZdZdZddee ee d fddZ	e
dee ed ed  d	 fd
dZ  ZS )UserChatBoostsa  This object represents a list of boosts added to a chat by a user.

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

    .. versionadded:: 20.8

    Args:
        boosts (Sequence[:class:`telegram.ChatBoost`]): List of boosts added to the chat by the
            user.

    Attributes:
        boosts (Tuple[:class:`telegram.ChatBoost`]): List of boosts added to the chat by the user.
    )boostsNr   )r[   r   c                   s.   t  j|d t|| _| jf| _|   d S r   )r   r   r   r[   r   r   )r   r[   r   r   r!   r"   r     s    

zUserChatBoosts.__init__r   r1   c                    s8   |  |}|sdS t|d||d< t j||dS )r4   Nr[   r5   )r7   rL   Zde_listr;   r   r=   rW   r   r!   r"   r=     s
    
zUserChatBoosts.de_json)N)r#   r$   r%   r&   r'   r   rL   r   r   r   rA   r=   r)   r!   r!   r   r"   rZ     s     rZ   N)%r&   r   typingr   r   r   r   r   r   r	   Ztelegramr
   Ztelegram._chatr   Ztelegram._telegramobjectr   Ztelegram._userr   Ztelegram._utilsr   Ztelegram._utils.argumentparsingr   Ztelegram._utils.datetimer   r   Ztelegram._utils.typesr   r   r   r*   r8   r9   r:   rL   rS   rX   rZ   r!   r!   r!   r"   <module>   s*   $!C7C2=