Ë
    ®¦jH\  ã                   ó^  — d dl Z d dlZd dlZd dlmZmZmZmZmZm	Z	 d dl
Z
d dlmZ d dlmZ d dlZd dlZd dlmZ d dlmZmZmZmZmZmZmZ 	 d dlZdZ ej@                  d«      Z! ejD                  «       Z#g d	¢Z$g d
¢Z%g d¢Z& G d„ dejN                  «      Z( G d„ d«      Z) G d„ d«      Z* G d„ d«      Z+d„ Z,de-de.fd„Z/de-de	e-df   fd„Z0de-de	e-df   fd„Z1de-dejd                  de-fd„Z3de-de4dee-   fd„Z5efde-de4dee-   fd„Z6de-dee-   fd„Z7d;d ejp                  d!e.de-fd"„Z9d<d#ee-ee-ef   f   d$e4dejt                  fd%„Z;d&„ Z<d'„ Z=d(„ Z>d)„ Z?d;d*„Z@d=d+e.d,ee   fd-„ZAd.„ ZBd/d0œd1efd2„ZCd/d0œd1efd3„ZDd4e-d5e-fd6„ZEd4e-d5e-fd7„ZFde.fd8„ZGde	e4df   fd9„ZHd:ZIy# e$ r d dlZY �ŒYw xY w)>é    N)ÚAnyÚCallableÚListÚDictÚOptionalÚUnion)Úsha256)Ú	parse_qsl)Útypes)Úis_pil_imageÚis_dictÚ	is_stringÚis_bytesÚchunksÚgenerate_random_tokenÚpil_image_to_filei   ÚTeleBot)ÚtextÚaudioÚdocumentÚ	animationÚgameÚphotoÚstickerÚvideoÚ
video_noteÚvoiceÚcontactÚlocationÚvenueÚdiceÚinvoiceÚsuccessful_paymentÚconnected_websiteÚpollÚpassport_dataÚweb_app_dataÚstoryÚgiveawayÚgiftÚunique_gift)1Únew_chat_membersÚleft_chat_memberÚnew_chat_titleÚnew_chat_photoÚdelete_chat_photoÚgroup_chat_createdÚsupergroup_chat_createdÚchannel_chat_createdÚmigrate_to_chat_idÚmigrate_from_chat_idÚpinned_messageÚproximity_alert_triggeredÚvideo_chat_scheduledÚvideo_chat_startedÚvideo_chat_endedÚvideo_chat_participants_invitedÚ!message_auto_delete_timer_changedÚchat_background_setÚforum_topic_createdÚforum_topic_closedÚforum_topic_reopenedÚforum_topic_editedÚgeneral_forum_topic_hiddenÚgeneral_forum_topic_unhiddenÚwrite_access_allowedÚusers_sharedÚchat_sharedÚgiveaway_createdÚgiveaway_winnersÚgiveaway_completedÚboost_addedÚpaid_message_price_changedÚchecklist_tasks_doneÚchecklist_tasks_addedÚdirect_message_price_changedÚsuggested_post_refundedÚsuggested_post_infoÚsuggested_post_approvedÚsuggested_post_approval_failedÚsuggested_post_declinedÚsuggested_post_paidÚgift_upgrade_sentÚchat_owner_leftÚchat_owner_changedÚmanaged_bot_createdÚpoll_option_addedÚpoll_option_deletedÚcommunity_chat_addedÚcommunity_chat_removed)ÚmessageÚedited_messageÚchannel_postÚedited_channel_postÚinline_queryÚchosen_inline_resultÚcallback_queryÚshipping_queryÚpre_checkout_queryr%   Úpoll_answerÚmy_chat_memberÚchat_memberÚchat_join_requestÚmessage_reactionÚmessage_reaction_countÚremoved_chat_boostÚ
chat_boostÚbusiness_connectionÚbusiness_messageÚedited_business_messageÚdeleted_business_messagesÚpurchased_paid_mediaÚmanaged_botÚguest_messageÚsubscriptionc                   ó:   — e Zd ZdZdZd
d„Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
y)ÚWorkerThreadú
    :meta private:
    r   Nc                 ó2  — |sGdj                  | j                  j                  dz   «      }| j                  xj                  dz  c_        |st        j                  «       }t        j
                  j                  | |¬«       || _        d| _        t	        j                  «       | _
        t	        j                  «       | _        t	        j                  «       | _        t	        j                  «       | _        || _        d | _        d| _        | j#                  «        y )NzWorkerThread{0}é   )ÚnameT)ÚformatÚ	__class__ÚcountÚQueueÚ	threadingÚThreadÚ__init__ÚqueueÚdaemonÚEventÚreceived_task_eventÚ
