a
    9gn                     @  s  d dl mZ d dlZd dlmZ d dlmZmZ d dlm	Z	m
Z
 d dlmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZmZ d dl m!Z! d dl"m#Z# d dl$m%Z% d dl&m'Z' d dl(m)Z) d dl*m+Z+ d dl,m-Z- d dl.m/Z/m0Z0 G dd dZ1G dd dZ2G dd de	Z3G dd dZ4G dd dZ5e G dd dZ6d d d!d"d#d$Z7G d%d& d&Z8G d'd( d(Z9G d)d* d*Z:G d+d, d,Z;G d-d. d.Z<eG d/d0 d0Z=G d1d2 d2Z>G d3d4 d4Z?e? Z@dS )5    )annotationsN)defaultdict)	dataclassreplace)Enumauto)	AnyClassVarDictListOptionalTupleTypeUnionoverload)Self)loggers)
Dispatcher)NextMiddlewareType)CallableObjectCallbackType)extract_flags_from_object)Router)SceneException)StateFilter)
FSMContext)StateMemoryStorageRecord)TelegramObjectUpdatec                   @  s   e Zd Zd!ddddddZd	d
ddddZddddZddddZddddZddddZddddZ	d	d
ddddZ
d	dddZd S )"HistoryManagerscenes_history
   r   strint)statedestinysizec                 C  s*   || _ || _t|jt|j|dd| _d S )N)r'   )storagekey)_size_stater   r)   r   r*   _history_state)selfr&   r'   r(    r/   n/var/www/vosh/data/www/fastworkle.ru/webshop-tgbot-v.1.0/venv/lib/python3.9/site-packages/aiogram/fsm/scene.py__init__   s
    zHistoryManager.__init__Optional[str]Dict[str, Any]None)r&   datareturnc                   sr   | j  I d H }|dg }|||d t|| jkrJ|| j d  }tjd|| | j j	|dI d H  d S )Nhistoryr&   r5   z Push state=%s data=%s to historyr7   )
r-   get_data
setdefaultappendlenr+   r   scenedebugupdate_data)r.   r&   r5   history_datar7   r/   r/   r0   push!   s    zHistoryManager.pushzOptional[MemoryStorageRecord]r6   c                   s   | j  I d H }|dg }|s$d S | }|d }|d }|sT| j i I d H  n| j j|dI d H  tjd|| t	||dS )Nr7   r&   r5   r9   z!Pop state=%s data=%s from historyr8   )
r-   r:   r;   popset_datar@   r   r>   r?   r   )r.   rA   r7   recordr&   r5   r/   r/   r0   rD   +   s    zHistoryManager.popc                   s6   | j  I d H }|dg }|s$d S tf i |d S )Nr7   )r-   r:   r;   r   r.   rA   r7   r/   r/   r0   get:   s
    zHistoryManager.getzList[MemoryStorageRecord]c                   s*   | j  I d H }|dg }dd |D S )Nr7   c                 S  s   g | ]}t f i |qS r/   r   ).0itemr/   r/   r0   
