L i|dZddlmZmZmZddlmZddlmZddl m Z ddl m Z m Z mZerddlmZGdd e ee e fZy ) z4This module contains the StringCommandHandler class.) TYPE_CHECKINGAnyOptional) DEFAULT_TRUE)DVType) BaseHandler)CCTRTHandlerCallback) Applicationc eZdZdZdZefdddedeeee fde e ffd Z d e d eeefd Zd ed ed ddeeed df dZxZS)StringCommandHandleraHandler class to handle string commands. Commands are string updates that start with ``/``. The handler will add a :obj:`list` to the :class:`CallbackContext` named :attr:`CallbackContext.args`. It will contain a list of strings, which is the text following the command split on single whitespace characters. Note: This handler is not used to handle Telegram :class:`telegram.Update`, but strings manually put in the queue. For example to send messages with the bot using command line or API. 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: command (:obj:`str`): The command this handler should listen for. 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: str, 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` Attributes: command (:obj:`str`): The command this handler should listen for. 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`. )commandselfzStringCommandHandler[CCT, RT]rcallbackblockc6t|||||_y)N)r)super__init__r)rrrr __class__s q/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/telegram/ext/_handlers/stringcommandhandler.pyrzStringCommandHandler.__init__Is /# updatereturnct|tr<|jdr+|ddjd}|d|jk(r|ddSy)a Determines whether an update should be passed to this handler's :attr:`callback`. Args: update (:obj:`object`): The incoming update. Returns: list[:obj:`str`]: List containing the text command split on whitespace. /N r) isinstancestr startswithsplitr)rrargss r check_updatez!StringCommandHandler.check_updateRsO fc "v'8'8'=!":##C(DAw$,,&ABxrcontext applicationz)Application[Any, CCT, Any, Any, Any, Any] check_resultNc||_y)zqAdd text after the command to :attr:`CallbackContext.args` as list, split on single whitespaces. N)r#)rr%rr&r's rcollect_additional_contextz/StringCommandHandler.collect_additional_contextbs $ r)__name__ __module__ __qualname____doc__ __slots__rr r r r rboolrobjectrlistr$r) __classcell__)rs@rrr s$LI + $-$$"#sB,/$d| $6htCy.A $ $ $A $ tCy) $  $rrN)r-typingrrrtelegram._utils.defaultvaluertelegram._utils.typesr"telegram.ext._handlers.basehandlerrtelegram.ext._utils.typesr r r telegram.extr r rrrr:s>&;//5(:>>(L$;sC|4L$r