done_eventÚexception_eventÚcontinue_eventÚexception_callbackÚexception_infoÚ_runningÚstart)ÚselfrŠ   rƒ   r{   s       ú?/var/www/html/venv/lib/python3.12/site-packages/telebot/util.pyr‚   zWorkerThread.__init__B   sÉ   € ÙØ$×+Ñ+¨D¯N©N×,@Ñ,@À1Ñ,DÓEˆDØ�N‰N× Ò  AÑ%Õ ÙÜ—K‘K“MˆEä×Ñ×!Ñ! $¨TÐ!Ô2ØˆŒ
ØˆŒä#,§?¡?Ó#4ˆÔ Ü#Ÿ/™/Ó+ˆŒÜ(Ÿ™Ó0ˆÔÜ'Ÿo™oÓ/ˆÔà"4ˆÔØ"ˆÔØˆŒØ�
‰
�ó    c                 óä  — | j                   rþ	 | j                  j                  dd¬«      \  }}}| j                  j	                  «        | j
                  j	                  «        | j                  j	                  «        | j                  j	                  «        t        j                  d«       | j
                  j                  «         ||i |¤Ž t        j                  d«       | j                  j                  «        | j                   rŒýy y # t        j                  $ r Y Œ$t        $ rÆ}t        j                  t        |«      j                  dz   t!        |j"                  «      z   dz   t%        j&                  «       z   «       || _        | j                  j                  «        | j*                  r| j+                  | | j(                  «       | j                  j-                  «        Y d }~Œíd }~ww xY w)NTg      à?)ÚblockÚtimeoutzReceived taskzTask completez occurred, args=ú
)rŒ   rƒ   Úgetr‰   Úclearr†   r‡   rˆ   ÚloggerÚdebugÚsetr   ÚEmptyÚ	ExceptionÚtypeÚ__name__ÚstrÚargsÚ	tracebackÚ
format_excr‹   rŠ   Úwait)rŽ   ÚtaskrŸ   ÚkwargsÚes        r�   ÚrunzWorkerThread.runW   sn  € Ø�mŠmð+Ø%)§Z¡Z§^¡^¸$È ^Ó%KÑ"��d˜FØ×#Ñ#×)Ñ)Ô+Ø×(Ñ(×.Ñ.Ô0Ø—‘×%Ñ%Ô'Ø×$Ñ$×*Ñ*Ô,Ü—‘˜_Ô-Ø×(Ñ(×,Ñ,Ô.á�dÐ%˜fÒ%Ü—‘˜_Ô-Ø—‘×#Ñ#Ô%ð �m�møô —;‘;ò ÙÜò +Ü—‘œT !›W×-Ñ-Ð0BÑBÄSÈÏÉÃ[ÑPÐSWÑWÔZc×ZnÑZnÓZpÑpÔqØ&'�Ô#Ø×$Ñ$×(Ñ(Ô*Ø×*Ò*Ø×+Ñ+¨D°$×2EÑ2EÔFØ×#Ñ#×(Ñ(×*Ñ*ûð+ús   ŽC/D ÄG/Ä!G/Ä)B<G*Ç*G/c                 ó@   — | j                   j                  |||f«       y ©N)rƒ   Úput)rŽ   r£   rŸ   r¤   s       r�   r©   zWorkerThread.puto   ó   € Ø�
‰
�‰˜˜d FÐ+Õ,r�   c                 óP   — | j                   j                  «       r| j                  ‚y r¨   ©rˆ   Úis_setr‹   ©rŽ   s    r�   Úraise_exceptionszWorkerThread.raise_exceptionsr   ó%   € Ø×Ñ×&Ñ&Ô(Ø×%Ñ%Ð%ð )r�   c                 ól   — | j                   j                  «        | j                  j                  «        y r¨   )rˆ   r–   r‰   r™   r®   s    r�   Úclear_exceptionszWorkerThread.clear_exceptionsv   s&   € Ø×Ñ×"Ñ"Ô$Ø×Ñ×ÑÕ!r�   c                 ó   — d| _         y ©NF)rŒ   r®   s    r�   ÚstopzWorkerThread.stopz   s	   € Øˆ�r�   )NNN)r�   Ú
__module__Ú__qualname__Ú__doc__r~   r‚   r¦   r©   r¯   r²   rµ   © r�   r�   rw   rw   <   s,   „ ñð €Eóò*+ò0-ò&ò"ór�   rw   c                   ó6   — e Zd ZdZd	d„Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)
Ú
ThreadPoolrx   c                 ó  — || _         t        j                  «       | _        t        |«      D �cg c]"  }t	        | j
                  | j                  «      ‘Œ$ c}| _        || _        t        j                  «       | _
        d | _        y c c}w r¨   )Útelebotr   ÚtasksÚrangerw   Úon_exceptionÚworkersÚnum_threadsr€   r…   rˆ   r‹   )rŽ   r½   rÂ   Ú_s       r�   r‚   zThreadPool.__init__ƒ   sd   € ØˆŒÜ—[‘[“]ˆŒ
ÜMRÐS^ÓM_Ö`Èœ T×%6Ñ%6¸¿
¹
ÕCÒ`ˆŒØ&ˆÔä(Ÿ™Ó0ˆÔØ"ˆÕùò	 as   ®'Bc                 ó@   — | j                   j                  |||f«       y r¨   )r¾   r©   )rŽ   ÚfuncrŸ   r¤   s       r�   r©   zThreadPool.putŒ   rª   r�   c                 óú   — | j                   j                  �&| j                   j                  j                  |«      }nd}|s!|| _        | j                  j                  «        |j                  j                  «        y r´   )r½   Úexception_handlerÚhandler‹   rˆ   r™   r‰   )rŽ   Úworker_threadÚexc_infoÚhandleds       r�   rÀ   zThreadPool.on_exception�   s`   € Ø�<‰<×)Ñ)Ð5Ø—l‘l×4Ñ4×;Ñ;¸HÓE‰GàˆGÙØ"*ˆDÔØ× Ñ ×$Ñ$Ô&Ø×$Ñ$×(Ñ(Õ*r�   c                 óP   — | j                   j                  «       r| j                  ‚y r¨   r¬   r®   s    r�   r¯   zThreadPool.raise_exceptions™   r°   r�   c                 ó8   — | j                   j                  «        y r¨   )rˆ   r–   r®   s    r�   r²   zThreadPool.clear_exceptions�   s   € Ø×Ñ×"Ñ"Õ$r�   c                 ó¸   — | j                   D ]  }|j                  «        Œ | j                   D ]*  }|t        j                  «       k7  sŒ|j	                  «        Œ, y r¨   )rÁ   rµ   r€   Úcurrent_threadÚjoin)rŽ   Úworkers     r�   ÚclosezThreadPool.close    sK   € Ø—l‘lò 	ˆFØ�K‰K�Mð	à—l‘lò 	ˆFØœ×1Ñ1Ó3Ó3Ø—‘•ñ	r�   N©é   )
r�   r¶   r·   r¸   r‚   r©   rÀ   r¯   r²   rÒ   r¹   r�   r�   r»   r»   ~   s%   „ ñó#ò-ò+ò&ò%ór�   r»   c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)Ú	AsyncTaskrx   c                 óº   — || _         || _        || _        d| _        t	        j
                  | j                  ¬«      | _        | j                  j                  «        y )NF)Útarget)	rØ   rŸ   r¤   Údoner€   r�   Ú_runÚthreadr�   )rŽ   rØ   rŸ   r¤   s       r�   r‚   zAsyncTask.__init__­   sD   € ØˆŒØˆŒ	ØˆŒàˆŒ	Ü×&Ñ&¨d¯i©iÔ8ˆŒØ�‰×ÑÕr�   c                 ó²   — 	  | j                   | j                  i | j                  ¤Ž| _        d| _        y # t        $ r}|| _        Y d }~d| _        y d }~ww xY w)NT)rØ   rŸ   r¤   Úresultr›   rÙ   )rŽ   r¥   s     r�   rÚ   zAsyncTask._run¶   sQ   € ð	Ø%˜$Ÿ+™+ t§y¡yÐ@°D·K±KÑ@ˆDŒKð ˆ�	øô ò 	ØˆD�KˆKØˆ�	ûð	ús   ‚+5 µ	A¾AÁAc                 ó²   — | j                   s| j                  j                  «        t        | j                  t
        «      r| j                  ‚| j                  S r¨   )rÙ   rÛ   rÐ   Ú
