From e2e2761b510a15673e0d8b87aaa875c1fe3253e8 Mon Sep 17 00:00:00 2001 From: Yuriy Yuriev Date: Fri, 22 May 2026 23:06:31 +0700 Subject: [PATCH] fix comand --- auth/manager.py | 4 ++++ handlers/commands.py | 17 ++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/auth/manager.py b/auth/manager.py index 47cc771..94a56b2 100644 --- a/auth/manager.py +++ b/auth/manager.py @@ -37,6 +37,10 @@ class AuthManager: def is_authenticated(self, user_id: int) -> bool: if user_id not in self._sessions: return False + # Обычные пользователи — сессия бесконечная + if self._roles.get(user_id) != "admin": + return True + # Админы — таймаут применяется if datetime.now() - self._sessions[user_id] > self._session_timeout: self.logout(user_id) return False diff --git a/handlers/commands.py b/handlers/commands.py index 867adef..dc49063 100644 --- a/handlers/commands.py +++ b/handlers/commands.py @@ -2952,18 +2952,21 @@ class BotInterface: cost = int(value * settings.CLICK_PRICE_RUB) - # Сохраняем для шага подтверждения self._payment_confirm[user_id] = {"clicks": value, "rub": cost} + rub_bal = await self.rub_storage.get_balance(user_id) builder = InlineKeyboardBuilder() - builder.row( - InlineKeyboardButton(text="✅ Подтвердить", callback_data="confirm_buy"), - InlineKeyboardButton(text="❌ Отмена", callback_data="cancel_confirm_buy"), - ) + if rub_bal >= cost: + builder.row(InlineKeyboardButton( + text=f"💰 С баланса ({rub_bal} ₽)", + callback_data="pay_from_balance" + )) + builder.row(InlineKeyboardButton(text="💳 Оплатить криптой", callback_data="confirm_buy")) + builder.row(InlineKeyboardButton(text="❌ Отмена", callback_data="cancel_confirm_buy")) await _edit_prompt( f"🛒 Подтвердите покупку\n\n" - f"🔢 {value} переходов\n" - f"💰 Стоимость: {cost} ₽", + f"🔢 {value} переходов × {fmt_price(settings.CLICK_PRICE_RUB)} ₽ = {cost} ₽" + + (f"\n\n🪙 Ваш баланс: {rub_bal} ₽" if rub_bal > 0 else ""), builder.as_markup() )