L iRdZddlZddlmZmZddlmZmZmZmZm Z m Z ddl m Z ddl mZddlmZddlmZdd lmZmZed Zerdd lmZGd d ee eefZy)z9This module contains the ChosenInlineResultHandler class.N)MatchPattern) TYPE_CHECKINGAnyOptionalTypeVarUnioncast)Update) DEFAULT_TRUE)DVType) BaseHandler)CCTHandlerCallbackRT) Applicationc eZdZdZdZedfdddeeee fde e de e eeefffd Zd ed e e e effd Zd ed eddde e eefd df dZxZS)ChosenInlineResultHandleraHandler class to handle Telegram updates that contain :attr:`telegram.Update.chosen_inline_result`. 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. 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`. 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` pattern (:obj:`str` | :func:`re.Pattern `, optional): Regex pattern. If not :obj:`None`, :func:`re.match` is used on :attr:`telegram.ChosenInlineResult.result_id` to determine if an update should be handled by this handler. This is accessible in the callback as :attr:`telegram.ext.CallbackContext.matches`. .. versionadded:: 13.6 Attributes: callback (:term:`coroutine function`): The callback function for this handler. 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`. pattern (`Pattern`): Optional. Regex pattern to test :attr:`telegram.ChosenInlineResult.result_id` against. .. versionadded:: 13.6 )patternNselfz"ChosenInlineResultHandler[CCT, RT]callbackblockrct|||t|trt j |}||_y)N)r)super__init__ isinstancestrrecompiler)rrrr __class__s v/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/telegram/ext/_handlers/choseninlineresulthandler.pyrz"ChosenInlineResultHandler.__init__Ps6 / gs #jj)G;B updatereturnct|trR|jrF|jr9t j |j|jj x}r|Syyy)zDetermines 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` TN)rr chosen_inline_resultrrmatch result_id)rr#r's r! check_updatez&ChosenInlineResultHandler.check_update]sU ff %&*E*E||HHT\\63N3N3X3XYY5Y Lr"context applicationz)Application[Any, CCT, Any, Any, Any, Any] check_resultcF|jrtd|}|g|_yy)zuThis function adds the matched regex pattern result to :attr:`telegram.ext.CallbackContext.matches`. rN)rr matches)rr*r#r+r,s r!collect_additional_contextz4ChosenInlineResultHandler.collect_additional_contextos% <<6L+nGO r")__name__ __module__ __qualname____doc__ __slots__r rr rrr boolrr rrrobjectr)rr/ __classcell__)r s@r!rr%s&PI +6: C2 C!&#r/2 Cd| C%WS\ 123 C6huT6\7J.K$ - - -A - D%*,- -  -r"r)r3rrrtypingrrrrr r telegramr telegram._utils.defaultvaluer telegram._utils.typesr "telegram.ext._handlers.basehandlerrtelegram.ext._utils.typesrrr telegram.extrrr"r!r@sN&@ EE5(:: T](V- FCO <V-r"