isinstancerÝ   ÚBaseExceptionr®   s    r�   r¢   zAsyncTask.wait½   s;   € Ø�yŠyØ�K‰K×ÑÔÜ�d—k‘k¤=Ô1Ø—+‘+Ðà—;‘;Ðr�   N)r�   r¶   r·   r¸   r‚   rÚ   r¢   r¹   r�   r�   rÖ   rÖ   ¨   s   „ ñòòór�   rÖ   c                   ó   — e Zd ZdZdd„Zd„ Zy)ÚCustomRequestResponserx   c                 ó.   — || _         || _        || _        y r¨   )Ústatus_coder   Úreason)rŽ   Ú	json_texträ   rå   s       r�   r‚   zCustomRequestResponse.__init__Ë   s   € Ø&ˆÔØˆŒ	Øˆ�r�   c                 ó@   — t        j                  | j                  «      S r¨   )ÚjsonÚloadsr   r®   s    r�   rè   zCustomRequestResponse.jsonÐ   s   € Ü�z‰z˜$Ÿ)™)Ó$Ð$r�   N)éÈ   Ú )r�   r¶   r·   r¸   r‚   rè   r¹   r�   r�   râ   râ   Æ   s   „ ñóó
%r�   râ   c                  ó   — d„ } | S )rx   c                 ó   ‡ — ˆ fd„}|S )Nc                  ó"   •— t        ‰g| ¢­i |¤ŽS r¨   )rÖ   )rŸ   r¤   Úfns     €r�   Úwrapperz-async_dec.<locals>.decorator.<locals>.wrapperÚ   s   ø€ Ü˜RÐ1 $Ò1¨&Ñ1Ð1r�   r¹   )rï   rð   s   ` r�   Ú	decoratorzasync_dec.<locals>.decoratorÙ   s   ø€ ô	2ð ˆr�   r¹   )rñ   s    r�   Ú	async_decrò   Ô   s   € ò
ð Ðr�   r   Úreturnc                 ó*   — | €y| j                  d«      S )zì
    Checks if `text` is a command. Telegram chat commands start with the '/' character.
    
    :param text: Text to check.
    :type text: :obj:`str`

    :return: True if `text` is a command, else False.
    :rtype: :obj:`bool`
    Fú/)Ú
