
    YiL                        S r SSKrSSKrSSKJr  SSKJrJrJrJ	r	J
r
JrJrJr  SSKJr  SSKJrJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJ r   SSK!J"r"  SSK#J$r$  SSK%J&r&  SSK'J(r(  SSK)J*r*  SSK+J,r,  SSK-J.r.  SSK/J0r0J1r1J2r2  \(       a
  SSK3J4r4J5r5J6r6  \7\8\2\ \\0\84   \84   r9\" \:SS9r;\ " S S\	\0   5      5       r<\ " S S5      5       r= " S S\ \\0\84   5      r>g)z-This module contains the ConversationHandler.    N)	dataclass)TYPE_CHECKINGAnyFinalGenericNoReturnOptionalUnioncast)Update)DEFAULT_TRUEDefaultValue)
get_logger)build_repr_with_selected_attrs)DVType)warn)ApplicationHandlerStop)ExtBot)BaseHandler)CallbackQueryHandler)ChosenInlineResultHandler)InlineQueryHandler)StringCommandHandler)StringRegexHandler)TypeHandler)TrackingDict)CCTConversationDictConversationKey)ApplicationJobJobQueueConversationHandler)
class_namec                   F    \ rS rSr% SrSr\\S'   \\S'   S\S'   \	\S'   S	r
g
)_ConversationTimeoutContext2   zUsed as a datastore for conversation timeouts. Passed in the
:paramref:`JobQueue.run_once.data` parameter. See :meth:`_trigger_timeout`.
)applicationcallback_contextconversation_keyupdater*   r+   .Application[Any, CCT, Any, Any, Any, JobQueue]r(   r)    N)__name__
__module____qualname____firstlineno____doc__	__slots__r   __annotations__r   r   __static_attributes__r-       U/app/.venv/lib/python3.13/site-packages/telegram/ext/_handlers/conversationhandler.pyr&   r&   2   s&     RI%%NAAr6   r&   c                   b    \ rS rSr% SrSr\R                  \S'   \	\S'   S\
4S jrS\	4S jrS	rg
)PendingState@   zThin wrapper around :class:`asyncio.Task` to handle block=False handlers. Note that this is
a public class of this module, since :meth:`Application.update_persistence` needs to access it.
It's still hidden from users, since this module itself is private.
	old_statetaskr=   r<   returnc                 6    U R                   R                  5       $ N)r=   doneselfs    r7   rA   PendingState.doneL   s    yy~~r6   c                    U R                   R                  5       (       d  [        S5      eU R                   R                  5       nU(       a,  [        R                  SU R
                  5        U R
                  $ U R                   R                  5       nUc  U R
                  c  [        R                  nU$ Uc  U R
                  $ U$ )a`  Returns the new state of the :class:`ConversationHandler` if available. If there was an
exception during the task execution, then return the old state. If both the new and old
state are :obj:`None`, return `CH.END`. If only the new state is :obj:`None`, return the
old state.

Raises:
    :exc:`RuntimeError`: If the current task has not yet finished.
zNew state is not yet availablez<Task function raised exception. Falling back to old state %s)	r=   rA   RuntimeError	exception_LOGGERr<   resultr#   END)rC   excress      r7   resolvePendingState.resolveO   s     yy~~?@@ii!!#N >>!ii ;4>>1%))C
 
	 [>>!
r6   r-   N)r.   r/   r0   r1   r2   r3   asyncioTaskr4   objectboolrA   rM   r5   r-   r6   r7   r9   r9   @   s6    
 &I
,, d   r6   r9   c                      \ rS rSr% SrSrSr\\   \	S'    Sr
\\   \	S'    Sr\\   \	S	'    S
SSS
SSS
S\4	SSS\\\\\4      S\\\\\\\4      4   S\\\\\4      S\S\S\S\S\\\\R0                  4      S\\   S\S\\\\4      S\\   4S jjrS\4S jr\S\\\\\4      4S j5       r\R>                  S\S\ 4S  j5       r\S\\\\\\\4      4   4S! j5       r!\!R>                  S\S\ 4S" j5       r!\S\\\\\4      4S# j5       r"\"R>                  S\S\ 4S$ j5       r"\S\4S% j5       r#\#R>                  S\S\ 4S& j5       r#\S\4S' j5       r$\$R>                  S\S\ 4S( j5       r$\S\4S) j5       r%\%R>                  S\S\ 4S* j5       r%\S\4S+ j5       r&\&R>                  S\S\ 4S, j5       r&\S\\\\R0                  4      4S- j5       r'\'R>                  S\S\ 4S. j5       r'\S\\   4S/ j5       r(\(R>                  S\S\ 4S0 j5       r(\S\4S1 j5       r)\)R>                  S\S\ 4S2 j5       r)\S\\\\4      4S3 j5       r*\*R>                  S\S\ 4S4 j5       r*S5S6S\\\+\,\4   4   4S7 jr-S8\S\,4S9 jr.S:\/R`                  S5S;S8\S<\S=\,SS4S> jr1S:\S5S;S8\S<\S=\,SS4S? jr2S8\S\\3\      4S@ jr4S8\S5SASB\3\   S<\S\\   4
SC jr5 SIS:\SD\,SE\\   SS4SF jjr6S<\SS4SG jr7SHr8g)Jr#   m   a"  
A handler to hold a conversation with a single or multiple users through Telegram updates by
managing three collections of other handlers.

Warning:
    :class:`ConversationHandler` heavily relies on incoming updates being processed one by one.
    When using this handler, :attr:`telegram.ext.ApplicationBuilder.concurrent_updates` should
    be set to :obj:`False`.

Note:
    :class:`ConversationHandler` will only accept updates that are (subclass-)instances of
    :class:`telegram.Update`. This is, because depending on the :attr:`per_user` and
    :attr:`per_chat`, :class:`ConversationHandler` relies on
    :attr:`telegram.Update.effective_user` and/or :attr:`telegram.Update.effective_chat` in
    order to determine which conversation an update should belong to. For
    :attr:`per_message=True <per_message>`, :class:`ConversationHandler` uses
    :attr:`update.callback_query.message.message_id <telegram.Message.message_id>` when
    :attr:`per_chat=True <per_chat>` and
    :attr:`update.callback_query.inline_message_id <.CallbackQuery.inline_message_id>` when
    :attr:`per_chat=False <per_chat>`. For a more detailed explanation, please see our `FAQ`_.

    Finally, :class:`ConversationHandler`, does *not* handle (edited) channel posts.

.. _`FAQ`: https://github.com/python-telegram-bot/python-telegram-bot/wiki        /Frequently-Asked-Questions#what-do-the-per_-settings-in-conversation handler-do

The first collection, a :obj:`list` named :attr:`entry_points`, is used to initiate the
conversation, for example with a :class:`telegram.ext.CommandHandler` or
:class:`telegram.ext.MessageHandler`.

The second collection, a :obj:`dict` named :attr:`states`, contains the different conversation
steps and one or more associated handlers that should be used if the user sends a message when
the conversation with them is currently in that state. Here you can also define a state for
:attr:`TIMEOUT` to define the behavior when :attr:`conversation_timeout` is exceeded, and a
state for :attr:`WAITING` to define behavior when a new update is received while the previous
:attr:`block=False <block>` handler is not finished.

The third collection, a :obj:`list` named :attr:`fallbacks`, is used if the user is currently
in a conversation but the state has either no associated handler or the handler that is
associated to the state is inappropriate for the update, for example if the update contains a
command, but a regular text message is expected. You could use this for a ``/cancel`` command
or to let the user know their message was not recognized.

To change the state of conversation, the callback function of a handler must return the new
state after responding to the user. If it does not return anything (returning :obj:`None` by
default), the state will not change. If an entry point callback function returns :obj:`None`,
the conversation ends immediately after the execution of this callback function.
To end the conversation, the callback function must return :attr:`END` or ``-1``. To
handle the conversation timeout, use handler :attr:`TIMEOUT` or ``-2``.
Finally, :class:`telegram.ext.ApplicationHandlerStop` can be used in conversations as described
in its documentation.

Note:
    In each of the described collections of handlers, a handler may in turn be a
    :class:`ConversationHandler`. In that case, the child :class:`ConversationHandler` should
    have the attribute :attr:`map_to_parent` which allows returning to the parent conversation
    at specified states within the child conversation.

    Note that the keys in :attr:`map_to_parent` must not appear as keys in :attr:`states`
    attribute or else the latter will be ignored. You may map :attr:`END` to one of the parents
    states to continue the parent conversation after the child conversation has ended or even
    map a state to :attr:`END` to end the *parent* conversation from within the child
    conversation. For an example on nested :class:`ConversationHandler` s, see
    :any:`examples.nestedconversationbot`.

Examples:
    * :any:`Conversation Bot <examples.conversationbot>`
    * :any:`Conversation Bot 2 <examples.conversationbot2>`
    * :any:`Nested Conversation Bot <examples.nestedconversationbot>`
    * :any:`Persistent Conversation Bot <examples.persistentconversationbot>`

Args:
    entry_points (list[:class:`telegram.ext.BaseHandler`]): A list of :obj:`BaseHandler`
        objects that
        can trigger the start of the conversation. The first handler whose :meth:`check_update`
        method returns :obj:`True` will be used. If all return :obj:`False`, the update is not
        handled.
    states (dict[:obj:`object`, list[:class:`telegram.ext.BaseHandler`]]): A :obj:`dict` that
        defines the different states of conversation a user can be in and one or more
        associated :obj:`BaseHandler` objects that should be used in that state. The first
        handler whose :meth:`check_update` method returns :obj:`True` will be used.
    fallbacks (list[:class:`telegram.ext.BaseHandler`]): A list of handlers that might be used
        if the user is in a conversation, but every handler for their current state returned
        :obj:`False` on :meth:`check_update`. The first handler which :meth:`check_update`
        method returns :obj:`True` will be used. If all return :obj:`False`, the update is not
        handled.
    allow_reentry (:obj:`bool`, optional): If set to :obj:`True`, a user that is currently in a
        conversation can restart the conversation by triggering one of the entry points.
        Default is :obj:`False`.
    per_chat (:obj:`bool`, optional): If the conversation key should contain the Chat's ID.
        Default is :obj:`True`.
    per_user (:obj:`bool`, optional): If the conversation key should contain the User's ID.
        Default is :obj:`True`.
    per_message (:obj:`bool`, optional): If the conversation key should contain the Message's
        ID. Default is :obj:`False`.
    conversation_timeout (:obj:`float` | :obj:`datetime.timedelta`, optional): When this
        handler is inactive more than this timeout (in seconds), it will be automatically
        ended. If this value is ``0`` or :obj:`None` (default), there will be no timeout. The
        last received update and the corresponding :class:`context <.CallbackContext>` will be
        handled by *ALL* the handler's whose :meth:`check_update` method returns :obj:`True`
        that are in the state :attr:`ConversationHandler.TIMEOUT`.

        Caution:
            * This feature relies on the :attr:`telegram.ext.Application.job_queue` being set
              and hence requires that the dependencies that :class:`telegram.ext.JobQueue`
              relies on are installed.
            * Using :paramref:`conversation_timeout` with nested conversations is currently
              not supported. You can still try to use it, but it will likely behave
              differently from what you expect.

    name (:obj:`str`, optional): The name for this conversation handler. Required for
        persistence.
    persistent (:obj:`bool`, optional): If the conversation's dict for this handler should be
        saved. :paramref:`name` is required and persistence has to be set in
        :attr:`Application <.Application.persistence>`.

        .. versionchanged:: 20.0
            Was previously named as ``persistence``.
    map_to_parent (dict[:obj:`object`, :obj:`object`], optional): A :obj:`dict` that can be
        used to instruct a child conversation handler to transition into a mapped state on
        its parent conversation handler in place of a specified nested state.
    block (:obj:`bool`, optional): Pass :obj:`False` or :obj:`True` to set a default value for
        the :attr:`BaseHandler.block` setting of all handlers (in :attr:`entry_points`,
        :attr:`states` and :attr:`fallbacks`). The resolution order for checking if a handler
        should be run non-blocking is:

        1. :attr:`telegram.ext.BaseHandler.block` (if set)
        2. the value passed to this parameter (if any)
        3. :attr:`telegram.ext.Defaults.block` (if defaults are used)

        .. seealso:: :wiki:`Concurrency`

        .. versionchanged:: 20.0
            No longer overrides the handlers settings. Resolution order was changed.

Raises:
    :exc:`ValueError`: If :paramref:`persistent` is used but :paramref:`name` was not set, or
        when :attr:`per_message`, :attr:`per_chat`, :attr:`per_user` are all :obj:`False`.

Attributes:
    block (:obj:`bool`): Determines whether the callback will run in a blocking way. Always
        :obj:`True` since conversation handlers handle any non-blocking callbacks internally.

)_allow_reentry_block_child_conversations_conversation_timeout_conversations_entry_points
_fallbacks_map_to_parent_name	_per_chat_per_message	_per_user_persistent_states_timeout_jobs_locktimeout_jobsrJ   TIMEOUTWAITINGFTNrC   zConversationHandler[CCT]entry_pointsstates	fallbacksallow_reentryper_chatper_userper_messageconversation_timeoutname
persistentmap_to_parentblockc           	         SSK JnJnJnJn  SU l        Xl        Xl        X l        X0l	        X@l
        X`l        XPl        Xpl        UU l        Xl        Xl        0 U l        [$        R&                  " 5       U l        0 U l        [-        5       U l        U
(       a  U R0                  (       d  [3        S5      eXl        [7        U R8                  U R:                  U R<                  45      (       d  [3        S5      eU R<                  (       a  U R:                  (       d
  [?        SSS9  / nURA                  U5        URA                  U5        URC                  5        H  nURA                  U5        M     U R.                  RE                  S	 U 5       5        S
nU GH  n[G        U[H        [J        45      (       a$  [?        SURL                  RN                   S3SS9  GO.[G        U[P        5      (       aB  [S        URT                  [V        5      (       d#  [?        SURT                  RN                   S3SS9  O[G        UU5      (       a  [?        SSS9  OU R:                  (       aC  [G        UU[X        [Z        UU45      (       a%  [?        SURL                  RN                   SU 3SS9  OgU R<                  (       a#  [G        U[\        5      (       d  [?        SU 3SS9  O3U R<                  (       d"  [G        U[\        5      (       a  [?        SU 3SS9  U R^                  (       d  GM  [G        UU RL                  5      (       d  GM  [?        SSS9  GM     g )Nr   )PollAnswerHandlerPollHandlerPreCheckoutQueryHandlerShippingQueryHandlerTz:Conversations can't be persistent when handler is unnamed.z='per_user', 'per_chat' and 'per_message' can't all be 'False'znIf 'per_message=True' is used, 'per_chat=True' should also be used, since message IDs are not globally unique.   
stacklevelc              3   T   #    U  H  n[        U[        5      (       d  M  Uv   M      g 7fr@   )
isinstancer#   ).0handlers     r7   	<genexpr>/ConversationHandler.__init__.<locals>.<genexpr>d  s      )
#/:gGZ3[GG<s   (	(z Read this FAQ entry to learn more about the per_* settings: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Frequently-Asked-Questions#what-do-the-per_-settings-in-conversationhandler-do.zJThe `ConversationHandler` only handles updates of type `telegram.Update`. z handles updates of type `str`.zkThe `ConversationHandler` only handles updates of type `telegram.Update`. The TypeHandler is set to handle .zPollHandler will never trigger in a conversation since it has no information about the chat or the user who voted in it. Do you mean the `PollAnswerHandler`?zUpdates handled by zb only have information about the user, so this handler won't ever be triggered if `per_chat=True`.zIf 'per_message=True', all entry points, state handlers, and fallbacks must be 'CallbackQueryHandler', since no other handlers have a message context.zUIf 'per_message=False', 'CallbackQueryHandler' will not be tracked for every message.zUsing `conversation_timeout` with nested conversations is currently not supported. You can still try to use it, but it will likely behave differently from what you expect.)0telegram.extrw   rx   ry   rz   ru   rV   rZ   rb   r[   rU   r`   r^   r_   rX   r]   r\   rd   rO   Lockrc   rY   setrW   rr   
ValueErrorra   anyro   rn   rp   r   extendvaluesr+   r   r   r   	__class__r.   r   
issubclasstyper   r   r   r   rq   )rC   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rw   rx   ry   rz   all_handlersstate_handlersper_faq_linkr   s                        r7   __init__ConversationHandler.__init__  s    	
 	
 $(
$)EQMSBK$1''"-  	" %)
>K >@"),,.02>Ae!diiYZZ!+DMM4==$2B2BCDD\]]DMM= @BL)I&$mmoN/ . 	!!(( )
#/)
 	
