Ë
    S"“j#  ã                   ó€   — d dl Z d dlZd dlZddlmZmZmZ ddlmZm	Z	 ddl
mZmZmZ ddlmZ e G d„ d	e«      «       Zy)
é    Né   )ÚEventBuilderÚEventCommonÚname_inner_eventé   )ÚutilsÚhelpers)ÚtypesÚ	functionsÚcustom)ÚSenderGetterc                   ód   ‡ — e Zd ZdZ	 d
ddddœˆ fd„Zedd„«       Zˆ fd„Z G d„ d	ee	«      Z
ˆ xZS )ÚInlineQuerya§  
    Occurs whenever you sign in as a bot and a user
    sends an inline query such as ``@bot query``.

    Args:
        users (`entity`, optional):
            May be one or more entities (username/peer/etc.), preferably IDs.
            By default, only inline queries from these users will be handled.

        blacklist_users (`bool`, optional):
            Whether to treat the users as a blacklist instead of
            as a whitelist (default). This means that every chat
            will be handled *except* those specified in ``users``
            which will be ignored if ``blacklist_users=True``.

        pattern (`str`, `callable`, `Pattern`, optional):
            If set, only queries matching this pattern will be handled.
            You can specify a regex-like string which will be matched
            against the message, a callable function that returns `True`
            if a message is acceptable, or a compiled regex pattern.

    Example
        .. code-block:: python

            from telethon import events

            @client.on(events.InlineQuery)
            async def handler(event):
                builder = event.builder

                # Two options (convert user text to UPPERCASE or lowercase)
                await event.answer([
                    builder.article('UPPERCASE', text=event.text.upper()),
                    builder.article('lowercase', text=event.text.lower()),
                ])
    NF)Úblacklist_usersÚfuncÚpatternc                ó8  •— t         ‰| �  |||¬«       t        |t        «      r%t	        j
                  |«      j                  | _        y |rt        |«      r|| _        y t        |d«      r't        |j                  «      r|j                  | _        y t        d«      ‚)N)Úblacklist_chatsr   ÚmatchzInvalid pattern type given)ÚsuperÚ__init__Ú
isinstanceÚstrÚreÚcompiler   r   ÚcallableÚhasattrÚ	TypeError)ÚselfÚusersr   r   r   Ú	__class__s        €ú\/var/www/api.ozpay.ru/ozpay/venv/lib/python3.12/site-packages/telethon/events/inlinequery.pyr   zInlineQuery.__init__2   st   ø€ ä‰Ñ˜°ÀdÐÔKä�gœsÔ#ÜŸ:™: gÓ.×4Ñ4ˆD�LÙœH WÔ-Ø"ˆD�LÜ�W˜gÔ&¬8°G·M±MÔ+BØ"Ÿ=™=ˆD�LäÐ8Ó9Ð9ó    c                 óZ   — t        |t        j                  «      r| j                  |«      S y ©N)r   r
   ÚUpdateBotInlineQueryÚEvent)ÚclsÚupdateÚothersÚself_ids       r"   ÚbuildzInlineQuery.build?   s&   € ä�fœe×8Ñ8Ô9Ø—9‘9˜VÓ$Ð$ð :r#   c                 ó„   •— | j                   r%| j                  |j                  «      }|sy ||_        t        ‰| �  |«      S r%   )r   ÚtextÚpattern_matchr   Úfilter)r   Úeventr   r!   s      €r"   r0   zInlineQuery.filterD   s9   ø€ Ø�<Š<Ø—L‘L §¡Ó,ˆEÙØØ"'ˆEÔä‰w‰~˜eÓ$Ð$r#   c                   ó¤   ‡ — e Zd ZdZˆ fd„Zˆ fd„Zed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
ed„ «       Z	 dd
d	d
d	ddœd„Zed„ «       Zˆ xZS )úInlineQuery.Eventa
  
        Represents the event of a new callback query.

        Members:
            query (:tl:`UpdateBotInlineQuery`):
                The original :tl:`UpdateBotInlineQuery`.

                Make sure to access the `text` property of the query if
                you want the text rather than the actual query object.

            pattern_match (`obj`, optional):
                The resulting object from calling the passed ``pattern``
                function, which is ``re.compile(...).match`` by default.
        c                 óÊ   •— t         ‰| �  t        j                  |j                  «      ¬«       t        j                  | |j                  «       || _        d | _        d| _        y )N)Ú	chat_peerF)	r   r   r
   ÚPeerUserÚuser_idr   Úqueryr/   Ú	_answered)r   r8   r!   s     €r"   r   zInlineQuery.Event.__init__\   sJ   ø€ Ü‰GÑ¤u§~¡~°e·m±mÓ'DÐÔEÜ×!Ñ! $¨¯©Ô6ØˆDŒJØ!%ˆDÔØ"ˆD�Nr#   c                 ó¨   •— t         ‰| �  |«       t        j                  | j                  | j
                  |j                  «      \  | _        | _        y r%   )	r   Ú_set_clientr   Ú_get_entity_pairÚ	sender_idÚ	_entitiesÚ_mb_entity_cacheÚ_senderÚ_input_sender)r   Úclientr!   s     €r"   r;   zInlineQuery.Event._set_clientc   s@   ø€ Ü‰GÑ Ô'Ü/4×/EÑ/EØ—‘ §¡°×0GÑ0Gó0IÑ,ˆDŒL˜$Õ,r#   c                 ó.   — | j                   j                  S )zI
            Returns the unique identifier for the query ID.
            )r8   Úquery_id©r   s    r"   ÚidzInlineQuery.Event.idh   s   € ð
 —:‘:×&Ñ&Ð&r#   c                 ó.   — | j                   j                   S )zR
            Returns the text the user used to make the inline query.
            )r8   rE   s    r"   r.   zInlineQuery.Event.texto   s   € ð
 —:‘:×#Ñ#Ð#r#   c                 ó.   — | j                   j                  S )z¥
            The string the user's client used as an offset for the query.
            This will either be empty or equal to offsets passed to `answer`.
            )r8   ÚoffsetrE   s    r"   rI   zInlineQuery.Event.offsetv   s   € ð —:‘:×$Ñ$Ð$r#   c                 ó.   — | j                   j                  S )z×
            If the user location is requested when using inline mode
            and the user's device is able to send it, this will return
            the :tl:`GeoPoint` with the position of the user.
            )r8   ÚgeorE   s    r"   rK   zInlineQuery.Event.geo~   s   € ð —:‘:—>‘>Ð!r#   c                 ó@   — t        j                  | j                  «      S )z~
            Returns a new `InlineBuilder
            <telethon.tl.custom.inlinebuilder.InlineBuilder>` instance.
            )r   ÚInlineBuilderÚ_clientrE   s    r"   ÚbuilderzInlineQuery.Event.builder‡   s   € ô ×'Ñ'¨¯©Ó5Ð5r#   NFÚ )ÚgalleryÚnext_offsetÚprivateÚ	switch_pmÚswitch_pm_paramc             ƒ   óÌ  K  — | j                   ry|rY|D �cg c]  }| j                  |«      ‘Œ }	}t        j                  |	«      ƒ d{  –—†  |	D �cg c]  }|j	                  «       ‘Œ }}ng }|rt        j                  ||«      }| j                  t        j                  j                  | j                  j                  ||||||¬«      «      ƒ d{  –—† S c c}w 7 Œ’c c}w 7 Œ­w)a¤	  
            Answers the inline query with the given results.

            See the documentation for `builder` to know what kind of answers
            can be given.

            Args:
                results (`list`, optional):
                    A list of :tl:`InputBotInlineResult` to use.
                    You should use `builder` to create these:

                    .. code-block:: python

                        builder = inline.builder
                        r1 = builder.article('Be nice', text='Have a nice day')
                        r2 = builder.article('Be bad', text="I don't like you")
                        await inline.answer([r1, r2])

                    You can send up to 50 results as documented in
                    https://core.telegram.org/bots/api#answerinlinequery.
                    Sending more will raise ``ResultsTooMuchError``,
                    and you should consider using `next_offset` to
                    paginate them.

                cache_time (`int`, optional):
                    For how long this result should be cached on
                    the user's client. Defaults to 0 for no cache.

                gallery (`bool`, optional):
                    Whether the results should show as a gallery (grid) or not.

                next_offset (`str`, optional):
                    The offset the client will send when the user scrolls the
                    results and it repeats the request.

                private (`bool`, optional):
                    Whether the results should be cached by Telegram
                    (not private) or by the user's client (private).

                switch_pm (`str`, optional):
                    If set, this text will be shown in the results
                    to allow the user to switch to private messages.

                switch_pm_param (`str`, optional):
                    Optional parameter to start the bot with if
                    `switch_pm` was used.

            Example:

                .. code-block:: python

                    @bot.on(events.InlineQuery)
                    async def handler(event):
                        builder = event.builder

                        rev_text = event.text[::-1]
                        await event.answer([
                            builder.article('Reverse text', text=rev_text),
                            builder.photo('/path/to/photo.jpg')
                        ])
            N)rD   ÚresultsÚ
cache_timerQ   rR   rS   rT   )r9   Ú
_as_futureÚasyncioÚwaitÚresultr
   ÚInlineBotSwitchPMrN   r   ÚmessagesÚSetInlineBotResultsRequestr8   rD   )
r   rW   rX   rQ   rR   rS   rT   rU   ÚxÚfuturess
             r"   ÚanswerzInlineQuery.Event.answer�   sÚ   è ø€ ðB �~Š~ØáØ7>Ö?°!˜4Ÿ?™?¨1Õ-Ð?�Ð?ä—l‘l 7Ó+×+Ð+ð 07Ö7¨!˜1Ÿ8™8�:Ð7�Ñ7à�áÜ!×3Ñ3°I¸ÓO�	àŸ™Ü×"Ñ"×=Ñ=Ø!ŸZ™Z×0Ñ0Ø#Ø)Ø#Ø +Ø#Ø'ð >ó ó
÷ 
ð 
ùò! @à+úò 8ð
ús:   ‚C$–C®C$ÁCÁ	C$ÁCÁ(A)C$ÃC"Ã
C$ÃC$c                 óÀ   — t        j                  | «      rt        j                  | «      S t	        j
                  «       j                  «       }|j                  | «       |S r%   )ÚinspectÚisawaitablerZ   Úensure_futurer	   Úget_running_loopÚcreate_futureÚ
set_result)ÚobjÚfs     r"   rY   zInlineQuery.Event._as_futureð   sI   € ä×"Ñ" 3Ô'Ü×,Ñ,¨SÓ1Ð1ä×(Ñ(Ó*×8Ñ8Ó:ˆAØ�L‰L˜ÔØˆHr#   )Nr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r;   ÚpropertyrF   r.   rI   rK   rO   rb   ÚstaticmethodrY   Ú__classcell__©r!   s   @r"   r'   r3   M   s©   ø„ ñ	ô	#ô	Ið
 
ñ	'ó 
ð	'ð 
ñ	$ó 
ð	$ð 
ñ	%ó 
ð	%ð 
ñ	"ó 
ð	"ð 
ñ	6ó 
ð	6ð 01ð_	à¨4¸Ø°ô_	ðB 
ñ	ó 
ô	r#   r'   r%   )NN)rl   rm   rn   ro   r   Úclassmethodr,   r0   r   r   r'   rr   rs   s   @r"   r   r      sN   ø„ ñ#ðJ ð:Ø16¸TÈ4ö:ð ò%ó ð%ô%ôj�˜\÷ jð jr#   r   )rd   r   rZ   Úcommonr   r   r   rP   r   r	   Útlr
   r   r   Útl.custom.sendergetterr   r   © r#   r"   ú<module>ry      s>   ðÛ Û 	ã ç ?Ñ ?ß ß )Ñ )Ý 1ð ôj�,ó jó ñjr#   