startswith©r   s    r�   Ú
is_commandrø   â   s   € ð €|˜EØ�?‰?˜3ÓÐr�   c                 ór   — | €yt        | «      r(| j                  «       d   j                  d«      d   dd S dS )av  
    Extracts the command from `text` (minus the '/') if `text` is a command (see is_command).
    If `text` is not a command, this function returns None.

    .. code-block:: python3
        :caption: Examples:
        
        extract_command('/help'): 'help'
        extract_command('/help@BotName'): 'help'
        extract_command('/search black eyed peas'): 'search'
        extract_command('Good day to you'): None

    :param text: String to extract the command from
    :type text: :obj:`str`

    :return: the command if `text` is a command (according to is_command), else None.
    :rtype: :obj:`str` or :obj:`None`
    Nr   ú@rz   )rø   Úsplitr÷   s    r�   Úextract_commandrü   ð   s>   € ð& €|˜DÜ0:¸4Ô0@ˆ4�:‰:‹<˜‰?× Ñ  Ó% aÑ(¨¨Ð,ÐJÀdÐJr�   c                 ó¨   — t        j                  dt         j                  «      }|j                  | «      }t	        | «      r|j                  d«      S dS )aÚ  
    Returns the argument after the command.
    
    .. code-block:: python3
        :caption: Examples:

        extract_arguments("/get name"): 'name'
        extract_arguments("/get"): ''
        extract_arguments("/get@botName name"): 'name'
    
    :param text: String to extract the arguments from a command
    :type text: :obj:`str`

    :return: the arguments if `text` is a command (according to is_command), else None.
    :rtype: :obj:`str` or :obj:`None`
    z/\w*(@\w*)*\s*([\s\S]*)rÔ   N)ÚreÚcompileÚ
IGNORECASEÚmatchrø   Úgroup)r   ÚregexprÝ   s      r�   Úextract_argumentsr    sA   € ô" �Z‰ZÐ2´B·M±MÓB€FØ�\‰\˜$Ó€FÜ(¨Ô.ˆ6�<‰<˜‹?Ð8°DÐ8r�   r¥   c                 ó  — d}d}| j                  «       }t        |«      }d}|D ]Q  }|dz  dk7  rB||j                  k(  r|}n ||j                  z
  |j                  k(  r|} n|dk\  r|dz  }n|dz  }|dz  }ŒS ||| j	                  «       S )a  
    Returns the content of the entity.
    
    :param text: The text of the message the entity belongs to
    :type text: :obj:`str`
    
    :param e: The entity to extract
    :type e: :obj:`MessageEntity`
    
    :return: The content of the entity
    :rtype: :obj:`str`
    r   éÀ   é€   éð   rÔ   rz   )ÚencodeÚlenÚoffsetÚlengthÚdecode)r   r¥   r  r�   Úencoded_textÚendÚiÚbytes           r�   Úextract_entityr    s«   € ð €FØ€EØ—;‘;“=€LÜ
ˆlÓ
€CØ	€Aàò ˆØ�4‰K˜DÒ Ø˜Ÿ™Ò!Ø‘Ø˜!Ÿ(™(Ñ" a§h¡hÒ.Ø�ÙØ�tŠ|Ø˜!‘‘à˜!‘�Ø	ˆQ‰‰ðð ˜˜cÐ"×)Ñ)Ó+Ð+r�   Úchars_per_stringc                 ó`   — t        dt        | «      |«      D �cg c]
  }| |||z    ‘Œ c}S c c}w )a×  
    Splits one string into multiple strings, with a maximum amount of `chars_per_string` characters per string.
    This is very useful for splitting one giant message into multiples.

    :param text: The text to split
    :type text: :obj:`str`

    :param chars_per_string: The number of characters per line the text is split into.
    :type chars_per_string: :obj:`int`

    :return: The splitted text as a list of strings.
    :rtype: :obj:`list` of :obj:`str`
    r   )r¿   r
  )r   r  r  s      r�   Úsplit_stringr  >  s3   € ô 38¸¼3¸t»9ÐFVÓ2WÖX¨QˆD��1Ð'Ñ'Ò(ÒXÐXùÒXs   ™+c                 ó$  ‡— dt         dt         fˆfd„}|t        kD  rt        }g }	 t        | «      |k  r|j                  | «       |S | d| Šd‰v r	 |d«      Šnd‰v r	 |d«      Šnd‰v r |d«      Š|j                  ‰«       | t        ‰«      d } Œl)aT  
    Splits one string into multiple strings, with a maximum amount of `chars_per_string` characters per string.
    This is very useful for splitting one giant message into multiples.
    If `chars_per_string` > 4096: `chars_per_string` = 4096.
    Splits by '\n', '. ' or ' ' in exactly this priority.

    :param text: The text to split
    :type text: :obj:`str`

    :param chars_per_string: The number of maximum characters per part the text is split to.
    :type chars_per_string: :obj:`int`

    :return: The splitted text as a list of strings.
    :rtype: :obj:`list` of :obj:`str`
    Úsubstrró   c                 óP   •— | j                  ‰j                  | «      d d «      | z   S )Néÿÿÿÿ)rÐ   rû   )r  Úparts    €r�   Ú_text_before_lastz&smart_split.<locals>._text_before_last`  s'   ø€ Ø�{‰{˜4Ÿ:™: fÓ-¨c¨rÐ2Ó3°fÑ<Ð<r�   Nr”   z. ú )rž   ÚMAX_MESSAGE_LENGTHr
  Úappend)r   r  r  Úpartsr  s       @r�   Úsmart_splitr   O  s¯   ø€ ð"=¤#ð =¬#õ =ð Ô,Ò,ÔASÐ.>à€EØ