<listcomp>D       z&HistoryManager.all.<locals>.<listcomp>)r-   r:   r;   rH   r/   r/   r0   allA   s    zHistoryManager.allc                   s"   t jd | ji I d H  d S )NzClear history)r   r>   r?   r-   rE   r.   r/   r/   r0   clearF   s    zHistoryManager.clearc                   s6   | j  I d H }| j  I d H }| ||I d H  d S N)r,   	get_stater:   rB   r.   r&   r5   r/   r/   r0   snapshotJ   s    zHistoryManager.snapshotc                   s(   | j |I d H  | j |I d H  d S rQ   )r,   	set_staterE   rS   r/   r/   r0   
_set_stateO   s    zHistoryManager._set_statec                   sX   |   I d H }|s(| d i I d H  d S tjd|j|j | |j|jI d H  |jS )NzRollback to state=%s data=%s)rD   rV   r   r>   r?   r&   r5   )r.   previous_stater/   r/   r0   rollbackS   s    zHistoryManager.rollbackN)r"   r#   )__name__
__module____qualname__r1   rB   rD   rI   rN   rP   rT   rV   rX   r/   r/   r/   r0   r!      s   
r!   c                   @  s   e Zd Zddddddddd	Zd
ddddZdddddZdddddZddddZdddddZddddZ	ddddZ
dS )ObserverDecoratorNr$   ztuple[CallbackType, ...]zSceneAction | NoneOptional[After]r4   )namefiltersactionafterr6   c                 C  s   || _ || _|| _|| _d S rQ   )r^   r_   r`   ra   )r.   r^   r_   r`   ra   r/   r/   r0   r1   c   s    zObserverDecorator.__init__zType[Scene] | CallbackType)targetr6   c                 C  s@   t |dd }|s g }t|d| |t| j|| j| jd d S )N__aiogram_handler__r^   handlerr_   ra   )getattrsetattrr<   HandlerContainerr^   r_   ra   )r.   rb   handlersr/   r/   r0   _wrap_filtero   s    zObserverDecorator._wrap_filterr   c                 C  sR   | j d usJ dt|dd }|d u r:tt}t|d| t||| j  | j< d S )NzScene action is not specified__aiogram_action__)r`   rf   r   dictrg   r   r^   )r.   rb   r`   r/   r/   r0   _wrap_action~   s    zObserverDecorator._wrap_actionc                 C  s8   t |r,| jd u r | | q4| | ntd|S )Nz"Only function or method is allowed)inspect
isfunctionr`   rj   rm   	TypeErrorr.   rb   r/   r/   r0   __call__   s    

zObserverDecorator.__call__ActionContainerrC   c                 C  s   t | j| jtjS rQ   )rs   r^   r_   SceneActionleaverO   r/   r/   r0   ru      s    zObserverDecorator.leaveType[Scene]c                 C  s   t | j| jtj|S rQ   )rs   r^   r_   rt   enterrq   r/   r/   r0   rw      s    zObserverDecorator.enterc                 C  s   t | j| jtjS rQ   )rs   r^   r_   rt   exitrO   r/   r/   r0   rx      s    zObserverDecorator.exitc                 C  s   t | j| jtjS rQ   )rs   r^   r_   rt   backrO   r/   r/   r0   ry      s    zObserverDecorator.back)NN)rY   rZ   r[   r1   rj   rm   rr   ru   rw   rx   ry   r/   r/   r/   r0   r\   b   s     	
r\   c                   @  s$   e Zd Ze Ze Ze Ze ZdS )rt   N)rY   rZ   r[   r   rw   ru   rx   ry   r/   r/   r/   r0   rt      s   rt   c                   @  s4   e Zd Zddddddddd	Zd
ddddZdS )rs   Nr$   Tuple[CallbackType, ...]rt   !Optional[Union[Type[Scene], str]]r4   )r^   r_   r`   rb   r6   c                 C  s   || _ || _|| _|| _d S rQ   )r^   r_   r`   rb   )r.   r^   r_   r`   rb   r/   r/   r0   r1      s    zActionContainer.__init__SceneWizardwizardr6   c                   s   | j tjkr*| jd ur*|| jI d H  nR| j tjkrF| I d H  n6| j tjkrb| I d H  n| j tjkr|| I d H  d S rQ   )r`   rt   rw   rb   gotoru   rx   ry   r.   r~   r/   r/   r0   execute   s    zActionContainer.execute)N)rY   rZ   r[   r1   r   r/   r/   r/   r0   rs      s    rs   c                   @  s$   e Zd Zd
dddddddd	ZdS )rh   Nr$   r   rz   r]   r4   )r^   re   r_   ra   r6   c                 C  s   || _ || _|| _|| _d S rQ   rd   )r.   r^   re   r_   ra   r/   r/   r0   r1      s    zHandlerContainer.__init__)N)rY   rZ   r[   r1   r/   r/   r/   r0   rh      s    rh   c                   @  sJ   e Zd ZU ded< ded< ded< dZded	< dZded
< dZded< dS )SceneConfigr2   r&   zList[HandlerContainer]ri   z,Dict[SceneAction, Dict[str, CallableObject]]actionsNzOptional[bool]reset_data_on_enterreset_history_on_entercallback_query_without_state)rY   rZ   r[   __annotations__r   r   r   r/   r/   r/   r0   r      s   
r   r   r4   )argskwargsr6   c                    s   d S rQ   r/   )r   r   r/   r/   r0   _empty_handler   s    r   c                   @  sP   e Zd ZddddddddZd	d
d
dddZddddZddddZdS )SceneHandlerWrapperNrv   r   r]   r4   )r>   re   ra   r6   c                 C  s   || _ t|| _|| _d S rQ   )r>   r   re   ra   )r.   r>   re   ra   r/   r/   r0   r1      s    
zSceneHandlerWrapper.__init__r   r   )eventr   r6   c           	   	     s   |d }|d }|d }| j t| j j|||j||dd}| jj||fi |I d H }| jrtdd| jj| jj }|	|j
I d H  |S )Nr&   scenesevent_updatescene_configmanagerr&   update_typer   r5   r~   ra   r/   )r>   r|   __scene_config__
event_typere   callra   rs   r`   r   r~   )	r.   r   r   r&   r   r   r>   resultZaction_containerr/   r/   r0   rr      s.    zSceneHandlerWrapper.__call__r   rC   c                 C  s   | S rQ   r/   rO   r/   r/   r0   	__await__	  s    zSceneHandlerWrapper.__await__r$   c                 C  s8   d| j  d| jj }| jr,|d| j 7 }|d7 }|S )NzSceneHandlerWrapper(z, z, after=))r>   re   callbackra   )r.   r   r/   r/   r0   __str__  s
    zSceneHandlerWrapper.__str__)N)rY   rZ   r[   r1   rr   r   r   r/   r/   r/   r0   r      s
    
r   c                      s   e Zd ZU dZded< dddddZd	dd
 fddZedddddZeddddddZ	ed	dd
ddZ
  ZS )Scenea  
    Represents a scene in a conversation flow.

    A scene is a specific state in a conversation where certain actions can take place.

    Each scene has a set of filters that determine when it should be triggered,
    and a set of handlers that define the actions to be executed when the scene is active.

    .. note::
        This class is not meant to be used directly. Instead, it should be subclassed
        to define custom scenes.
    zClassVar[SceneConfig]r   r|   r4   r}   c                 C  s   || _ | | j _d S rQ   )r~   r>   r   r/   r/   r0   r1   %  s    zScene.__init__r   r   r6   c              	     sB  | dd }| dd }| dd }| dd }t jf i | g }tt}| jD ]L}t|tsdqTt|dd }	|	svqT|d u r|	j	}|d u r|	j
}|d u rT|	j}qTt| D ]v\}
}t|dd  }r|| t|tr|t|jt|j|jd t|dr|j D ]\}}|| | qqt||t||||d	| _d S )
Nr&   r   r   r   r   rc   ra   rk   )r&   ri   r   r   r   r   )rD   super__init_subclass__r   rl   	__bases__
issubclassr   rf   r   r   r   rn   
getmembersextend
isinstancer\   r<   rh   r^   r   r_   ra   hasattrrk   itemsupdater   r   )clsr   Z
state_namer   r   r   ri   r   baseZparent_scene_configr^   valueZscene_handlersr`   Zaction_handlers	__class__r/   r0   r   ,  sT    




zScene.__init_subclass__r   routerr6   c                 C  s   | j }t }|jD ]F}|j|j jt| |j|jdg|j	R dt
|ji ||j q|D ]*}|jrr|dkrrq^|j| t|j q^dS )z^
        Adds the scene to the given router.

        :param router:
        :return:
        r   flagscallback_queryN)r   setri   	observersr^   registerr   re   ra   r_   r   addr   filterr   r&   )r   r   r   Zused_observersre   Zobserver_namer/   r/   r0   add_to_router_  s&    
	zScene.add_to_routerNr2   r^   r6   c                 C  s>   |du r&d| j  d| j d| jj}t|d}| | |S )zM
        Returns the scene as a router.

        :return: new router
        NzScene '.z' for state r^   )rZ   r[   r   r&   r   r   )r   r^   r   r/   r/   r0   	as_router{  s    

zScene.as_routerr   c                   s   dddd fdd}|S )z
        Create an entry point handler for the scene, can be used to simplify the handler
        that starts the scene.

        >>> router.message.register(MyScene.as_handler(), Command("start"))
        r   ScenesManagerr4   )r   r   r6   c                   s   |j  fi I d H  d S rQ   )rw   )r   r   r   r   r/   r0   enter_to_scene_handler  s    z0Scene.as_handler.<locals>.enter_to_scene_handlerr/   )r   r   r   r/   r   r0   
as_handler  s    	zScene.as_handler)N)rY   rZ   r[   __doc__r   r1   r   classmethodr   r   r   __classcell__r/   r/   r   r0   r     s   
3r   c                   @  s  e Zd ZdZdddddddd	d
ZdddddZd7ddddddZdddddZdddddZdddddZ	ddddddZ
dddd d!d"Zddd#d$d%Zdd&d'd(Zedd)d*d+d,Zedddd-d.d,Zd8dd)d)d-d0d,Zd9d1ddd2d3d4Zdd&d5d6Zd/S ):r|   as  
    A class that represents a wizard for managing scenes in a Telegram bot.

    Instance of this class is passed to each scene as a parameter.
    So, you can use it to transition between scenes, get and set data, etc.

    .. note::

        This class is not meant to be used directly. Instead, it should be used
        as a parameter in the scene constructor.

    r   r   r   r$   r   r3   r   c                 C  s.   || _ || _|| _|| _|| _|| _d| _dS )a  
        A class that represents a wizard for managing scenes in a Telegram bot.

        :param scene_config: The configuration of the scene.
        :param manager: The scene manager.
        :param state: The FSMContext object for storing the state of the scene.
        :param update_type: The type of the update event.
        :param event: The TelegramObject represents the event.
        :param data: Additional data for the scene.
        N)r   r   r&   r   r   r5   r>   )r.   r   r   r&   r   r   r5   r/   r/   r0   r1     s    zSceneWizard.__init__r   r4   r   c                   sz   t jd| jj | jjr,| ji I dH  | jjrF| jj	
 I dH  | j| jjI dH  | jtjfi |I dH  dS )a  
        Enter method is used to transition into a scene in the SceneWizard class.
        It sets the state, clears data and history if specified,
        and triggers entering event of the scene.

        :param kwargs: Additional keyword arguments.
        :return: None
        zEntering scene %rN)r   r>   r?   r   r&   r   rE   r   r   r7   rP   rU   
_on_actionrt   rw   r.   r   r/   r/   r0   rw     s    	zSceneWizard.enterTbool)_with_historyr   r6   c                   sF   t jd| jj |r(| jj I dH  | jt	j
fi |I dH  dS )a"  
        Leaves the current scene.
        This method is used to exit a scene and transition to the next scene.

        :param _with_history: Whether to include history in the snapshot. Defaults to True.
        :param kwargs: Additional keyword arguments.
        :return: None

        zLeaving scene %rN)r   r>   r?   r   r&   r   r7   rT   r   rt   ru   )r.   r   r   r/   r/   r0   ru     s    
zSceneWizard.leavec                   s^   t jd| jj | jj I dH  | jt	j
fi |I dH  | jjdddi|I dH  dS )z
        Exit the current scene and enter the default scene/state.

        :param kwargs: Additional keyword arguments.
        :return: None
        zExiting scene %rN_check_activeF)N)r   r>   r?   r   r&   r   r7   rP   r   rt   rx   rw   r   r/   r/   r0   rx     s    zSceneWizard.exitc                   s`   t jd| jj | jf ddi|I dH  | jj I dH }| jj	|fddi|I dH  dS )z
        This method is used to go back to the previous scene.

        :param kwargs: Keyword arguments that can be passed to the method.
        :return: None
        z$Back to previous scene from scene %sr   FNr   )
