o
    -˜Žjw#  ã                   @   s>   d dl Z d dl mZmZmZ d dlmZmZ G dd„ dƒZdS )é    N)ÚtypesÚrawÚutils)ÚUnionÚListc                +   @   s¢   e Zd Z															ddddeeef dedededed	ed	 f d
edededededededddedededededed ddf*dd„ZdS )ÚSendInvoiceNÚselfzpyrogram.ClientÚchat_idÚtitleÚdescriptionÚcurrencyÚpricesztypes.LabeledPriceÚproviderÚprovider_dataÚpayloadÚ	photo_urlÚ
photo_sizeÚphoto_mime_typeÚstart_parameterÚextended_mediaztypes.InputMediaÚreply_to_message_idÚmessage_thread_idÚ
quote_textÚallow_paid_broadcastÚmessage_effect_idÚquote_entitiesztypes.MessageEntityÚreply_markupztypes.InlineKeyboardMarkupc                 Ã   sä  �t |tjƒ }|durFd}|jD ]}|D ]
}t |tjƒrd}qq|sFd}|dkr:d}|D ]}||j7 }q-d|› �}|j dtj|d�g¡ tj| |||||d	�I dH }|dur]| 	¡ }n|›  	¡ }|  
tjjj|  |¡I dH tjj||tjj||r�d
d„ |D ƒn| ¡ gd�||tjj|r�|ndd�|	r£tjj|	|
pœd|pŸdg d�nd||d�	|||  ¡ |d|dur»| | ¡I dH ndd�¡I dH }|jD ])}t |tjjtjjfƒrïtjj| |jdd„ |jD ƒdd„ |jD ƒd�I dH   S qÆdS )a¶  Use this method to send invoices.

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

        Parameters:
            chat_id (``int`` | ``str``):
                Unique identifier for the target private chat or username of the target private chat.

            title (``str``):
                Product name.

            description (``str``):
                Product description.

            currency (``str``):
                Three-letter ISO 4217 currency code.
                `XTR` for Telegram Stars.

            prices (:obj:`~pyrogram.types.LabeledPrice` | List of :obj:`~pyrogram.types.LabeledPrice`):
                Price with label.
                If you add multiple prices, the prices will be added up.
                For stars invoice you can only have one item.

            provider (``str``, *optional*):
                Payment provider.
                Get this from botfather.

            provider_data (``str``, *optional*):
                Provider data in json format.

            payload (``str``, *optional*):
                Bot-defined invoice payload, 1-128 bytes.
                This will not be displayed to the user, use for your internal processes.

            photo_url (``str``, *optional*):
                Photo URL.

            photo_size (``int``, *optional*):
                Photo size.

            photo_mime_type (``str``, *optional*):
                Photo MIME type.

            start_parameter (``str``, *optional*):
                Unique bot deep-linking parameter that can be used to generate this invoice.

            extended_media (:obj:`~pyrogram.types.InputMedia`, *optional*):
                Additional media.

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

            message_thread_id (``int``, *optional*):
                Unique identifier for the target message thread (topic) of the forum.
                for forum supergroups only.

            quote_text (``str``, *optional*):
                Text to quote.
                for reply_to_message only.

            allow_paid_broadcast (``bool``, *optional*):
                Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only

            message_effect_id (``int`` ``64-bit``, *optional*):
                Unique identifier of the message effect to be added to the message; for private chats only.

            quote_entities (List of :obj:`~pyrogram.types.MessageEntity`, *optional*):
                List of special entities that appear in quote_text, which can be specified instead of *parse_mode*.
                for reply_to_message only.

            reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*):
                An inline keyboard. If empty, one 'Buy' button will be shown.

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

        Example:
            .. code-block:: python

                # USD (single prices)
                app.send_invoice(
                    chat_id,
                    title="Product Name",
                    description="Product Description",
                    currency="USD",
                    prices=types.LabeledPrice("Product", 1000),
                    provider="Stripe_provider_codes",
                    provider_data="{}"
                )

                # USD (multiple prices)
                app.send_invoice(
                    chat_id,
                    title="Product Name",
                    description="Product Description",
                    currency="USD",
                    prices=[
                        types.LabeledPrice("Product 1", 1000),
                        types.LabeledPrice("Product 2", 2000)
                    ],
                    provider="Stripe_provider_codes",
                    provider_data="{}"
                )

                # Telegram Stars
                app.send_invoice(
                    chat_id,
                    title="Product Name",
                    description="Product Description",
                    currency="XTR",
                    prices=types.LabeledPrice("Product", 1000)
                )
        NFTÚPayÚXTRr   u
   Pay â­�ï¸�)Útext)Úclientr	   r   r   r   r   c                 S   s   g | ]}|  ¡ ‘qS © )Úwrite)Ú.0Úpricer!   r!   úc/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pyrogram/methods/payments/send_invoice.pyÚ
<listcomp>Ç   ó    z,SendInvoice.send_invoice.<locals>.<listcomp>)r   r   z{})Údataz
image/jpeg)ÚurlÚsizeÚ	mime_typeÚ
attributes)	r
   r   Úinvoicer   r   r   ÚphotoÚstart_paramr   Ú )ÚpeerÚmediaÚallow_paid_floodskipÚeffectÚ	random_idÚreply_toÚmessager   c                 S   ó   i | ]}|j |“qS r!   ©Úid©r#   Úir!   r!   r%   Ú
<dictcomp>é   r'   z,SendInvoice.send_invoice.<locals>.<dictcomp>c                 S   r8   r!   r9   r;   r!   r!   r%   r=   ê   r'   )ÚusersÚchats)Ú
isinstancer   ÚLabeledPriceÚinline_keyboardÚInlineKeyboardButtonBuyÚamountÚinsertr   Úget_reply_toÚencodeÚinvoker   Ú	functionsÚmessagesÚ	SendMediaÚresolve_peerÚInputMediaInvoiceÚInvoicer"   ÚDataJSONÚInputWebDocumentÚrnd_idÚupdatesÚUpdateNewMessageÚUpdateNewChannelMessageÚMessageÚ_parser7   r>   r?   )r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Úis_iterableÚhas_buy_buttonr<   Újr   Úprices_totalr$   r6   Úencoded_payloadÚrr!   r!   r%   Úsend_invoice   sš   € 

€þ
ú	

þûüïæ
ÿ
þþüùÿzSendInvoice.send_invoice)NNNNNNNNNNNNNNN)	Ú__name__Ú
__module__Ú__qualname__r   ÚintÚstrr   Úboolr]   r!   r!   r!   r%   r      sv    ëÿ
þýüûúùø	÷
öõôóòñðïîíìër   )Úpyrogramr   r   r   Útypingr   r   r   r!   r!   r!   r%   Ú<module>   s   