Üˆt‹9Ð'Ò'Ø�L‰L˜ÔØˆLàÐ%Ð%Ð&ˆà�4‰<Ù$ TÓ*‰DØ�T‰\Ù$ TÓ*‰DØ�D‰[Ù$ SÓ)ˆDà�‰�TÔØ”C˜“I�JÐˆð r�   c                 ól   — ddddœ}| €y|j                  «       D ]  \  }}| j                  ||«      } Œ | S )z¬
    Replaces the following chars in `text` ('&' with '&amp;', '<' with '&lt;' and '>' with '&gt;').

    :param text: the text to escape
    :return: the escaped text
    z&amp;z&lt;z&gt;)ú&ú<ú>N)ÚitemsÚreplace)r   ÚcharsÚoldÚnews       r�   Úescaper*  x  sF   € ð  ¨VÑ4€EØ€|ØØ—K‘K“Mò &‰ˆˆSØ�|‰|˜C Ó%‰ð&à€Kr�   ÚuserÚ
include_idc                 ó€   — t        | j                  «      }d| j                  › d|› d�|rd| j                  › d�z   S dz   S )aæ  
    Returns an HTML user link. This is useful for reports.
    Attention: Don't forget to set parse_mode to 'HTML'!


    .. code-block:: python3
        :caption: Example:

        bot.send_message(your_user_id, user_link(message.from_user) + ' started the bot!', parse_mode='HTML')

    .. note::
        You can use formatting.* for all other formatting options(bold, italic, links, and etc.)
        This method is kept for backward compatibility, and it is recommended to use formatting.* for
        more options.

    :param user: the user (not the user_id)
    :type user: :obj:`telebot.types.User`

    :param include_id: include the user_id
    :type include_id: :obj:`bool`

    :return: HTML user link
    :rtype: :obj:`str`
    z<a href='tg://user?id=z'>z</a>z (<pre>z</pre>)rë   )r*  Ú
first_nameÚid)r+  r,  r{   s      r�   Ú	user_linkr0  ‡  sU   € ô2 �$—/‘/Ó"€DØ$ T§W¡W I¨R°¨v°TÐ:Ù-7�˜Ÿ™˜	 Ð)ñAð BØ=?ñAð Br�   ÚvaluesÚ	row_widthc           	      óÊ   — t        j                  |¬«      }| j                  «       D ��cg c]  \  }}t        j                  dd|i|¤Ž‘Œ }}} |j                  |Ž  |S c c}}w )aK  
    Returns a reply markup from a dict in this format: {'text': kwargs}
    This is useful to avoid always typing 'btn1 = InlineKeyboardButton(...)' 'btn2 = InlineKeyboardButton(...)' 
    
    Example:

    .. code-block:: python3
        :caption: Using quick_markup:

        from telebot.util import quick_markup

        markup = quick_markup({
            'Twitter': {'url': 'https://twitter.com'},
            'Facebook': {'url': 'https://facebook.com'},
            'Back': {'callback_data': 'whatever'}
        }, row_width=2)
        # returns an InlineKeyboardMarkup with two buttons in a row, one leading to Twitter, the other to facebook
        # and a back button below

        # kwargs can be: 
        {
            'url': None, 
            'callback_data': None, 
            'switch_inline_query': None,
            'switch_inline_query_current_chat': None,
            'callback_game': None,
            'pay': None,
            'login_url': None,
            'web_app': None
        }
    
    :param values: a dict containing all buttons to create in this format: {text: kwargs} {str:}
    :type values: :obj:`dict`

    :param row_width: number of :class:`telebot.types.InlineKeyboardButton` objects on each row
    :type row_width: :obj:`int`

    :return: InlineKeyboardMarkup
    :rtype: :obj:`types.InlineKeyboardMarkup`
    )r2  r   r¹   )r   ÚInlineKeyboardMarkupr%  ÚInlineKeyboardButtonÚadd)r1  r2  Úmarkupr   r¤   Úbuttonss         r�   Úquick_markupr9  ¥  sk   € ôR ×'Ñ'°)Ô<€Fð #ŸL™L›N÷áˆD�&ô 	×"Ñ"Ñ7¨Ð7°Ó7ð€Gñ ð €F‡J�J�ÑØ€Mùós   ª!Ac                 óD   — | j                  «        | j                  «        y©rx   N)Ú_setÚchangedr®   s    r�   Úor_setr>  Ø  s   € ð 	‡I�I„KØ‡L�L…Nr�   c                 óD   — | j                  «        | j                  «        yr;  )Ú_clearr=  r®   s    r�   Úor_clearrA  à  s   € ð 	‡K�K„MØ‡L�L…Nr�   c                 ó°   ‡ — t        ‰ d«      s‰ j                  ‰ _        t        ‰ d«      s‰ j                  ‰ _        |‰ _        ˆ fd„‰ _        ˆ fd„‰ _        y)rx   r<  r@  c                  ó   •— t        ‰ «      S r¨   )r>  ©r¥   s   €r�   ú<lambda>zorify.<locals>.<lambda>ñ  s   ø€ ”F˜1“I€ r�   c                  ó   •— t        ‰ «      S r¨   )rA  rD  s   €r�   rE  zorify.<locals>.<lambda>ò  s   ø€ ”h˜q“k€ r�   N)Úhasattrr™   r<  r–   r@  r=  )r¥   Úchanged_callbacks   ` r�   ÚorifyrI  è  sD   ø€ ô �1�fÔØ—‘ˆŒÜ�1�hÔØ—7‘7ˆŒØ €A„IÛ€A„EÛ!€A…Gr�   c                  ó¬   ‡ ‡— t        j                  «       Šˆ ˆfd„}ˆfd„}‰ D ]  }t        ||«       Œ ‰j                  ‰_        |‰_         |«        ‰S )rx   c                  ó¢   •— ‰D � cg c]  } | j                  «       ‘Œ }} t        |«      r‰j                  «        y ‰j                  «        y c c} w r¨   )r­   Úanyr™   r–   )ÚevÚboolsÚeventsÚor_events     €€r�   r=  zOrEvent.<locals>.changedû  s;   ø€ Ø'-Ö. �—‘•Ð.ˆÐ.ÜˆuŒ:Ø�L‰L�Nà�N‰NÕùò	 /s   †Ac                  ól   •— ‰ j                  «       s#‰ j                  d«       ‰ j                  «       sŒ"y y )Né   )r­   Ú_wait)rP  s   €r�   Ú	busy_waitzOrEvent.<locals>.busy_wait  s%   ø€ Ø—/‘/Ô#à�N‰N˜1Ôð —/‘/×#r�   )r€   r…   rI  r¢   rS  )rO  r=  rT  r¥   rP  s   `   @r�   ÚOrEventrU  õ  sR   ù€ ô �‰Ó €Hõôð
 ò ˆÜˆa�Õðà—]‘]€H„NØ€H„MÙ„IØ€Or�   c                 óv   — |st        t        | «      s |«       }t        t        | |«       t        t        | «      S )rx   )rG  Úthread_localÚsetattrÚgetattr)ÚkeyÚconstruct_valueÚresetÚvalues       r�   Ú