r   r>   r?   r   r&   ru   r   r7   rX   rw   )r.   r   Z	new_scener/   r/   r0   ry     s    zSceneWizard.backc                   s4   | j jdusJ d| j| j jfi |I dH  dS )z
        This method allows to re-enter the current scene.

        :param kwargs: Additional keyword arguments to pass to the scene.
        :return: None
        NzScene state is not specified)r   r&   r   r   r/   r/   r0   retake  s    zSceneWizard.retakezUnion[Type[Scene], str])r>   r   r6   c                   s8   | j f i |I dH  | jj|fddi|I dH  dS )a  
        The `goto` method transitions to a new scene.
        It first calls the `leave` method to perform any necessary cleanup
        in the current scene, then calls the `enter` event to enter the specified scene.

        :param scene: The scene to transition to. Can be either a `Scene` instance
            or a string representing the scene.
        :param kwargs: Additional keyword arguments to pass to the `enter`
            method of the scene manager.
        :return: None
        Nr   F)ru   r   rw   )r.   r>   r   r/   r/   r0   r     s    zSceneWizard.gotort   )r`   r   r6   c                   s   | j stdtj d|j| jj | jj|i }|sRtj d|j| jj dS | j	}||vr|tj d|j|| jj dS || j
| j | jfi i | j|I d H  dS )NzScene is not initializedzCall action %r in scene %rzAction %r not found in scene %rFz,Action %r for event %r not found in scene %rT)r>   r   r   r?   r^   r   r&   r   rI   r   r   r   r5   )r.   r`   r   Zaction_configr   r/   r/   r0   r     s(    ,zSceneWizard._on_action)r5   r6   c                   s   | j j|dI dH  dS )z
        Sets custom data in the current state.

        :param data: A dictionary containing the custom data to be set in the current state.
        :return: None
        r5   N)r&   rE   )r.   r5   r/   r/   r0   rE   .  s    zSceneWizard.set_datarC   c                   s   | j  I dH S )z
        This method returns the data stored in the current state.

        :return: A dictionary containing the data stored in the scene state.
        N)r&   r:   rO   r/   r/   r0   r:   7  s    zSceneWizard.get_datazOptional[Any])r*   r6   c                   s   dS )z
        This method returns the value from key in the data of the current state.

        :param key: The keyname of the item you want to return the value from.

        :return: A dictionary containing the data stored in the scene state.
        Nr/   )r.   r*   r/   r/   r0   	get_value?  s    	zSceneWizard.get_value)r*   defaultr6   c                   s   dS )aC  
        This method returns the value from key in the data of the current state.

        :param key: The keyname of the item you want to return the value from.
        :param default: Default value to return, if ``key`` was not found.

        :return: A dictionary containing the data stored in the scene state.
        Nr/   r.   r*   r   r/   r/   r0   r   J  s    
