U
    gGC                     @   s   d Z ddlZddl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mZ dd	lmZ erdd
lmZ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dS )zGThis module contains an objects that are related to Telegram giveaways.    N)TYPE_CHECKINGOptionalSequenceTuple)Chat)TelegramObject)User)parse_sequence_arg)extract_tzinfo_from_defaultsfrom_timestamp)JSONDict)BotMessagec                       s   e Zd ZdZdZdddee ejee	e
 e	e
 e	e e	ee  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 )Giveawaya  This object represents a message about a scheduled giveaway.

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

    .. versionadded:: 20.8

    Args:
        chats (Tuple[:class:`telegram.Chat`]): The list of chats which the user must join to
            participate in the giveaway.
        winners_selection_date (:class:`datetime.datetime`): The date when the giveaway winner will
            be selected. |datetime_localization|
        winner_count (:obj:`int`): The number of users which are supposed to be selected as winners
            of the giveaway.
        only_new_members (:obj:`True`, optional): If :obj:`True`, only users who join the chats
            after the giveaway started should be eligible to win.
        has_public_winners (:obj:`True`, optional): :obj:`True`, if the list of giveaway winners
            will be visible to everyone
        prize_description (:obj:`str`, optional): Description of additional giveaway prize
        country_codes (Sequence[:obj:`str`]): A list of two-letter ISO 3166-1 alpha-2
            country codes indicating the countries from which eligible users for the giveaway must
            come. If empty, then all users can participate in the giveaway. Users with a phone
            number that was bought on Fragment can always participate in giveaways.
        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
        premium_subscription_month_count (:obj:`int`, optional): The number of months the Telegram
            Premium subscription won from the giveaway will be active for; for Telegram Premium
            giveaways only.

    Attributes:
        chats (Sequence[:class:`telegram.Chat`]): The list of chats which the user must join to
            participate in the giveaway.
        winners_selection_date (:class:`datetime.datetime`): The date when the giveaway winner will
            be selected. |datetime_localization|
        winner_count (:obj:`int`): The number of users which are supposed to be selected as winners
            of the giveaway.
        only_new_members (:obj:`True`): Optional. If :obj:`True`, only users who join the chats
            after the giveaway started should be eligible to win.
        has_public_winners (:obj:`True`): Optional. :obj:`True`, if the list of giveaway winners
            will be visible to everyone
        prize_description (:obj:`str`): Optional. Description of additional giveaway prize
        country_codes (Tuple[:obj:`str`]): Optional. A tuple of two-letter ISO 3166-1 alpha-2
            country codes indicating the countries from which eligible users for the giveaway must
            come. If empty, then all users can participate in the giveaway. Users with a phone
            number that was bought on Fragment can always participate in giveaways.
        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
        premium_subscription_month_count (:obj:`int`): Optional. The number of months the Telegram
            Premium subscription won from the giveaway will be active for; for Telegram Premium
            giveaways only.
    )	chatscountry_codeshas_public_winnersonly_new_members premium_subscription_month_countprize_descriptionprize_star_countwinner_countwinners_selection_dateN
api_kwargs)
r   r   r   r   r   r   r   r   r   r   c
                   sj   t  j|
d t|| _|| _|| _|| _|| _|| _t	|| _
|| _|	| _| j| j| jf| _|   d S Nr   )super__init__tupler   r   r   r   r   r   r	   r   r   r   	_id_attrs_freeze)selfr   r   r   r   r   r   r   r   r   r   	__class__ 6/tmp/pip-unpacked-wheel-swnnwir2/telegram/_giveaway.pyr   h   s    

zGiveaway.__init__r   databotreturnc                    s^   |  |}|dkrdS t|}tt|d||d< t|d|d|d< t j||dS ),See :meth:`telegram.TelegramObject.de_json`.Nr   r   tzinfor'   r(   )	_parse_datar
   r   r   de_listgetr   r   de_jsonclsr'   r(   Z
loc_tzinfor"   r$   r%   r1      s    
 
zGiveaway.de_json)NNNNNN)N)__name__
__module____qualname____doc__	__slots__r   r   datetimeintr   boolstrr   r   classmethodr1   __classcell__r$   r$   r"   r%   r   "   s:   9      
"  r   c                       s<   e Zd ZdZdZdddee ee d fddZ  Z	S )	GiveawayCreateda  This object represents a service message about the creation of a scheduled giveaway.

    Args:
        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

    Attributes:
        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

    )r   Nr   )r   r   c                   s    t  j|d || _|   d S r   )r   r   r   r    )r!   r   r   r"   r$   r%   r      s    zGiveawayCreated.__init__)N)