per_threadr^    s1   € ñ ”GœL¨#Ô.ÙÓ!ˆÜ”˜c 5Ô)ä”< Ó%Ð%r�   ÚwarnÚalternativec                 ó   ‡ ‡‡— ˆˆˆ fd„}|S )aß  
    Use this decorator to mark functions as deprecated.
    When the function is used, an info (or warning if `warn` is True) is logged.

    :meta private:
    
    :param warn: If True a warning is logged else an info
    :type warn: :obj:`bool`

    :param alternative: The new function to use instead
    :type alternative: :obj:`Callable`

    :param deprecation_text: Custom deprecation text
    :type deprecation_text: :obj:`str`

    :return: The decorated function
    c                 ó   •‡ — ˆˆˆ ˆfd„}|S )Nc                  óÌ   •— d‰j                   › d�}‰r|d‰j                   › d�z  }‰r|d‰z   z  }‰st        j                  |«       nt        j                  |«        ‰| i |¤ŽS )Nú`z` is deprecated.z Use `z	` insteadr  )r�   r—   ÚinfoÚwarning)rŸ   r¤   re  r`  Údeprecation_textÚfunctionr_  s      €€€€r�   rð   z.deprecated.<locals>.decorator.<locals>.wrapper.  st   ø€ Ø�x×(Ñ(Ð)Ð)9Ð:ˆDÙØ˜& ×!5Ñ!5Ð 6°iÐ@Ñ@�ÙØ˜Ð.Ñ.Ñ.�ÙÜ—‘˜DÕ!ä—‘˜tÔ$Ù˜TÐ, VÑ,Ð,r�   r¹   )rh  rð   r`  rg  r_  s   ` €€€r�   rñ   zdeprecated.<locals>.decorator-  s   ù€ ÷
	-ð ˆr�   r¹   )r_  r`  rg  rñ   s   ``` r�   Ú
deprecatedri    s   ú€ ö&ð Ðr�   c                 óä   — |j                   rC	 |j                  «       }t        j                  j	                  |«      }| j                  |g«       yy# t        $ r}t        |«       Y d}~yd}~ww xY w)a(  
    A webhook endpoint for Google Cloud Functions FaaS.
    
    :param bot: The bot instance
    :type bot: :obj:`telebot.TeleBot` or :obj:`telebot.async_telebot.AsyncTeleBot`

    :param request: The request object
    :type request: :obj:`flask.Request`

    :return: The response object
    rë   N)zBot FAILi�  zBot ON)Úis_jsonÚget_jsonr   ÚUpdateÚde_jsonÚprocess_new_updatesr›   Úprint)ÚbotÚrequestÚrequest_jsonÚupdater¥   s        r�   Úwebhook_google_functionsru  @  sf   € ð ‡‚ð	#Ø"×+Ñ+Ó-ˆLÜ—\‘\×)Ñ)¨,Ó7ˆFØ×#Ñ# V HÔ-Øð
 øô	 ò 	#Ü�!ŒHÜ"ûð	#ús   ŽAA Á	A/ÁA*Á*A/é   )Únumber_retriesrh  c                óÚ   — ddl m} ddlm} t	        |dz
  «      D ]  }	  | |i |¤Žc S   | |i |¤ŽS # |$ r3}|j
                  dk(  r ||j                  d   d   «       n‚ Y d}~ŒJd}~ww xY w)	a‡  
    Use this function inside loops in order to avoid getting TooManyRequests error.
    Example:
    
    .. code-block:: python3
    
        from telebot.util import antiflood
        for chat_id in chat_id_list:
        msg = antiflood(bot.send_message, chat_id, text)
        
    :param function: The function to call
    :type function: :obj:`Callable`

    :param number_retries: Number of retries to send
    :type function: :obj:int

    :param args: The arguments to pass to the function
    :type args: :obj:`tuple`

    :param kwargs: The keyword arguments to pass to the function
    :type kwargs: :obj:`dict`

    :return: None
    r   ©ÚApiTelegramException)Úsleeprz   é­  Ú
parametersÚretry_afterN)Útelebot.apihelperrz  Útimer{  r¿   Ú
error_codeÚresult_json)rh  rw  rŸ   r¤   rz  r{  rÃ   Úexs           r�   Ú	antifloodr„  Y  s‡   € õ2 7Ýä�> AÑ%Ó&ò 	)ˆð	Ù˜TÐ, VÑ,Ò,ð	)ñ ˜Ð( Ñ(Ð(øð $ò 	Ø�}‰} Ò#Ù�b—n‘n \Ñ2°=ÑAÕBàô Cûð	ús   Ÿ2²A*·)A%Á%A*c             �   ó*  K  — ddl m} ddl}t        |dz
  «      D ]  }	  | |i |¤Žƒ d{  –—† c S   | |i |¤Žƒ d{  –—† S 7 Œ# |$ rE}|j                  dk(  r+|j                  |j                  d   d   «      ƒ d{  –—†7   n‚ Y d}~Œnd}~ww xY w7 ŒS­w)aZ  
    Async counterpart to :func:`antiflood`. Awaits ``function(*args, **kwargs)``
    in a retry loop that honours Telegram's ``retry_after`` parameter on 429
    responses. Use with :obj:`telebot.async_telebot.AsyncTeleBot` calls.

    Example:

    .. code-block:: python3

        from telebot.util import async_antiflood

        for chat_id in chat_id_list:
            msg = await async_antiflood(bot.send_message, chat_id, text)

    :param function: The awaitable callable to invoke. Called fresh on each
        attempt, so pass the function itself (for example ``bot.send_message``),
        not a pre-awaited coroutine.
    :type function: :obj:`Callable`

    :param number_retries: Total number of attempts. After ``number_retries - 1``
        retried 429 responses the final call is issued without the 429 guard,
        so its exception will propagate.
    :type number_retries: :obj:`int`

    :param args: Positional arguments forwarded to ``function``.
    :param kwargs: Keyword arguments forwarded to ``function``.

    :return: Whatever ``function`` returns on the first successful call.
    r   ry  Nrz   r|  r}  r~  )Útelebot.asyncio_helperrz  Úasyncior¿   r�  r{  r‚  )rh  rw  rŸ   r¤   rz  r‡  rÃ   rƒ  s           r�   Úasync_antifloodrˆ  �  s£   è ø€ õ< <Ûä�> AÑ%Ó&ò ˆð	Ù! 4Ð2¨6Ñ2×2Ò2ðñ ˜4Ð* 6Ñ*×*Ð*ð 3ùØ#ò 	Ø�}‰} Ò#Ø—m‘m B§N¡N°<Ñ$@ÀÑ$OÓP×PÒPàô Qûð	úð
 +úsS   ‚BŸAªA«A®B½B¾BÁAÁBÁ	3B	Á<A?Á=B	ÂBÂ	BÂBÚtokenÚraw_init_datac                 óÀ   — t        | |«      }|syi }t        |«      D ]   \  }}	 t        j                  |«      }|||<   Œ" |S # t        j                  $ r |||<   Y Œ?w xY w)zÏ
    Parses web app data.

    :param token: The bot token
    :type token: :obj:`str`

    :param raw_init_data: The raw init data
    :type raw_init_data: :obj:`str`

    :return: The parsed init data
    F)Úvalidate_web_app_datar
   rè   ré   ÚJSONDecodeError)r‰  rŠ  Úis_validrÝ   rZ  r]  s         r�   Úparse_web_app_datar�  ­  sx   € ô % U¨MÓ:€HÙØà€FÜ Ó.ò  ‰
ˆˆUð	 Ü—J‘J˜uÓ%ˆEð  ˆF�3ŠKð ð €Møô	 ×#Ñ#ò 	 ØˆF�3‹Kð	 ús   ¤AÁAÁAc                 ó¸  — 	 t        t        |«      «      }d|vry|j                  d«      }dj	                  d„ t        |j                  «       «      D «       «      }t        j                  d| j                  «       t        ¬«      }t        j                  |j                  «       |j                  «       t        «      j                  «       |k(  S # t        $ r Y yw xY w)zÒ
    Validates web app data.

    :param token: The bot token
    :type token: :obj:`str`

    :param raw_init_data: The raw init data
    :type raw_init_data: :obj:`str`

    :return: The parsed init data
    FÚhashr”   c              3   ó0   K  — | ]  \  }}|› d |› �–— Œ y­w)ú=Nr¹   )Ú.0rZ  r]  s      r�   ú	<genexpr>z(validate_web_app_data.<locals>.<genexpr>Ü  s   è ø€ Ò!a±z°s¸E S E¨¨5¨'Ô"2Ñ!aùs   ‚s
   WebAppData)rZ  ÚmsgÚ	digestmod)Údictr
   Ú
ValueErrorÚpoprÐ   Úsortedr%  Úhmacr)  r	  r	   ÚdigestÚ	hexdigest)r‰  rŠ  Úparsed_dataÚinit_data_hashÚdata_check_stringÚ
secret_keys         r�   rŒ  rŒ  È  sµ   € ðÜœ9 ]Ó3Ó4ˆð �[Ñ Øà —_‘_ VÓ,€NØŸ	™	Ñ!aÄVÈK×L]ÑL]ÓL_ÓE`Ô!aÓaÐÜ—‘˜m°·±³Ì6ÔR€Jä�8‰8�J×%Ñ%Ó'Ð):×)AÑ)AÓ)CÄVÓL×VÑVÓXÐ\jÑjÐjøô ò Ùðús   ‚C Ã	CÃCc                 ó¬   — t        d„ | D «       «      rt        d«      ‚d| vrt        d«      ‚t        | j                  d«      «      dk7  rt        d«      ‚y)Nc              3   ó<   K  — | ]  }|j                  «       –— Œ y ­wr¨   )Úisspace)r”  Úchars     r�   r•  z!validate_token.<locals>.<genexpr>ã  s   è ø€ Ò
,˜dˆ4�<‰<�>Ñ
,ùs   ‚zToken must not contain spacesú:zToken must contain a colonrÔ   z7Token must contain exactly 2 parts separated by a colonT)rL  r™  r
  rû   ©r‰  s    r�   Úvalidate_tokenr©  â  sU   € Ü