Nc                   s   | j ||I d H S rQ   )r&   r   r   r/   r/   r0   r   V  s    zOptional[Dict[str, Any]])r5   r   r6   c                   s"   |r| | | jj|dI dH S )z
        This method updates the data stored in the current state

        :param data: Optional dictionary of data to update.
        :param kwargs: Additional key-value pairs of data to update.
        :return: Dictionary of updated data
        r   N)r   r&   r@   )r.   r5   r   r/   r/   r0   r@   Y  s    

zSceneWizard.update_datac                   s   |  i I dH  dS )z9
        Clears the data.

        :return: None
        N)rE   rO   r/   r/   r0   
clear_datag  s    zSceneWizard.clear_data)T)N)N)rY   rZ   r[   r   r1   rw   ru   rx   ry   r   r   r   rE   r:   r   r   r@   r   r/   r/   r/   r0   r|     s&   
	
 r|   c                   @  sl   e Zd ZdZdddddddd	d
ZdddddZddddZddddddddZdddddZdS )r   z
    The ScenesManager class is responsible for managing scenes in an application.
    It provides methods for entering and exiting scenes, as well as retrieving the active scene.
    SceneRegistryr$   r   r   r3   r4   )registryr   r   r&   r5   r6   c                 C  s.   || _ || _|| _|| _|| _t| j| _d S rQ   )r   r   r   r&   r5   r!   r7   )r.   r   r   r   r&   r5   r/   r/   r0   r1   v  s    zScenesManager.__init__r{   r   )