r4   r5   r6   r7   r8   r   r:   r   r   r>   r$   r$   r"   r%   r?      s     r?   c                       s   e Zd ZdZdZdddeeejeee	 e
e e
e e
e e
e e
e 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 )GiveawayWinnersa  This object represents a message about the completion of a giveaway with public winners.

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

    .. versionadded:: 20.8

    Args:
        chat (:class:`telegram.Chat`): The chat that created the giveaway
        giveaway_message_id (:obj:`int`): Identifier of the message with the giveaway in the chat
        winners_selection_date (:class:`datetime.datetime`): Point in time when winners of the
            giveaway were selected. |datetime_localization|
        winner_count (:obj:`int`): Total number of winners in the giveaway
        winners	(Sequence[:class:`telegram.User`]): List of up to
            :tg-const:`telegram.constants.GiveawayLimit.MAX_WINNERS` winners of the giveaway
        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
        additional_chat_count (:obj:`int`, optional): The number of other chats the user had to
            join in order to be eligible for the giveaway
        premium_subscription_month_count (:obj:`int`, optional): The number of months the Telegram
            Premium subscription won from the giveaway will be active for
        unclaimed_prize_count (:obj:`int`, optional): Number of undistributed prizes
        only_new_members (:obj:`True`, optional): :obj:`True`, if only users who had joined the
            chats after the giveaway started were eligible to win
        was_refunded (:obj:`True`, optional): :obj:`True`, if the giveaway was canceled because the
            payment for it was refunded
        prize_description (:obj:`str`, optional): Description of additional giveaway prize

    Attributes:
        chat (:class:`telegram.Chat`): The chat that created the giveaway
        giveaway_message_id (:obj:`int`): Identifier of the message with the giveaway in the chat
        winners_selection_date (:class:`datetime.datetime`): Point in time when winners of the
            giveaway were selected. |datetime_localization|
        winner_count (:obj:`int`): Total number of winners in the giveaway
        winners	(Tuple[:class:`telegram.User`]): tuple of up to
            :tg-const:`telegram.constants.GiveawayLimit.MAX_WINNERS` winners of the giveaway
        additional_chat_count (:obj:`int`): Optional. The number of other chats the user had to
            join in order to be eligible for the giveaway
        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
        premium_subscription_month_count (:obj:`int`): Optional. The number of months the Telegram
            Premium subscription won from the giveaway will be active for
        unclaimed_prize_count (:obj:`int`): Optional. Number of undistributed prizes
        only_new_members (:obj:`True`): Optional. :obj:`True`, if only users who had joined the
            chats after the giveaway started were eligible to win
        was_refunded (:obj:`True`): Optional. :obj:`True`, if the giveaway was canceled because the
            payment for it was refunded
        prize_description (:obj:`str`): Optional. Description of additional giveaway prize
    )additional_chat_countchatgiveaway_message_idr   r   r   r   unclaimed_prize_countwas_refundedr   winnersr   Nr   )rB   rC   r   r   rF   rA   r   rD   r   rE   r   r   r   c                   s   t  j|d || _|| _|| _|| _t|| _|| _|| _	|| _
|	| _|
| _|| _|| _| j| j| j| j| jf| _|   d S r   )r   r   rB   rC   r   r   r   rF   rA   r   rD   r   rE   r   r   r   r    )r!   rB   rC   r   r   rF   rA   r   rD   r   rE   r   r   r   r"   r$   r%   r     s(    
zGiveawayWinners.__init__r   r&   c                    st   |  |}|dkrdS t|}t|d||d< tt|d||d< t|d|d|d< t	 j||dS )r*   NrB   rF   r   r+   r-   )
r.   r
   r   r1   r0   r   r   r/   r   r   r2   r"   r$   r%   r1   ,  s    
 
zGiveawayWinners.de_json)NNNNNNN)N)r4   r5   r6   r7   r8   r   r:   r9   r   r   r   r;   r<   r   r   r=   r1   r>   r$   r$   r"   r%   r@      sB   7       *  r@   c                       sr   e Zd ZdZdZdddeee e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 )GiveawayCompletedas  This object represents a service message about the completion of a giveaway without public
    winners.

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

    .. versionadded:: 20.8


    Args:
        winner_count (:obj:`int`): Number of winners in the giveaway
        unclaimed_prize_count (:obj:`int`, optional): Number of undistributed prizes
        giveaway_message (:class:`telegram.Message`, optional): Message with the giveaway that was
            completed, if it wasn't deleted
        is_star_giveaway (:obj:`bool`, optional): :obj:`True`, if the giveaway is a Telegram Star
            giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.

            .. versionadded:: 21.6
    Attributes:
        winner_count (:obj:`int`): Number of winners in the giveaway
        unclaimed_prize_count (:obj:`int`): Optional. Number of undistributed prizes
        giveaway_message (:class:`telegram.Message`): Optional. Message with the giveaway that was
            completed, if it wasn't deleted
        is_star_giveaway (:obj:`bool`): Optional. :obj:`True`, if the giveaway is a Telegram Star
            giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.

            .. versionadded:: 21.6
    )giveaway_messageis_star_giveawayrD   r   Nr   r   )r   rD   rH   rI   r   c                   s@   t  j|d || _|| _|| _|| _| j| jf| _|   d S r   )r   r   r   rD   rH   rI   r   r    )r!   r   rD   rH   rI   r   r"   r$   r%   r   b  s    	zGiveawayCompleted.__init__r   r&   c                    sH   |  |}|dkrdS ddlm} ||d||d< t j||dS )r*   Nr   )r   rH   r-   )r.   Ztelegram._messager   r1   r0   r   )r3   r'   r(   r   r"   r$   r%   r1   y  s    
zGiveawayCompleted.de_json)NNN)N)r4   r5   r6   r7   r8   r:   r   r;   r   r   r=   r1   r>   r$   r$   r"   r%   rG   B  s*        rG   )r7   r9   typingr   r   r   r   Ztelegram._chatr   Ztelegram._telegramobjectr   Ztelegram._userr   Ztelegram._utils.argumentparsingr	   Ztelegram._utils.datetimer
   r   Ztelegram._utils.typesr   Ztelegramr   r   r   r?   r@   rG   r$   r$   r$   r%   <module>   s   } 