Ñ
, eÔ
,Ô,ÜÐ8Ó9Ð9à
�%ÑÜÐ5Ó6Ð6ä
ˆ5�;‰;�sÓÓ Ò!ÜÐRÓSÐSàr�   c                 ór   — 	 t        | «       t        | j                  d«      d   «      S # t        $ r Y y w xY w)Nr§  r   )r©  r™  Úintrû   r¨  s    r�   Úextract_bot_idr¬  î  s>   € ðÜ�uÔô ˆu�{‰{˜3Ó Ñ"Ó#Ð#øô ò Ùðús   ‚* ª	6µ6)#Úcontent_type_mediaÚcontent_type_serviceÚupdate_typesrw   rÖ   râ   rò   ri  r   r   r   r   r   r   r   rø   rü   r  r  r   r*  r0  r9  r„  rˆ  r�  rŒ  r>  rA  rI  rU  r^  ru  r©  r¬  )FrÓ   )TNN)Jrþ   r€   r    Útypingr   r   r   r   r   r   rœ  Úhashlibr	   Úurllib.parser
   rƒ   r   Úloggingr½   r   Útelebot.service_utilsr   r   r   r   r   r   r   Úujsonrè   ÚImportErrorr  Ú	getLoggerr—   ÚlocalrW  r­  r®  r¯  r�   rw   r»   rÖ   râ   rò   rž   Úboolrø   rü   r  ÚMessageEntityr  r«  r  r   r*  ÚUserr0  r4  r9  r>  rA  rI  rU  r^  ri  ru  r„  rˆ  r�  rŒ  r©  r¬  Ú__all__r¹   r�   r�   ú<module>r½     s”  ðã 	Û Û ß =× =Û Ý Ý "ó Û å ß ~× ~Ñ ~ðÛð Ð à	ˆ×	Ñ	˜9Ó	%€àˆy�‰Ó €òÐ òÐ ò€ô?�9×#Ñ#ô ?÷D'ñ '÷Tñ ÷<%ñ %òð �Sð  ˜Tó  ðK˜#ð K %¨¨T¨	Ñ"2ó Kð.9˜Cð 9 E¨#¨t¨)Ñ$4ó 9ð* ,˜ð  , ×!4Ñ!4ð  ,¸ó  ,ðDY�sð Y¨cð Y°d¸3±ió Yð" 4Fñ & �cð & ¨Sð & È$ÈsÉ)ó & ðR�ð ˜ #™ó ñB�E—J‘Jð B¨Dð B¸Só Bñ</˜˜c 4¨¨S¨¡>Ð1Ñ2ð /¸sð /È5×KeÑKeó /òfòò
"òó4&ñ"�Tð "¨x¸Ñ/Aó "òLð2 9:ò %)˜ó %)ðP EFò )+ Hó )+ðX˜cð °#ó ð6k ð k°Só kð4
˜Tó 
ð$˜U 3¨ 9Ñ-ó $ð�øðG ò Þðús   ÁF Æ	F,Æ+F,