scene_typer6   c              	     s0   | j |}|t|j| | j| j| j| jddS )Nr   r   )r   rI   r|   r   r&   r   r   r5   )r.   r   r/   r/   r0   
_get_scene  s    zScenesManager._get_scenezOptional[Scene]rC   c                   s<   | j  I d H }z| |I d H W S  ty6   Y d S 0 d S rQ   )r&   rR   r   r   )r.   r&   r/   r/   r0   _get_active_scene  s
    zScenesManager._get_active_sceneTr   r   )r   r   r   r6   c                   s   |r2|   I dH }|dur2|jjf i |I dH  z| |I dH }W n. tyt   |dur^ | jdI dH  Y n0 |jjf i |I dH  dS )a  
        Enters the specified scene.

        :param scene_type: Optional Type[Scene] or str representing the scene type to enter.
        :param _check_active: Optional bool indicating whether to check if
            there is an active scene to exit before entering the new scene. Defaults to True.
        :param kwargs: Additional keyword arguments to pass to the scene's wizard.enter() method.
        :return: None
        N)r   r~   rx   r   r   r&   rU   rw   )r.   r   r   r   Zactive_scener>   r/   r/   r0   rw     s    zScenesManager.enterr   c                   s2   |   I dH }|sdS |jjf i |I dH  dS )z
        Close method is used to exit the currently active scene in the ScenesManager.

        :param kwargs: Additional keyword arguments passed to the scene's exit method.
        :return: None
        N)r   r~   rx   )r.   r   r>   r/   r/   r0   close  s    zScenesManager.closeN)T)	rY   rZ   r[   r   r1   r   r   rw   r   r/   r/   r/   r0   r   p  s   
 r   c                   @  s   e Zd ZdZd#ddddddZddd	d
dZdddddddZdddddddZddddddddZdddddZ	ddd d!d"Z
dS )$r   zJ
    A class that represents a registry for scenes in a Telegram bot.
    Tr   r   r4   )r   register_on_addr6   c                 C  s    || _ || _i | _| | dS )z
        Initialize a new instance of the SceneRegistry class.

        :param router: The router instance used for scene registration.
        :param register_on_add: Whether to register the scenes to the router when they are added.
        N)r   r   _scenes_setup_middleware)r.   r   r   r/   r/   r0   r1     s    zSceneRegistry.__init__r   c                 C  sH   t |tr|j| j d S |j D ]}|jdv r6q&|| j q&d S )N>   errorr   )	r   r   r   Zouter_middleware_update_middlewarer   valuesZ