_ 	 $G'$8:L#MNN`((1122QS 
 G[11*W\\SY:Z:Z99@9N9N8OqR 
 G[11+  !	 ,*1/)	 	 )'*;*;*D*D)E F\#n&  !	 !!*W>R*S*S..:^=  !	 %%*W>R*S*S11=@  (((Z-P-P8  !	o $r6   r>   c                     Sn[        [        U R                  R                  5       5      SU 5      n[	        U5      n[        U R                  5      U:  a  USS S-   n[        U U R                  US9$ )a_  Give a string representation of the ConversationHandler in the form
``ConversationHandler[name=..., states={...}]``.

If there are more than 3 states, only the first 3 states are listed.

As this class doesn't implement :meth:`object.__str__`, the default implementation
will be used, which is equivalent to :meth:`__repr__`.

Returns:
    :obj:`str`
   Nre   z, ...})rr   rk   )dictlistrk   itemsstrlenr   rr   )rC   truncation_thresholdrk   states_strings       r7   __repr__ConversationHandler.__repr__  su      !d4;;,,./0E1EFGFt{{22)#2.9M- 
 	
r6   c                     U R                   $ )z~list[:class:`telegram.ext.BaseHandler`]: A list of :obj:`BaseHandler` objects that can
trigger the start of the conversation.
)rZ   rB   s    r7   rj    ConversationHandler.entry_points  s    
 !!!r6   _c                     [        S5      e)NzDYou can not assign a new value to entry_points after initialization.AttributeErrorrC   r   s     r7   rj   r     s    R
 	
