-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all update types are supported for states(theoretically)
- Loading branch information
1 parent
7e5a044
commit 4a7bc5d
Showing
5 changed files
with
69 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
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 = ['message', 'edited_message', 'callback_query'] #TODO: support other types | ||
self.update_types = update_types | ||
self.bot: TeleBot = bot | ||
|
||
def pre_process(self, message, data): | ||
data['state_context'] = StateContext(message, self.bot) | ||
|
||
def post_process(self, message, data, exception): | ||
pass | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters