diff --git a/bot.py b/bot.py
index 0e93fb3b..0c12b0f8 100644
--- a/bot.py
+++ b/bot.py
@@ -19,8 +19,3 @@ dp.include_router(keys.router)
dp.include_router(key_management.router)
dp.include_router(pay.router)
dp.include_router(notifications.router)
-
-
-
-async def on_startup(dispatcher: Dispatcher):
- await login_with_credentials()
diff --git a/handlers/notifications.py b/handlers/notifications.py
index 31dc7bf0..510886f4 100644
--- a/handlers/notifications.py
+++ b/handlers/notifications.py
@@ -7,7 +7,9 @@ from aiogram.types import ( # Импортируем необходимые к
InlineKeyboardButton, InlineKeyboardMarkup)
from bot import bot
-from config import DATABASE_URL
+from config import DATABASE_URL, ADMIN_PASSWORD, ADMIN_USERNAME
+from client import delete_client
+from auth import login_with_credentials
router = Router()
@@ -48,21 +50,31 @@ async def notify_expiring_keys(bot: Bot):
# Обрабатываем истекшие ключи
expired_records = await conn.fetch('''
- SELECT tg_id, email FROM keys
+ SELECT tg_id, email, client_id FROM keys
WHERE expiry_time <= $1
''', datetime.utcnow().timestamp() * 1000)
for record in expired_records:
tg_id = record['tg_id']
email = record['email']
+ client_id = record['client_id']
+
+ # Удаляем ключ из базы данных
+ await conn.execute('DELETE FROM keys WHERE client_id = $1', client_id)
+
+ # Создаем сессию с использованием учетных данных
+ session = login_with_credentials(ADMIN_USERNAME, ADMIN_PASSWORD)
+
+ # Удаляем клиента из панели
+ delete_client(session, client_id)
keyboard = InlineKeyboardMarkup(inline_keyboard=[
- [InlineKeyboardButton(text='1 месяц (100 руб.)', callback_data=f'renew_plan|1|{record["client_id"]}')],
- [InlineKeyboardButton(text='3 месяца (250 руб.)', callback_data=f'renew_plan|3|{record["client_id"]}')],
+ [InlineKeyboardButton(text='1 месяц (100 руб.)', callback_data=f'renew_plan|1|{client_id}')],
+ [InlineKeyboardButton(text='3 месяца (250 руб.)', callback_data=f'renew_plan|3|{client_id}')],
[InlineKeyboardButton(text='Пополнить баланс', callback_data='replenish_balance')]
])
- message = f"Ваш ключ {email} уже истек. Пожалуйста, продлите его."
+ message = f"Ваш ключ {email} уже истек и был удален. Пожалуйста, продлите его."
await bot.send_message(chat_id=tg_id, text=message, parse_mode='HTML', reply_markup=keyboard)
finally:
diff --git a/handlers/solo_pic.png b/handlers/solo_pic.png
deleted file mode 100644
index 484f1bdc..00000000
Binary files a/handlers/solo_pic.png and /dev/null differ