refactor: balance handling and upload processing

This commit is contained in:
2026-07-24 16:48:32 +05:00
parent 8bd5c80693
commit 9009147b52
9 changed files with 341 additions and 122 deletions
+13 -3
View File
@@ -11,7 +11,10 @@ from bot.services.redeem import (
redeem_all_bots_keys,
redeem_single_bot_keys,
)
from bot.services.bot_accounts import list_user_bot_accounts
from bot.services.bot_accounts import (
get_owned_bot,
list_user_activation_bot_accounts,
)
from bot.states import ConsoleFlow, RedeemFlow
@@ -103,12 +106,19 @@ async def handle_single_bot_redeem(message: Message, state: FSMContext):
bot_name = state_data.get("bot_name")
account_id = state_data.get("account_id")
if not isinstance(bot_name, str) or not bot_name:
if not isinstance(account_id, int):
await message.answer("Контекст потерян, попробуйте еще раз.")
await state.clear()
return
account = await get_owned_bot(message.from_user.id, account_id)
if account is None:
await message.answer("Бот больше недоступен для активации ключей.")
await state.clear()
return
bot_name = account.bot_name
chat_id = message.chat.id
menu_message_id = state_data.get("menu_message_id")
@@ -257,7 +267,7 @@ async def handle_all_bots_redeem(message: Message, state: FSMContext):
)
try:
accounts = await list_user_bot_accounts(message.from_user.id)
accounts = await list_user_activation_bot_accounts(message.from_user.id)
await checking.edit_text(
await redeem_all_bots_keys(keys, [account.bot_name for account in accounts])
)