§
    «eîi(  ã                   óp   — d Z ddlZddlmZ ddlmZ ddlmZmZ ddl	m
Z
 ddlmZ dZ G d	„ d
¦  «        ZdS )zDThis module contains an object that represents a Telegram InputFile.é    N)ÚIO)Úuuid4)Úguess_file_nameÚ	load_file)ÚTextEncoding)Ú
FieldTuplezapplication/octet-streamc            	       ó’   — e Zd ZdZdZ	 	 	 ddee         ez  ez  dedz  ded	efd
„Z	e
defd„¦   «         Ze
dedz  fd„¦   «         ZdS )Ú	InputFileaŒ  This object represents a Telegram InputFile.

    .. versionchanged:: 20.0

        * The former attribute ``attach`` was renamed to :attr:`attach_name`.
        * Method ``is_image`` was removed. If you pass :obj:`bytes` to :paramref:`obj` and would
          like to have the mime type automatically guessed, please pass :paramref:`filename`
          in addition.

    Args:
        obj (:term:`file object` | :obj:`bytes` | :obj:`str`): An open file descriptor or the files
            content as bytes or string.

            Note:
                If :paramref:`obj` is a string, it will be encoded as bytes via
                :external:obj:`obj.encode('utf-8') <str.encode>`.

            .. versionchanged:: 20.0
                Accept string input.
        filename (:obj:`str`, optional): Filename for this InputFile.
        attach (:obj:`bool`, optional): Pass :obj:`True` if the parameter this file belongs to in
            the request to Telegram should point to the multipart data via an ``attach://`` URI.
            Defaults to `False`.
        read_file_handle (:obj:`bool`, optional): If :obj:`True` and :paramref:`obj` is a file
            handle, the data will be read from the file handle on initialization of this object.
            If :obj:`False`, the file handle will be passed on to the
            :attr:`networking backend <telegram.request.BaseRequest.do_request>` which will have
            to handle the reading. Defaults to :obj:`True`.

            Tip:
                If you upload extremely large files, you may want to set this to :obj:`False` to
                avoid reading the complete file into memory. Additionally, this may be supported
                better by the networking backend (in particular it is handled better by
                the default :class:`~telegram.request.HTTPXRequest`).

            Important:
                If you set this to :obj:`False`, you have to ensure that the file handle is still
                open when the request is made. In particular, the following snippet can *not* work
                as expected.

                .. code-block:: python

                    with open('file.txt', 'rb') as file:
                        input_file = InputFile(file, read_file_handle=False)

                    # here the file handle is already closed and the upload will fail
                    await bot.send_document(chat_id, input_file)

            .. versionadded:: 21.5


    Attributes:
        input_file_content (:obj:`bytes` | :class:`IO`): The binary content of the file to send.
        attach_name (:obj:`str`): Optional. If present, the parameter this file belongs to in
            the request to Telegram should point to the multipart data via a an URI of the form
            ``attach://<attach_name>`` URI.
        filename (:obj:`str`): Filename for the file to be sent.
        mimetype (:obj:`str`): The mimetype inferred from the file to be sent.

    )Úattach_nameÚfilenameÚinput_file_contentÚmimetypeNFTÚobjr   ÚattachÚread_file_handlec                 ó  — t          |t          ¦  «        r|| _        npt          |t          ¦  «        r%|                     t
          j        ¦  «        | _        n6|rt          |¦  «        \  }| _        |p|}n|| _        |pt          |¦  «        }|rdt          ¦   «         j
        z   nd | _        |r)t          j        |d¬¦  «        d         pt          | _        nt          | _        |p| j                             dd¦  «        | _        d S )NÚattachedF)Ústrictr   ú/ú.)Ú
isinstanceÚbytesr   ÚstrÚencoder   ÚUTF_8r   r   r   Úhexr   Ú	mimetypesÚ
guess_typeÚ_DEFAULT_MIME_TYPEr   Úreplacer   )Úselfr   r   r   r   Úreported_filenames         ú]/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/telegram/_files/inputfile.pyÚ__init__zInputFile.__init__`   s  € õ �c�5Ñ!Ô!ð 		8Ø9<ˆDÔ#Ð#Ý˜�SÑ!Ô!ð 	8Ø&)§j¢jµÔ1CÑ&DÔ&DˆDÔ#Ð#Øð 	8Ý9BÀ3¹¼Ñ6Ð˜tÔ6ØÐ4Ð#4ˆHˆHà&)ˆDÔ#ØÐ7¥?°3Ñ#7Ô#7ˆHàCIÐ'S zµE±G´G´KÑ'?Ð'?ÈtˆÔàð 	/åÔ$ X°eÐ<Ñ<Ô<¸QÔ?ÐUÕCUð ŒMˆMõ /ˆDŒMà%ÐH¨¬×)>Ò)>¸sÀCÑ)HÔ)HˆŒˆˆó    Úreturnc                 ó*   — | j         | j        | j        fS )a  Field tuple representing the contents of the file for upload to the Telegram servers.

        .. versionchanged:: 21.5
            Content may now be a file handle.

        Returns:
            tuple[:obj:`str`, :obj:`bytes` | :class:`IO`, :obj:`str`]:
        )r   r   r   ©r!   s    r#   Úfield_tuplezInputFile.field_tuple}   s   € ð Œ}˜dÔ5°t´}ÐDÐDr%   c                 ó(   — | j         r
d| j         › �ndS )z…URI to insert into the JSON data for uploading the file. Returns :obj:`None`, if
        :attr:`attach_name` is :obj:`None`.
        z	attach://N)r   r(   s    r#   Ú
attach_urizInputFile.attach_uri‰   s#   € ð
 26Ô1AÐKÐ-˜4Ô+Ð-Ð-Ð-ÀtÐKr%   )NFT)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   Úboolr$   Úpropertyr   r)   r+   © r%   r#   r
   r
       sê   € € € € € ð;ð ;ðz N€Ið
  $ØØ!%ðIð Ià�ŒY˜Ñ Ñ$ðIð ˜‘*ðIð ð	Ið
 ðIð Ið Ið Ið: ð	E˜Zð 	Eð 	Eð 	Eñ „Xð	Eð ðL˜C $™Jð Lð Lð Lñ „XðLð Lð Lr%   r
   )r/   r   Útypingr   Úuuidr   Útelegram._utils.filesr   r   Útelegram._utils.stringsr   Útelegram._utils.typesr   r   r
   r3   r%   r#   ú<module>r9      sÆ   ðð& KÐ Jà Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,à/Ð ðnLð nLð nLð nLð nLñ nLô nLð nLð nLð nLr%   