L idZddlZddlmZmZddlmZmZmZmZm Z m Z ddl m Z ddl mZddlmZddlmZdd lmZmZerdd lmZed ZGd d ee eefZy)z2This module contains the InlineQueryHandler class.N)MatchPattern) TYPE_CHECKINGAnyOptionalTypeVarUnioncast)Update) DEFAULT_TRUE)DVType) BaseHandler)CCTHandlerCallback) ApplicationRTc eZdZdZdZdedfdddeeee fde e e e e fdeed e ee f fd Zd ed e e eee ffd Zded eddde e eee fd df dZxZS)InlineQueryHandlera BaseHandler class to handle Telegram updates that contain a :attr:`telegram.Update.inline_query`. Optionally based on a regex. Read the documentation of the :mod:`re` module for more information. Warning: * When setting :paramref:`block` to :obj:`False`, you cannot rely on adding custom attributes to :class:`telegram.ext.CallbackContext`. See its docs for more info. * :attr:`telegram.InlineQuery.chat_type` will not be set for inline queries from secret chats and may not be set for inline queries coming from third-party clients. These updates won't be handled, if :attr:`chat_types` is passed. Examples: :any:`Inline Bot ` Args: callback (:term:`coroutine function`): The callback function for this handler. Will be called when :meth:`check_update` has determined that an update should be processed by this handler. Callback signature:: async def callback(update: Update, context: CallbackContext) The return value of the callback is usually ignored except for the special case of :class:`telegram.ext.ConversationHandler`. pattern (:obj:`str` | :func:`re.Pattern `, optional): Regex pattern. If not :obj:`None`, :func:`re.match` is used on :attr:`telegram.InlineQuery.query` to determine if an update should be handled by this handler. block (:obj:`bool`, optional): Determines whether the return value of the callback should be awaited before processing the next handler in :meth:`telegram.ext.Application.process_update`. Defaults to :obj:`True`. .. seealso:: :wiki:`Concurrency` chat_types (list[:obj:`str`], optional): List of allowed chat types. If passed, will only handle inline queries with the appropriate :attr:`telegram.InlineQuery.chat_type`. .. versionadded:: 13.5 Attributes: callback (:term:`coroutine function`): The callback function for this handler. pattern (:obj:`str` | :func:`re.Pattern `): Optional. Regex pattern to test :attr:`telegram.InlineQuery.query` against. chat_types (list[:obj:`str`]): Optional. List of allowed chat types. .. versionadded:: 13.5 block (:obj:`bool`): Determines whether the return value of the callback should be awaited before processing the next handler in :meth:`telegram.ext.Application.process_update`. ) chat_typespatternNselfzInlineQueryHandler[CCT, RT]callbackrblockrct|||t|trt j |}||_||_y)N)r)super__init__ isinstancestrrecompilerr)rrrrr __class__s o/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/telegram/ext/_handlers/inlinequeryhandler.pyrzInlineQueryHandler.__init__[s= / gs #jj)G;B /9updatereturnc<t|tr|jr|j#|jj|jvry|j r8t j|j |jjx}r|S|j syy)z Determines whether an update should be passed to this handler's :attr:`callback`. Args: update (:class:`telegram.Update` | :obj:`object`): Incoming update. Returns: :obj:`bool` | :obj:`re.match` NFT) rr inline_queryr chat_typerrmatchquery)rr$r)s r" check_updatezInlineQueryHandler.check_updatejsy ff %&*=*=+##--T__D||"((4<<ATATAZAZ*[![![ <<r#context applicationz)Application[Any, CCT, Any, Any, Any, Any] check_resultcF|jrtd|}|g|_yy)zAdd the result of ``re.match(pattern, update.inline_query.query)`` to :attr:`CallbackContext.matches` as list with one element. rN)rr matches)rr,r$r-r.s r"collect_additional_contextz-InlineQueryHandler.collect_additional_contexts% <<6L+nGO r#)__name__ __module__ __qualname____doc__ __slots__r rr rrrr rrr boollistrobjectrr+r1 __classcell__)r!s@r"rr%s1f*I 7;**. :+ :!&#r/2 :%WS\ 123 :d| : T#Y' :6huT5:=M7N.O, - - -A - uT5:%567 -  -r#r)r5rrrtypingrrrrr r telegramr telegram._utils.defaultvaluer telegram._utils.typesr "telegram.ext._handlers.basehandlerrtelegram.ext._utils.typesrr telegram.extrrrr#r"rCsM&9 EE5(::( T]g-VS"_5g-r#