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:
29
helper_bot/handlers/callback/constants.py
Normal file
29
helper_bot/handlers/callback/constants.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# Callback data constants
|
||||
CALLBACK_PUBLISH = "publish"
|
||||
CALLBACK_DECLINE = "decline"
|
||||
CALLBACK_BAN = "ban"
|
||||
CALLBACK_UNLOCK = "unlock"
|
||||
CALLBACK_RETURN = "return"
|
||||
CALLBACK_PAGE = "page"
|
||||
|
||||
# Content types
|
||||
CONTENT_TYPE_TEXT = "text"
|
||||
CONTENT_TYPE_PHOTO = "photo"
|
||||
CONTENT_TYPE_VIDEO = "video"
|
||||
CONTENT_TYPE_VIDEO_NOTE = "video_note"
|
||||
CONTENT_TYPE_AUDIO = "audio"
|
||||
CONTENT_TYPE_VOICE = "voice"
|
||||
CONTENT_TYPE_MEDIA_GROUP = "^"
|
||||
|
||||
# Messages
|
||||
MESSAGE_PUBLISHED = "Выложено!"
|
||||
MESSAGE_DECLINED = "Отклонено!"
|
||||
MESSAGE_USER_BANNED = "Пользователь заблокирован!"
|
||||
MESSAGE_USER_UNLOCKED = "Пользователь разблокирован"
|
||||
MESSAGE_ERROR = "Что-то пошло не так!"
|
||||
MESSAGE_POST_PUBLISHED = "Твой пост был выложен🥰"
|
||||
MESSAGE_POST_DECLINED = "Твой пост был отклонен😔"
|
||||
MESSAGE_USER_BANNED_SPAM = "Ты заблокирован за спам. Дата разблокировки: {date}"
|
||||
|
||||
# Error messages
|
||||
ERROR_BOT_BLOCKED = "Forbidden: bot was blocked by the user"
|
||||
Reference in New Issue
Block a user