U
    ;g                     @   sV   d dl m Z  d dlmZmZ d dlZd dlmZmZ d dlmZmZ G dd dZ	dS )    )datetime)UnionListN)rawutils)typesenumsc                   @   sx   e Zd Zdejjdddddddddddddfdeeef ee	e e
de
eede	d eee
e
e
eeed dd	d
dZdS )SendPollTNzpyrogram.Clientzenums.PollTypezenums.ParseModeztypes.MessageEntity)ztypes.InlineKeyboardMarkupztypes.ReplyKeyboardMarkupztypes.ReplyKeyboardRemoveztypes.ForceReplyztypes.Message)selfchat_idquestionoptionsis_anonymoustypeallows_multiple_answerscorrect_option_idexplanationexplanation_parse_modeexplanation_entitiesopen_period
close_date	is_closeddisable_notificationprotect_contentreply_to_message_idschedule_datereply_markupreturnc                    sL  t | ||	|
I dH  \}}| tjjj| |I dH tj	j
tj	j|  |dd t|D || ||tjjkprd|t |d	|dk	rt|ggnd||pg dd|||  t |||r|| I dH ndd	I dH }|jD ]d}t|tj	jtj	jtj	jfrt	jj| |jd	d
 |jD dd
 |jD t|tj	jdI dH   S qdS )aP  Send a new poll.

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

        Parameters:
            chat_id (``int`` | ``str``):
                Unique identifier (int) or username (str) of the target chat.
                For your personal cloud (Saved Messages) you can simply use "me" or "self".
                For a contact that exists in your Telegram address book you can use his phone number (str).

            question (``str``):
                Poll question, 1-255 characters.

            options (List of ``str``):
                List of answer options, 2-10 strings 1-100 characters each.

            is_anonymous (``bool``, *optional*):
                True, if the poll needs to be anonymous.
                Defaults to True.

            type (:obj`~pyrogram.enums.PollType`, *optional*):
                Poll type, :obj:`~pyrogram.enums.PollType.QUIZ` or :obj:`~pyrogram.enums.PollType.REGULAR`.
                Defaults to :obj:`~pyrogram.enums.PollType.REGULAR`.

            allows_multiple_answers (``bool``, *optional*):
                True, if the poll allows multiple answers, ignored for polls in quiz mode.
                Defaults to False.

            correct_option_id (``int``, *optional*):
                0-based identifier of the correct answer option, required for polls in quiz mode.

            explanation (``str``, *optional*):
                Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style
                poll, 0-200 characters with at most 2 line feeds after entities parsing.

            explanation_parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
                By default, texts are parsed using both Markdown and HTML styles.
                You can combine both syntaxes together.

            explanation_entities (List of :obj:`~pyrogram.types.MessageEntity`):
                List of special entities that appear in the poll explanation, which can be specified instead of
                *parse_mode*.

            open_period (``int``, *optional*):
                Amount of time in seconds the poll will be active after creation, 5-600.
                Can't be used together with *close_date*.

            close_date (:py:obj:`~datetime.datetime`, *optional*):
                Point in time when the poll will be automatically closed.
                Must be at least 5 and no more than 600 seconds in the future.
                Can't be used together with *open_period*.

            is_closed (``bool``, *optional*):
                Pass True, if the poll needs to be immediately closed.
                This can be useful for poll preview.

            disable_notification (``bool``, *optional*):
                Sends the message silently.
                Users will receive a notification with no sound.

            protect_content (``bool``, *optional*):
                Protects the contents of the sent message from forwarding and saving.

            reply_to_message_id (``int``, *optional*):
                If the message is a reply, ID of the original message.

            schedule_date (:py:obj:`~datetime.datetime`, *optional*):
                Date when the message will be automatically sent.

            reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
                Additional interface options. An object for an inline keyboard, custom reply keyboard,
                instructions to remove reply keyboard or to force a reply from the user.

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

        Example:
            .. code-block:: python

                await app.send_poll(chat_id, "Is this a poll question?", ["Yes", "No", "Maybe"])
        Nc                 S   s&   g | ]\}}t jj|t|gd qS ))textoption)r   r   Z
PollAnswerbytes).0ir    r#   c/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pyrogram/methods/messages/send_poll.py
<listcomp>   s   z&SendPoll.send_poll.<locals>.<listcomp>F)	idr   ZanswersclosedZpublic_votersZmultiple_choiceZquizZclose_periodr   )pollZcorrect_answerssolutionsolution_entities )	ZpeerZmediamessageZsilentZreply_to_msg_idZ	random_idr   Z
noforwardsr   c                 S   s   i | ]}|j |qS r#   r&   r!   r"   r#   r#   r$   
<dictcomp>   s      z&SendPoll.send_poll.<locals>.<dictcomp>c                 S   s   i | ]}|j |qS r#   r-   r.   r#   r#   r$   r/      s      )Zis_scheduled)r   Zparse_text_entitiesvaluesZinvoker   Z	functionsmessagesZ	SendMediaZresolve_peerr   ZInputMediaPollZPollZrnd_id	enumerater   PollTypeZQUIZZdatetime_to_timestampr    writeZupdates
isinstanceZUpdateNewMessageZUpdateNewChannelMessageZUpdateNewScheduledMessageMessage_parser,   ZusersZchats)r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r)   r*   rr"   r#   r#   r$   	send_poll   s`    l   
 

 zSendPoll.send_poll)__name__
__module____qualname__r   r3   ZREGULARr   intstrr   boolr   r9   r#   r#   r#   r$   r	      sN   
r	   )
r   typingr   r   Zpyrogramr   r   r   r   r	   r#   r#   r#   r$   <module>   s
   