event_name_middleware)r.   r   Zobserverr/   r/   r0   r     s    

zSceneRegistry._setup_middlewarez"NextMiddlewareType[TelegramObject]r   r3   r   )re   r   r5   r6   c                   s@   t |tsJ dt| |j|j|d |d|d< |||I d H S )Nz Event must be an Update instancer&   r   r   r   r&   r5   r   )r   r    r   r   r   )r.   re   r   r5   r/   r/   r0   r     s    
z SceneRegistry._update_middlewarec                   s4   |d }t | |j||d |d|d< |||I d H S )Nr   r&   r   r   )r   r   )r.   re   r   r5   r   r/   r/   r0   r     s    
zSceneRegistry._middlewareN)r   rv   zOptional[Router])r   r   r6   c                G  st   |st d|D ]^}|jj| jv r6td|jjd|| j|jj< |rX||  q| jr| j|  qdS )a  
        This method adds the specified scenes to the registry
        and optionally registers it to the router.

        If a scene with the same state already exists in the registry, a SceneException is raised.

        .. warning::

            If the router is not specified, the scenes will not be registered to the router.
            You will need to include the scenes manually to the router or use the register method.

        :param scenes: A variable length parameter that accepts one or more types of scenes.
            These scenes are instances of the Scene class.
        :param router: An optional parameter that specifies the router
            to which the scenes should be added.
        :return: None
        z$At least one scene must be specifiedzScene with state z already existsN)	
ValueErrorr   r&   r   r   Zinclude_routerr   r   r   )r.   r   r   r>   r/   r/   r0   r     s    zSceneRegistry.add)r   r6   c                 G  s   | j |d| ji dS )z
        Registers one or more scenes to the SceneRegistry.

        :param scenes: One or more scene classes to register.
        :return: None
        r   N)r   r   )r.   r   r/   r/   r0   r   %  s    zSceneRegistry.registerr{   r>   r6   c                 C  sz   t |rt|tr|jj}t|tr,|j}|durFt|tsFt	dz| j
| W S  tyt   t	d|dY n0 dS )a  
        This method returns the registered Scene object for the specified scene.
        The scene parameter can be either a Scene object or a string representing
        the name of the scene. If a Scene object is provided, the state attribute
        of the SceneConfig object associated with the Scene object will be used as the scene name.
        If None or an invalid type is provided, a SceneException will be raised.

        If the specified scene is not registered in the SceneRegistry object,
        a SceneException will be raised.

        :param scene: A Scene object or a string representing the name of the scene.
        :return: The registered Scene object corresponding to the given scene parameter.

        Nz-Scene must be a subclass of Scene or a stringzScene z is not registered)rn   isclassr   r   r   r&   r   r   r$   r   r   KeyError)r.   r>   r/   r/   r0   rI   .  s    
