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
+20 -1
View File
@@ -17,6 +17,25 @@ async def list_user_bot_accounts(telegram_id: int) -> list[BotAccount]:
return list(result.scalars())
async def list_user_activation_bot_accounts(telegram_id: int) -> list[BotAccount]:
"""Возвращает личных ботов, доступных для активации ключей пользователем.
Боты, импортированные из ASF для совместимости с панелью администратора,
являются системными, а не загруженными администратором лично.
"""
async with async_session() as session:
result = await session.execute(
select(BotAccount)
.join(User)
.where(
User.telegram_id == telegram_id,
BotAccount.source_filename != "existing-asf",
)
.order_by(BotAccount.bot_name)
)
return list(result.scalars())
async def get_owned_bot(telegram_id: int, account_id: int) -> BotAccount | None:
async with async_session() as session:
result = await session.execute(
@@ -67,7 +86,7 @@ async def user_hash_exists(telegram_id: int, config_sha256: str) -> bool:
async def ensure_admin_compatibility(bot_names: list[str]) -> None:
"""Keep ASF bots created before ownership was introduced visible to the admin."""
"""Показывает администратору ботов ASF, созданных до добавления владельцев."""
for bot_name in bot_names:
if await bot_name_exists(bot_name):
continue