diff --git a/bot.py b/bot.py index 7a708d80..a995ed69 100644 --- a/bot.py +++ b/bot.py @@ -7,14 +7,14 @@ from aiogram.fsm.storage.memory import MemoryStorage from aiogram.types import ErrorEvent from config import API_TOKEN +from filters.private import IsPrivate from logger import logger from middlewares.admin import AdminMiddleware from middlewares.database import DatabaseMiddleware from middlewares.delete import DeleteMessageMiddleware from middlewares.logging import LoggingMiddleware -from middlewares.user import UserMiddleware from middlewares.throttling import ThrottlingMiddleware -from filters.private import IsPrivate +from middlewares.user import UserMiddleware bot = Bot(token=API_TOKEN, default=DefaultBotProperties(parse_mode=ParseMode.HTML)) storage = MemoryStorage() diff --git a/filters/private.py b/filters/private.py index 988db95c..334da487 100644 --- a/filters/private.py +++ b/filters/private.py @@ -5,4 +5,4 @@ from aiogram.types import Chat, TelegramObject class IsPrivate(BaseFilter): async def __call__(self, event: TelegramObject, event_chat: Chat) -> bool: - return event_chat.type == ChatType.PRIVATE \ No newline at end of file + return event_chat.type == ChatType.PRIVATE diff --git a/handlers/admin/admin_coupons.py b/handlers/admin/admin_coupons.py index f060acb7..9af0c575 100644 --- a/handlers/admin/admin_coupons.py +++ b/handlers/admin/admin_coupons.py @@ -72,7 +72,7 @@ async def show_coupon_list(callback_query: types.CallbackQuery, session: Any): builder.row(InlineKeyboardButton(text="⬅️ Предыдущая", callback_data=f"coupons:{current_page-1}")) if current_page < total_pages: builder.row(InlineKeyboardButton(text="➡️ Следующая", callback_data=f"coupons:{current_page+1}")) - + builder.row(InlineKeyboardButton(text="🔙 Назад", callback_data="coupons_editor")) await callback_query.message.answer(coupon_list, reply_markup=builder.as_markup()) diff --git a/handlers/keys/keys.py b/handlers/keys/keys.py index 65f3ba6d..8a9cbbb7 100644 --- a/handlers/keys/keys.py +++ b/handlers/keys/keys.py @@ -106,7 +106,7 @@ def build_keys_response(records): expiry_date = datetime.utcfromtimestamp(record["expiry_time"] / 1000).strftime("%d.%m.%Y") builder.row( InlineKeyboardButton( - text=f"🔑 {key_name} (до {expiry_date})", + text=f"🔑 {key_name} (до {expiry_date})", callback_data=f"view_key|{key_name}" ) ) diff --git a/handlers/notifications.py b/handlers/notifications.py index d5862e9d..cc3cc46c 100644 --- a/handlers/notifications.py +++ b/handlers/notifications.py @@ -1,8 +1,8 @@ import asyncio from datetime import datetime, timedelta -import pytz import asyncpg +import pytz from aiogram import Bot, Router, types from aiogram.exceptions import TelegramForbiddenError from aiogram.utils.keyboard import InlineKeyboardBuilder @@ -15,10 +15,10 @@ from config import ( AUTO_RENEW_KEYS, DATABASE_URL, DEV_MODE, + EXPIRED_KEYS_CHECK_INTERVAL, RENEWAL_PLANS, TOTAL_GB, TRIAL_TIME, - EXPIRED_KEYS_CHECK_INTERVAL ) from database import ( add_blocked_user, diff --git a/middlewares/throttling.py b/middlewares/throttling.py index af753651..8fd18052 100644 --- a/middlewares/throttling.py +++ b/middlewares/throttling.py @@ -1,4 +1,5 @@ -from typing import Any, Awaitable, Callable, MutableMapping +from collections.abc import Awaitable, Callable, MutableMapping +from typing import Any from aiogram import BaseMiddleware from aiogram.dispatcher.flags import get_flag @@ -7,6 +8,7 @@ from cachetools import TTLCache from logger import logger + class ThrottlingMiddleware(BaseMiddleware): def __init__( self, @@ -61,4 +63,4 @@ class ThrottlingMiddleware(BaseMiddleware): f"No throttling key provided for user {user.id}, proceeding without throttle." ) - return await handler(event, data) \ No newline at end of file + return await handler(event, data) diff --git a/requirements.txt b/requirements.txt index e5e3393f..2d8df8b2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -33,4 +33,5 @@ robokassa ping3 ruff pytz -cachetools \ No newline at end of file +cachetools +babel \ No newline at end of file