zSceneRegistry.get)T)rY   rZ   r[   r   r1   r   r   r   r   r   rI   r/   r/   r/   r0   r     s   "	r   c                   @  sZ   e Zd ZU ded< dZded< ed dddZed dd	d
Zedd dddZdS )Afterrt   r`   Nr{   r>   rC   c                 C  s   | t jdS Nr`   )rt   rx   r   r/   r/   r0   rx   O  s    z
After.exitc                 C  s   | t jdS r   )rt   ry   r   r/   r/   r0   ry   S  s    z
After.backr   c                 C  s   | t j|dS )N)r`   r>   )rt   rw   )r   r>   r/   r/   r0   r   W  s    z
After.goto)	rY   rZ   r[   r   r>   r   rx   ry   r   r/   r/   r/   r0   r   J  s   
r   c                   @  sn   e Zd ZdddddZdddd	d
dddZdd
dddZd
dddZd
dddZd
dddZdS )ObserverMarkerr$   r4   r   c                 C  s
   || _ d S rQ   r   )r.   r^   r/   r/   r0   r1   ]  s    zObserverMarker.__init__Nr   r   r]   r\   )r_   ra   r6   c                G  s   t | j||dS )Nr   )r\   r^   )r.   ra   r_   r/   r/   r0   rr   `  s
    zObserverMarker.__call__)r_   r6   c                 G  s   t | j|tjdS r   )r\   r^   rt   rw   )r.   r_   r/   r/   r0   rw   k  s    zObserverMarker.enterrC   c                 C  s   t | jdtjdS Nr/   r   )r\   r^   rt   ru   rO   r/   r/   r0   ru   n  s    zObserverMarker.leavec                 C  s   t | jdtjdS r   )r\   r^   rt   rx   rO   r/   r/   r0   rx   q  s    zObserverMarker.exitc                 C  s   t | jdtjdS r   )r\   r^   rt   ry   rO   r/   r/   r0   ry   t  s    zObserverMarker.back)	rY   rZ   r[   r1   rr   rw   ru   rx   ry   r/   r/   r/   r0   r   \  s   r   c                   @  s   e Zd ZdZedZedZedZedZedZ	edZ
edZed	Zed
ZedZedZedZedZedZdS )OnMarkera}  
    The `OnMarker` class is used as a marker class to define different
    types of events in the Scenes.

    Attributes:

    - :code:`message`: Event marker for handling `Message` events.
    - :code:`edited_message`: Event marker for handling edited `Message` events.
    - :code:`channel_post`: Event marker for handling channel `Post` events.
    - :code:`edited_channel_post`: Event marker for handling edited channel `Post` events.
    - :code:`inline_query`: Event marker for handling `InlineQuery` events.
    - :code:`chosen_inline_result`: Event marker for handling chosen `InlineResult` events.
    - :code:`callback_query`: Event marker for handling `CallbackQuery` events.
    - :code:`shipping_query`: Event marker for handling `ShippingQuery` events.
    - :code:`pre_checkout_query`: Event marker for handling `PreCheckoutQuery` events.
    - :code:`poll`: Event marker for handling `Poll` events.
    - :code:`poll_answer`: Event marker for handling `PollAnswer` events.
    - :code:`my_chat_member`: Event marker for handling my chat `Member` events.
    - :code:`chat_member`: Event marker for handling chat `Member` events.
    - :code:`chat_join_request`: Event marker for handling chat `JoinRequest` events.
    - :code:`error`: Event marker for handling `Error` events.

    .. note::

        This is a marker class and does not contain any methods or implementation logic.
    messageedited_messagechannel_postedited_channel_postinline_querychosen_inline_resultr   shipping_querypre_checkout_querypollpoll_answermy_chat_memberchat_memberchat_join_requestN)rY   rZ   r[   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r/   r/   r/   r0   r   x  s   r   )A
__future__r   rn   collectionsr   Zdataclassesr   r   enumr   r   typingr   r	   r
   r   r   r   r   r   r   Ztyping_extensionsr   Zaiogramr   Zaiogram.dispatcher.dispatcherr   Zaiogram.dispatcher.event.basesr   Z aiogram.dispatcher.event.handlerr   r   Zaiogram.dispatcher.flagsr   Zaiogram.dispatcher.routerr   Zaiogram.exceptionsr   Zaiogram.filtersr   Zaiogram.fsm.contextr   Zaiogram.fsm.stater   Zaiogram.fsm.storage.memoryr   Zaiogram.typesr   r    r!   r\   rt   rs   rh   r   r   r   r   r|   r   r   r   r   r   onr/   r/   r/   r0   <module>   sN   ,I<5  WT ,