mirror of
https://github.com/ada-dmitry/kurator_bot.git
synced 2026-09-25 16:50:15 +00:00
Init
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
from telebot.handler_backends import BaseMiddleware
|
||||
from telebot import TeleBot
|
||||
from telebot.states.sync.context import StateContext
|
||||
from telebot.util import update_types
|
||||
from telebot import types
|
||||
|
||||
|
||||
class StateMiddleware(BaseMiddleware):
|
||||
|
||||
def __init__(self, bot: TeleBot) -> None:
|
||||
self.update_sensitive = False
|
||||
self.update_types = update_types
|
||||
self.bot: TeleBot = bot
|
||||
|
||||
def pre_process(self, message, data):
|
||||
state_context = StateContext(message, self.bot)
|
||||
data['state_context'] = state_context
|
||||
data['state'] = state_context # 2 ways to access state context
|
||||
|
||||
def post_process(self, message, data, exception):
|
||||
pass
|
||||
Reference in New Issue
Block a user