Add middleware and refactor admin handlers for improved functionality
- Introduced `DependenciesMiddleware` and `BlacklistMiddleware` for enhanced request handling across all routers. - Refactored admin handlers to utilize new middleware, improving access control and error handling. - Updated the `admin_router` to include middleware for access checks and streamlined the process of banning users. - Enhanced the structure of admin handler imports for better organization and maintainability. - Improved error handling in various admin functions to ensure robust user interactions.
This commit is contained in:
@@ -1,20 +1,45 @@
|
||||
"""Private handlers package for Telegram bot"""
|
||||
|
||||
from .private_handlers import private_router, create_private_handlers, PrivateHandlers
|
||||
from .services import BotSettings, UserService, PostService, StickerService
|
||||
from .constants import FSM_STATES, BUTTON_TEXTS, ERROR_MESSAGES
|
||||
# Local imports - main components
|
||||
from .private_handlers import (
|
||||
private_router,
|
||||
create_private_handlers,
|
||||
PrivateHandlers
|
||||
)
|
||||
|
||||
# Local imports - services
|
||||
from .services import (
|
||||
BotSettings,
|
||||
UserService,
|
||||
PostService,
|
||||
StickerService
|
||||
)
|
||||
|
||||
# Local imports - constants and utilities
|
||||
from .constants import (
|
||||
FSM_STATES,
|
||||
BUTTON_TEXTS,
|
||||
ERROR_MESSAGES
|
||||
)
|
||||
from .decorators import error_handler
|
||||
|
||||
__all__ = [
|
||||
# Main components
|
||||
'private_router',
|
||||
'create_private_handlers',
|
||||
'PrivateHandlers',
|
||||
|
||||
# Services
|
||||
'BotSettings',
|
||||
'UserService',
|
||||
'PostService',
|
||||
'StickerService',
|
||||
|
||||
# Constants
|
||||
'FSM_STATES',
|
||||
'BUTTON_TEXTS',
|
||||
'ERROR_MESSAGES',
|
||||
|
||||
# Utilities
|
||||
'error_handler'
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user