r6   c                     U R                   $ )zdict[:obj:`object`, list[:class:`telegram.ext.BaseHandler`]]: A :obj:`dict` that
defines the different states of conversation a user can be in and one or more
associated :obj:`BaseHandler` objects that should be used in that state.
)rb   rB   s    r7   rk   ConversationHandler.states  s     ||r6   c                     [        S5      e)Nz>You can not assign a new value to states after initialization.r   r   s     r7   rk   r     s    ]^^r6   c                     U R                   $ )zlist[:class:`telegram.ext.BaseHandler`]: A list of handlers that might be used if
the user is in a conversation, but every handler for their current state returned
:obj:`False` on :meth:`check_update`.
)r[   rB   s    r7   rl   ConversationHandler.fallbacks  s     r6   c                     [        S5      e)NzAYou can not assign a new value to fallbacks after initialization.r   r   s     r7   rl   r     s    `aar6   c                     U R                   $ )zQ:obj:`bool`: Determines if a user can restart a conversation with an entry point.)rU   rB   s    r7   rm   !ConversationHandler.allow_reentry  s     """r6   c                     [        S5      e)NzEYou can not assign a new value to allow_reentry after initialization.r   r   s     r7   rm   r         S
 	
r6   c                     U R                   $ )zB:obj:`bool`: If the conversation key should contain the User's ID.)r`   rB   s    r7   ro   ConversationHandler.per_user       ~~r6   c                     [        S5      e)Nz@You can not assign a new value to per_user after initialization.r   r   s     r7   ro   r         _``r6   c                     U R                   $ )zB:obj:`bool`: If the conversation key should contain the Chat's ID.)r^   rB   s    r7   rn   ConversationHandler.per_chat   r   r6   c                     [        S5      e)Nz@You can not assign a new value to per_chat after initialization.r   r   s     r7   rn   r     r   r6   c                     U R                   $ )zE:obj:`bool`: If the conversation key should contain the message's ID.)r_   rB   s    r7   rp   ConversationHandler.per_message	  s        r6   c                     [        S5      e)NzCYou can not assign a new value to per_message after initialization.r   r   s     r7   rp   r     s    bccr6   c                     U R                   $ )z:obj:`float` | :obj:`datetime.timedelta`: Optional. When this
handler is inactive more than this timeout (in seconds), it will be automatically
ended.
)rX   rB   s    r7   rq   (ConversationHandler.conversation_timeout  s     )))r6   c                     [        S5      e)NzLYou can not assign a new value to conversation_timeout after initialization.r   r   s     r7   rq   r     s    Z
 	
r6   c                     U R                   $ )zE:obj:`str`: Optional. The name for this :class:`ConversationHandler`.)r]   rB   s    r7   rr   ConversationHandler.name"  s     zzr6   c                     [        S5      e)Nz<You can not assign a new value to name after initialization.r   r   s     r7   rr   r   '  s    [\\r6   c                     U R                   $ )z:obj:`bool`: Optional. If the conversations dict for this handler should be
saved. :attr:`name` is required and persistence has to be set in
:attr:`Application <.Application.persistence>`.
)ra   rB   s    r7   rs   ConversationHandler.persistent+  s     r6   c                     [        S5      e)NzBYou can not assign a new value to persistent after initialization.r   r   s     r7   rs   r   3  s    abbr6   c                     U R                   $ )zdict[:obj:`object`, :obj:`object`]: Optional. A :obj:`dict` that can be
used to instruct a nested :class:`ConversationHandler` to transition into a mapped state on
its parent :class:`ConversationHandler` in place of a specified nested state.
)r\   rB   s    r7   rt   !ConversationHandler.map_to_parent7  s     """r6   c                     [        S5      e)NzEYou can not assign a new value to map_to_parent after initialization.r   r   s     r7   rt   r   ?  r   r6   r(   r    c                   #    U R                   (       a"  U R                  (       a  UR                  (       d  [        S5      eU R                  n[        [        [        [        4   [        5       5      U l        U R                  R                  U5        UR                  R                  U R                  5      I Sh  vN nU R                  R                  U5        UR                  5        H0  u  pEXPR                  :X  d  M  U R                  U R                  US9  M2     U R                  U R                  0nU R                   H)  nUR                  UR!                  US9I Sh  vN 5        M+     U$  N N7f)a  Initializes the persistence for this handler and its child conversations.
While this method is marked as protected, we expect it to be called by the
Application/parent conversations. It's just protected to hide it from users.

Args:
    application (:class:`telegram.ext.Application`): The application.

Returns:
    A dict {conversation.name -> TrackingDict}, which contains all dict of this
    conversation and possible child conversations.

zRThis handler is not persistent, has no name or the application has no persistence!N)	new_statekey)r(   )rs   rr   persistencerF   rY   r   r   r   rQ   r+   get_conversationsupdate_no_trackr   rJ   _update_staterW   _initialize_persistence)rC   r(   current_conversationsstored_datar   stateoutr   s           r7   r   +ConversationHandler._initialize_persistenceE  s<     DII+2I2I 
 !% 3 3"&01N

 	""#89 (33EEdiiPP++K8 &++-JC ""TXX3"? . yy$--.00GJJ55 + 6   1 
) Qs,   B8E5:E1;AE5 A"E5"E3
#E53E5r+   c                 f   UR                   nUR                  n/ nU R                  (       a)  Uc  [        S5      eUR	                  UR
                  5        U R                  (       a)  Uc  [        S5      eUR	                  UR
                  5        U R                  (       a  UR                  c  [        S5      eUR                  R                  (       a&  UR	                  UR                  R                  5        O/UR	                  UR                  R                  R                  5        [        U5      $ )z7Builds the conversation key associated with the update.z2Can't build key for update without effective chat!z2Can't build key for update without effective user!z1Can't build key for update without CallbackQuery!)effective_chateffective_userrn   rF   appendidro   rp   callback_queryinline_message_idmessage
message_idtuple)rC   r+   chatuserr   s        r7   _get_keyConversationHandler._get_keyy  s    $$$$%'==|"#WXXJJtww==|"#WXXJJtww$$,"#VWW$$66

600BBC

60088CCDSzr6   r   r,   contextr*   c                    #     UI S h  vN nU R                  UUUUUS9$  N! [          a  n[        R                  SUS9   S nAg S nAff = f7f)NzTNon-blocking handler callback raised exception. Not scheduling conversation timeout.exc_info)r   r(   r+   r   r*   )	ExceptionrH   debug_schedule_job)rC   r   r(   r+   r   r*   effective_new_staterK   s           r7   _schedule_job_delayed)ConversationHandler._schedule_job_delayed  sm     	(1/ !!)#- " 
 	
 #2 	MM  
 	s6   A# !# A# 
AAAAAc           
         XR                   :X  a  g UR                  nUR                  U R                  U R                  [        XSX$5      S9U R                  U'   g! [         a  n[        R                  SUS9   SnAgSnAff = f)zRSchedules a job which executes :meth:`_trigger_timeout` upon conversation timeout.N)datazFailed to schedule timeout.r   )
rJ   	job_queuerun_once_trigger_timeoutrq   r&   rd   r   rH   rG   )rC   r   r(   r+   r   r*   j_queuerK   s           r7   r   !ConversationHandler._schedule_job  s      		K!++G292B2B%%))01A;` 3C 3D./
  	K;cJ	Ks   AA 
B%A>>Bc                 N   [        U[        5      (       d  gUR                  (       d  UR                  (       a  gU R                  (       a  UR
                  (       d  gU R                  (       a  UR                  (       d  gU R                  (       a  UR                  (       d  gUR                  (       a-  U R                  (       a  UR                  R                  (       d  gU R                  U5      nU R                  R                  U5      nSn[        U[        5      (       Ga  [        R!                  S5        UR#                  5       (       a  UR%                  5       nUR&                  c>  UR(                  R+                  5       (       a  U R                  R-                  US5        SnOU R/                  XR5        U R                  R                  U5      nO\U R0                  R                  U R2                  / 5      nU H/  nUR5                  U5      nUc  M  USLd  M   U R2                  X'U4s  $    g[        R!                  S[7        U5      [7        U5      5        SnUb  U R8                  (       a6  U R:                   H"  n	U	R5                  U5      nUc  M  USLd  M   U	n  O   Uc  gUbx  Ucu  U R0                  R                  U/ 5       H"  n
U
R5                  U5      nUc  M  USLd  M   U
n  O5   U R<                   H"  nUR5                  U5      nUc  M  USLd  M   Un  O   gX2X4$ )z
Determines whether an update should be handled by this conversation handler, and if so in
which state the conversation currently is.

Args:
    update (:class:`telegram.Update` | :obj:`object`): Incoming update.

Returns:
    :obj:`bool`

Nz&Waiting for asyncio Task to finish ...Fz'Selecting conversation %s with state %s)r   r   channel_postedited_channel_postrn   r   ro   r   rp   r   r   r   rY   getr9   rH   r   rA   rM   r<   r=   rG   popr   rk   ri   check_updater   rm   rj   rl   )rC   r+   r   r   checkrL   handlershandler_r   entry_point	candidatefallbacks               r7   r    ConversationHandler.check_update  s    &&))&"<"<==!6!6==!6!6F$9$9  T]]6;P;P;X;XmmF###'',"& e\**MMBC zz||mmo??*uzz/C/C/E/E''++C6 E&&s0 //33C8E  ;;??4<<< (H$11&9E(U%-?#||SEAA !) ?S3u:V)- =D..#00#008$e);)G	  1 = ![[__UB7	!..v6$e);'G	 8 !%H$11&9E(U%-?"*	 !/  7))r6   z)Application[Any, CCT, Any, Any, Any, Any]check_resultc           
        #    Uu  pVpxSn	U R                    ISh  vN   U R                  R                  US5      n
U
b  U
R                  5         SSS5      ISh  vN   UR                  [
        La  UR                  nOU R                  [
        La  U R                  nOw[        UR                  [        5      (       a8  UR                  R                  b!  UR                  R                  R                  nO [        R                  " UR                  5      n U(       a  UR                  XX5      I Sh  vN nO0UR                  UR                  XX5      USUR                   S3S9n U R                    ISh  vN   U R$                  (       a  UR&                  c  [)        SSS	9  OUR&                  R*                  R,                  (       d  [)        S
SS	9  Oc[        U[.        R0                  5      (       a1  UR                  U R3                  XXU5      USUR                   S3S9  OU R5                  XXU5        SSS5      ISh  vN   [        U R6                  [8        5      (       aq  XR6                  ;   ab  U R;                  U R<                  Xg5        U	(       a$  [!        U R6                  R?                  U5      5      eU R6                  R?                  U5      $ XPR@                  :w  a  U R;                  XU5        U	(       a  [         eg GN GN! , ISh  vN  (       d  f       GN= f GN! [          a  nUR"                  nSn	 SnAGNSnAff = f GN GN! , ISh  vN  (       d  f       GN'= f7f)a  Send the update to the callback for the current state and BaseHandler

Args:
    check_result: The result from :meth:`check_update`. For this handler it's a tuple of
        the conversation state, key, handler, and the handler's check result.
    update (:class:`telegram.Update`): Incoming telegram update.
    application (:class:`telegram.ext.Application`): Application that originated the
        update.
    context (:class:`telegram.ext.CallbackContext`): The context as provided by
        the application.

FNzConversationHandler:z:handle_update:non_blocking_cb)	coroutiner+   rr   TzHIgnoring `conversation_timeout` because the Application has no JobQueue.   r|   zQIgnoring `conversation_timeout` because the Applications JobQueue is not running.z:handle_update:timeout_job)r+   rr   )!rc   rd   r   schedule_removalru   r   rV   r   botr   defaultsr   	get_valuehandle_updatecreate_task	update_idr   r   rq   r   r   	schedulerrunningrO   rP   r   r   rt   r   r   rJ   r   ri   )rC   r+   r(   r   r   current_stater*   r   handler_check_resultraise_dp_handler_stoptimeout_jobru   r   rG   s                 r7   r  !ConversationHandler.handle_update   s    & JVF %***++//0@$GK&,,. +* ==,MME[[,KKE00[__5M5M5YOO,,22E **7==9E	)*1*?*?)=+ %	 (33%33-A "/0@0@/AA_` 4 	 ***((((0b#$ %..88@@'#$
  	7<<88  ++22%FEU  &3F4D4D3EE_` ,  &&yvP`a1 +*4 d(($//IASAS4Stxx)9C$,T-?-?-C-CI-NOO%%)))44LL(yGD  )(Y +***,% & 	)!I$(!	) +***s   M3LM30LM3LB;M3L, 2L)3L, 7M38/L, 'M38M9M3<B=M9M3MCM3M3L&LL&!M3)L, ,
M6M
M3
MM3M3M0M!M0+M3r   r   c                    XR                   :X  a  X R                  ;   a  U R                  U	 g g [        U[        R                  5      (       a1  [        U R                  R                  U5      US9U R                  U'   g Ubo  XR                  ;  aQ  [        Ub  [        UR                  R                  5      OS SU SU R                  b  SU R                  -   OS S3SS	9  XR                  U'   g g )
Nr;   r   z returned state z, which is unknown to the ConversationHandler  r   r{   r|   )rJ   rY   r   rO   rP   r9   r   rk   r   reprcallbackr.   rr   )rC   r   r   r   s       r7   r   !ConversationHandler._update_state  s      )))'', * 	7<<00'3--11#6Y(D$ "+:A:MtG,,556S`a b&&/[ 1*=AYY=R#		/XZ)[[\^  !	 (1$ #r6   c                   #    [        SUR                  5      n[        [        UR                  5      n[        R                  SUR                  5        UR                  nU R                   ISh  vN   U R                  R                  UR                  5      nXRLa   SSS5      ISh  vN   gU R                  UR                  	 SSS5      ISh  vN   U R                  R                  U R                  / 5      nU HZ  nUR                  UR                  5      nUc  M#  USLd  M*   UR                  UR                  UR                   X5      I Sh  vN   M\     U R'                  U R(                  UR                  5        g GN N N! , ISh  vN  (       d  f       N= f NP! ["         a    [%        SSS9   M  f = f7f)zThis is run whenever a conversation has timed out. Also makes sure that all handlers
which are in the :attr:`TIMEOUT` state and whose :meth:`BaseHandler.check_update` returns
:obj:`True` is handled.
r!   z7Conversation timeout was triggered for conversation %s!NFzWApplicationHandlerStop in TIMEOUT state of ConversationHandler has no effect. Ignoring.r{   r|   )r   jobr&   r   rH   r   r*   r)   rc   rd   r   rk   rg   r   r+   r  r(   r   r   r   rJ   )	rC   r   r  ctxtr)   	found_jobr   r   r   s	            r7   r   $ConversationHandler._trigger_timeout  sk    
 5'++&/:EtG\G\	
  00***))--d.C.CDI#	 +**
 !!$"7"78 +* ;;??4<<4G((5E U%%7	!//T%5%5u  	   	488T%:%:;/ +*** . G#$s   A-G/F0G3+F
G)F*G/F
GFAG!G)*F&F$F&,GGG
F!FF!G$F&&F>:G=F>>G)rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   ru   rd   r@   )9r.   r/   r0   r1   r2   r3   rJ   r   intr4   rg   ri   r   r   r   r   r   rQ   r   rR   r	   r
   floatdatetime	timedeltar   r   r   r   propertyrj   setterr   rk   rl   rm   ro   rn   rp   rq   rr   rs   rt   r   r   r   r   rO   rP   r   r   _CheckUpdateTyper   r  r   r   r5   r-   r6   r7   r#   r#   m   s=   ObI& CsPGU3Z GU3Z? $!KO" 8<*P(P;vsF':;<P VT+fc6.A"BCCDP FC$789	P
 P P P P 'uUH4F4F-F'GHP smP P  VV^ 45P d|Pd
# 
0 "d;vsF/B#CD " " 
f 
 
 

 VT+fc66I*J%KKL   ]]_ _8 _ _ 4FC,? @A   b6 bh b b #t # # 
v 
( 
 

 $   __a& aX a a $   __a& aX a a !T ! ! dV d d d *	%x1112	3* *   
f 
 
 !

 hsm   
[[]f ] ] ]  D     cF cx c c #xVV^(<= # # 
v 
( 
 

2(2	c< 788	92hv / 6
<<
 F
 	

 
 *
 

2KK FK 	K
 K *K 
K0Y*6 Y*h7G7L.M Y*vbb Ab 's+	b
 b 
&	bJ Y]11&51@H@U1	1.%<c %<d %<r6   )?r2   rO   r  dataclassesr   typingr   r   r   r   r   r	   r
   r   telegramr   telegram._utils.defaultvaluer   r   telegram._utils.loggingr   telegram._utils.reprr   telegram._utils.typesr   telegram._utils.warningsr   telegram.ext._applicationr   telegram.ext._extbotr   "telegram.ext._handlers.basehandlerr   +telegram.ext._handlers.callbackqueryhandlerr   0telegram.ext._handlers.choseninlineresulthandlerr   )telegram.ext._handlers.inlinequeryhandlerr   +telegram.ext._handlers.stringcommandhandlerr   )telegram.ext._handlers.stringregexhandlerr   "telegram.ext._handlers.typehandlerr    telegram.ext._utils.trackingdictr   telegram.ext._utils.typesr   r   r   r   r    r!   r"   r   rQ   r#  r.   rH   r&   r9   r#   r-   r6   r7   <module>r7     s   & 4   ! V V V  C . ? ( ) < ' : L V H L H : 9 L L77+fc6>Q2RTZZ[ 
X*?
@ 
'#, 
 
 ) ) )XS<+fc6&9: S<r6   