
    i_                     h    d Z ddlZddlmZmZmZ ddl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OptionalUnion)uuid4)	load_file)
FieldTuplezapplication/octet-streamc                       e Zd ZdZdZ	 	 ddeee         eef         de	e         de
fdZed	efd
            Zed	e	e         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`.

    Attributes:
        input_file_content (:obj:`bytes`): 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mimetypeNFobjr   attachc                    t          |t                    r|| _        nKt          |t                    r|                    d          | _        nt          |          \  }| _        |p|}|rdt                      j        z   nd | _        |r)t          j
        |d          d         pt          | _        nt          | _        |p| j                            dd          | _        d S )Nzutf-8attachedF)strictr   /.)
isinstancebytesr   strencoder   r   hexr   	mimetypes
guess_type_DEFAULT_MIME_TYPEr   replacer   )selfr   r   r   reported_filenames        _/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/telegram/_files/inputfile.py__init__zInputFile.__init__D   s     c5!! 	5-0D##S!! 	5&)jj&9&9D##9B36t64#4HFL*V*uww{*B*BRV 	/$Xe<<<Q?UCU MM /DM%H)>)>sC)H)H    returnc                 *    | j         | j        | j        fS )zField tuple representing the contents of the file for upload to the Telegram servers.

        Returns:
            Tuple[:obj:`str`, :obj:`bytes`, :obj:`str`]:
        )r   r   r   r   s    r!   field_tuplezInputFile.field_tuple]   s     }d5t}DDr#   c                 (    | j         r
d| j          ndS )zURI 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_urif   s#    
 261AK-4+---tKr#   )NF)__name__
__module____qualname____doc__	__slots__r   r   r   r   r   boolr"   propertyr   r'   r)    r#   r!   r
   r
      s           D NI
 #'	I I2e9eS()I 3-I 	I I I I2 EZ E E E XE LHSM L L L XL L Lr#   r
   )r-   r   typingr   r   r   uuidr   telegram._utils.filesr   telegram._utils.typesr   r   r
   r1   r#   r!   <module>r6      s   & K J     & & & & & & & & & &       + + + + + + , , , , , ,/ LL LL LL LL LL LL LL LL LL LLr#   