Archived
refactor: balance handling and upload processing
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user