
    x'h
                     h    d Z ddlmZmZ  G d d      Z G d d      Z G d d      Z G d	 d
      Zy)z+
File with all middleware classes, states.
    )StateStatesGroupc                   2    e Zd ZU dZdZeed<   d Zd Zd Z	y)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                      y N selfs    X/var/www/flask-api/venv/lib/python3.12/site-packages/telebot/asyncio_handler_backends.py__init__zBaseMiddleware.__init__*           c                    K   t         wr	   NotImplementedError)r   messagedatas      r   pre_processzBaseMiddleware.pre_process-        !!   	c                    K   t         wr	   r   )r   r   r   	exceptions       r   post_processzBaseMiddleware.post_process0   r   r   N)
__name__
__module____qualname____doc__r   bool__annotations__r   r   r   r
   r   r   r   r      s$    @ #d"""r   r   c                       e Zd ZdZddZy)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.
    Nc                      y r	   r
   r   s    r   r   zSkipHandler.__init__=   r   r   returnNr   r   r   r   r   r
   r   r   r#   r#   4       r   r#   c                       e Zd ZdZddZy)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.
    Nc                      y r	   r
   r   s    r   r   zCancelUpdate.__init__J   r   r   r%   r'   r
   r   r   r*   r*   A   r(   r   r*   c                       e Zd ZdZddZy)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!')
   
    Nc                      y r	   r
   r   s    r   r   zContinueHandling.__init__a   r   r   r%   r'   r
   r   r   r-   r-   N   s    $r   r-   N)r   telebot.statesr   r   r   r#   r*   r-   r
   r   r   <module>r0      s8    .*" *"Z
 

 
 r   