a
    /ð3e©  ã                   @   s\   d Z G dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ dƒZG d	d
„ d
ƒZG dd„ dƒZdS )z+
File with all middleware classes, states.
c                   @   s6   e Zd ZU dZdZeed< dd„ Zdd„ Zdd	„ Z	d
S )ÚBaseMiddlewareaÀ  
    Base class for middleware.
    Your middlewares should be inherited from this class.

    Set update_sensitive=True if you want to get different updates on
    different functions. For example, if you want to handle pre_process for
    message update, then you will have to create pre_process_message function, and
    so on. Same applies to post_process.

    .. code-block:: python
        :caption: Example of class-based middlewares

        class MyMiddleware(BaseMiddleware):
            def __init__(self):
                self.update_sensitive = True
                self.update_types = ['message', 'edited_message']
            
            async def pre_process_message(self, message, data):
                # only message update here
                pass

            async def post_process_message(self, message, data, exception):
                pass # only message update here for post_process

            async def pre_process_edited_message(self, message, data):
                # only edited_message update here
                pass

            async def post_process_edited_message(self, message, data, exception):
                pass # only edited_message update here for post_process
    FÚupdate_sensitivec                 C   s   d S ©N© ©Úselfr   r   úS/home/pi/bot/my_env/lib/python3.9/site-packages/telebot/asyncio_handler_backends.pyÚ__init__)   s    zBaseMiddleware.__init__c                 Ã   s   t ‚d S r   ©ÚNotImplementedError)r   ÚmessageÚdatar   r   r   Úpre_process,   s    zBaseMiddleware.pre_processc                 Ã   s   t ‚d S r   r	   )r   r   r   Ú	exceptionr   r   r   Úpost_process/   s    zBaseMiddleware.post_processN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚboolÚ__annotations__r   r   r   r   r   r   r   r      s
   
 r   c                   @   s,   e Zd ZdZddœdd„Zedœdd„ZdS )ÚStatez¨
    Class representing a state.

    .. code-block:: python3

        class MyStates(StatesGroup):
            my_state = State() # returns my_state:State string.
    N©Úreturnc                 C   s
   d | _ d S r   ©Únamer   r   r   r   r   <   s    zState.__init__c                 C   s   | j S r   r   r   r   r   r   Ú__str__?   s    zState.__str__)r   r   r   r   r   Ústrr   r   r   r   r   r   3   s   r   c                   @   s*   e Zd ZdZddœdd„Zedd„ ƒZdS )ÚStatesGroupz®
    Class representing common states.

    .. code-block:: python3

        class MyStates(StatesGroup):
            my_state = State() # returns my_state:State string.
    Nr   c                 C   s`   g }| j  ¡ D ]F\}}| d¡st|ƒst|tƒrd | j|f¡|_| |_	| 
|¡ q|| _d S )NÚ__ú:)Ú__dict__ÚitemsÚ
startswithÚcallableÚ
isinstancer   Újoinr   r   ÚgroupÚappendÚ_state_list)ÚclsÚ
state_listr   Úvaluer   r   r   Ú__init_subclass__L   s    zStatesGroup.__init_subclass__c                 C   s   | j S r   )r(   r   r   r   r   r*   V   s    zStatesGroup.state_list)r   r   r   r   r,   Úpropertyr*   r   r   r   r   r   C   s   
r   c                   @   s   e Zd ZdZddœdd„ZdS )ÚSkipHandlerz½
    Class for skipping handlers.
    Just return instance of this class 
    in middleware to skip handler.
    Update will go to post_process,
    but will skip execution of handler.
    Nr   c                 C   s   d S r   r   r   r   r   r   r   d   s    zSkipHandler.__init__©r   r   r   r   r   r   r   r   r   r.   [   s   r.   c                   @   s   e Zd ZdZddœdd„ZdS )ÚCancelUpdatez¿
    Class for canceling updates.
    Just return instance of this class 
    in middleware to skip update.
    Update will skip handler and execution
    of post_process in middlewares.
    Nr   c                 C   s   d S r   r   r   r   r   r   r   q   s    zCancelUpdate.__init__r/   r   r   r   r   r0   h   s   r0   c                   @   s   e Zd ZdZddœdd„ZdS )ÚContinueHandlinga7  
    Class for continue updates in handlers.
    Just return instance of this class 
    in handlers to continue process.
    
    .. code-block:: python3
        :caption: Example of using ContinueHandling

        @bot.message_handler(commands=['start'])
        async def start(message):
            await bot.send_message(message.chat.id, 'Hello World!')
            return ContinueHandling()
        
        @bot.message_handler(commands=['start'])
        async def start2(message):
            await bot.send_message(message.chat.id, 'Hello World2!')
   
    Nr   c                 C   s   d S r   r   r   r   r   r   r   ˆ   s    zContinueHandling.__init__r/   r   r   r   r   r1   u   s   r1   N)r   r   r   r   r.   r0   r1   r   r   r   r   Ú<module>   s   -