
    x'h                         d dl Z d dlZd dlmZ 	 d dlmZ dZdefdZ	defdZ
defd	Zdefd
ZddZd ZdefdZy# e$ r dZY /w xY w)    N)BytesIO)ImageTFreturnc                 "    t        | t              S )z7
    Returns True if the given object is a string.
    )
isinstancestrvars    M/var/www/flask-api/venv/lib/python3.12/site-packages/telebot/service_utils.py	is_stringr      s     c3    c                 "    t        | t              S )z
    Returns True if the given object is a dictionary.

    :param var: object to be checked
    :type var: :obj:`object`

    :return: True if the given object is a dictionary.
    :rtype: :obj:`bool`
    )r   dictr	   s    r   is_dictr      s     c4  r   c                 "    t        | t              S )z
    Returns True if the given object is a bytes object.

    :param var: object to be checked
    :type var: :obj:`object`

    :return: True if the given object is a bytes object.
    :rtype: :obj:`bool`
    )r   bytesr	   s    r   is_bytesr   !   s     c5!!r   c                 F    t         xr t        | t        j                        S )z
    Returns True if the given object is a PIL.Image.Image object.

    :param var: object to be checked
    :type var: :obj:`object`

    :return: True if the given object is a PIL.Image.Image object.
    :rtype: :obj:`bool`
    )pil_importedr   r   r	   s    r   is_pil_imager   .   s     8JsEKK88r   c                     t         r@t               }| j                  d      j                  |||       |j	                  d       |S t        d      )NRGB)qualityr   zPIL module is not imported)r   r   convertsaveseekRuntimeError)image	extensionr   photoBuffers       r   pil_image_to_filer!   ;   sJ    ie!!+y'!J788r   c              #   V   K   t        dt        |       |      D ]  }| |||z      yw)z)Yield successive n-sized chunks from lst.r   N)rangelen)lstnis      r   chunksr(   F   s4      1c#h" !AEls   ')c                  h    dj                  t        j                  t        j                  d            S )z
    Generates a random token consisting of letters and digits, 16 characters long.

    :return: a random token
    :rtype: :obj:`str`
        )joinrandomsamplestringascii_letters r   r   generate_random_tokenr2   M   s$     776==!5!5r:;;r   )JPEGweb_low)r-   r/   ior   PILr   r   ImportErrorboolr   r   r   r   r!   r(   r   r2   r1   r   r   <module>r9      sx      L
 d  
!D 
!
"T 
"
9 
99<s <I  Ls   > AA