feat(bot): add bot account ownership and balance

This commit is contained in:
2026-07-24 10:44:48 +05:00
parent 87385228ea
commit 8bd5c80693
22 changed files with 1008 additions and 393 deletions
+6 -6
View File
@@ -7,7 +7,7 @@ from bot.ui.keyboards import inventory_menu_keyboard, inventory_page_keyboard
logger = get_logger(__name__)
async def build_inventory_menu(bot_name: str) -> tuple[str, object]:
async def build_inventory_menu(bot_name: str, account_id: int) -> tuple[str, object]:
logger.info("Формирование меню инвентаря: bot=%s", bot_name)
cs2_inventory = await get_bot_inventory(bot_name, 730, 2)
steam_inventory = await get_bot_inventory(bot_name, 753, 6)
@@ -25,7 +25,7 @@ async def build_inventory_menu(bot_name: str) -> tuple[str, object]:
logger.info("Инвентарь пуст: bot=%s", bot_name)
return (
f"📦 Инвентарь {bot_name} пуст",
inventory_menu_keyboard(bot_name, 0, 0),
inventory_menu_keyboard(account_id, 0, 0),
)
logger.info(
"Меню инвентаря сформировано: bot=%s cs2_items=%s steam_items=%s",
@@ -40,11 +40,11 @@ async def build_inventory_menu(bot_name: str) -> tuple[str, object]:
"🔒 — нельзя продавать\n"
"❌ — нельзя трейдить"
)
return text, inventory_menu_keyboard(bot_name, len(cs2_assets), len(steam_assets))
return text, inventory_menu_keyboard(account_id, len(cs2_assets), len(steam_assets))
async def render_inventory_page(
bot_name: str, inventory_type: str, appid: int, contextid: int, page: int
bot_name: str, inventory_type: str, appid: int, contextid: int, page: int, account_id: int
) -> tuple[str, object] | tuple[None, None]:
logger.info(
"Формирование страницы инвентаря: bot=%s type=%s appid=%s contextid=%s page=%s",
@@ -70,7 +70,7 @@ async def render_inventory_page(
logger.info(
"Инвентарь выбранного типа пуст: bot=%s type=%s", bot_name, inventory_type
)
return f"Инвентарь {bot_name} пуст", inventory_menu_keyboard(bot_name, 0, 0)
return f"Инвентарь {bot_name} пуст", inventory_menu_keyboard(account_id, 0, 0)
desc_map = {}
for desc in descriptions:
key = (str(desc.get("classid")), str(desc.get("instanceid")))
@@ -139,5 +139,5 @@ async def render_inventory_page(
)
return text[:4000], inventory_page_keyboard(
inventory_type, bot_name, page, total_pages
inventory_type, account_id, page, total_pages
)