diff --git a/bot/handlers/bots.py b/bot/handlers/bots.py
index d324a64..b4b6aed 100644
--- a/bot/handlers/bots.py
+++ b/bot/handlers/bots.py
@@ -39,7 +39,9 @@ async def bots_handler(callback: CallbackQuery) -> None:
await callback.message.edit_text(f"Ошибка: {error}") # type: ignore[union-attr]
-@router.callback_query(lambda c: c.data and c.data.startswith("bot_"), AdminCallbackFilter())
+@router.callback_query(
+ lambda c: c.data and c.data.startswith("bot_"), AdminCallbackFilter()
+)
async def bot_selected(callback: CallbackQuery) -> None:
await stop_twofa_task(callback.message.message_id) # type: ignore[union-attr]
await callback.answer()
@@ -59,13 +61,17 @@ async def bot_selected(callback: CallbackQuery) -> None:
await callback.message.edit_text( # type: ignore[union-attr]
format_bot_ui(bot),
disable_web_page_preview=True,
- reply_markup=bot_details_keyboard(bot_name, bool(bot.get("HasMobileAuthenticator"))),
+ reply_markup=bot_details_keyboard(
+ bot_name, bool(bot.get("HasMobileAuthenticator"))
+ ),
)
except Exception as error:
await callback.message.edit_text(f"Ошибка: {error}") # type: ignore[union-attr]
-@router.callback_query(lambda c: c.data and c.data.startswith("games_"), AdminCallbackFilter())
+@router.callback_query(
+ lambda c: c.data and c.data.startswith("games_"), AdminCallbackFilter()
+)
async def games(callback: CallbackQuery) -> None:
await callback.answer()
if not callback.data:
@@ -78,7 +84,9 @@ async def games(callback: CallbackQuery) -> None:
)
-@router.callback_query(lambda c: c.data and c.data.startswith("farm|"), AdminCallbackFilter())
+@router.callback_query(
+ lambda c: c.data and c.data.startswith("farm|"), AdminCallbackFilter()
+)
async def farm_game(callback: CallbackQuery) -> None:
await callback.answer()
if not callback.data:
diff --git a/bot/handlers/inventory.py b/bot/handlers/inventory.py
index 9321a8c..fd743e5 100644
--- a/bot/handlers/inventory.py
+++ b/bot/handlers/inventory.py
@@ -8,7 +8,9 @@ from bot.ui.keyboards import back_keyboard
router = Router()
-@router.callback_query(lambda c: c.data and c.data.startswith("inventory_"), AdminCallbackFilter())
+@router.callback_query(
+ lambda c: c.data and c.data.startswith("inventory_"), AdminCallbackFilter()
+)
async def inventory_menu(callback: CallbackQuery) -> None:
await callback.answer()
bot_name = callback.data.replace("inventory_", "") # type: ignore[union-attr]
@@ -19,7 +21,9 @@ async def inventory_menu(callback: CallbackQuery) -> None:
await callback.message.edit_text(text, reply_markup=keyboard) # type: ignore[union-attr]
-@router.callback_query(lambda c: c.data and c.data.startswith("inv_cs2_"), AdminCallbackFilter())
+@router.callback_query(
+ lambda c: c.data and c.data.startswith("inv_cs2_"), AdminCallbackFilter()
+)
async def cs2_inventory(callback: CallbackQuery) -> None:
await callback.answer()
bot_name = callback.data.replace("inv_cs2_", "") # type: ignore[union-attr]
@@ -31,7 +35,9 @@ async def cs2_inventory(callback: CallbackQuery) -> None:
await callback.message.edit_text(text, reply_markup=keyboard) # type: ignore[union-attr]
-@router.callback_query(lambda c: c.data and c.data.startswith("inv_steam_"), AdminCallbackFilter())
+@router.callback_query(
+ lambda c: c.data and c.data.startswith("inv_steam_"), AdminCallbackFilter()
+)
async def steam_inventory(callback: CallbackQuery) -> None:
await callback.answer()
bot_name = callback.data.replace("inv_steam_", "") # type: ignore[union-attr]
@@ -43,12 +49,16 @@ async def steam_inventory(callback: CallbackQuery) -> None:
await callback.message.edit_text(text, reply_markup=keyboard) # type: ignore[union-attr]
-@router.callback_query(lambda c: c.data and c.data.startswith("invpage|"), AdminCallbackFilter())
+@router.callback_query(
+ lambda c: c.data and c.data.startswith("invpage|"), AdminCallbackFilter()
+)
async def inventory_page(callback: CallbackQuery) -> None:
await callback.answer()
_, inv_type, bot_name, page_value = callback.data.split("|") # type: ignore[union-attr]
app_id, context_id = (730, 2) if inv_type == "cs2" else (753, 6)
- text, keyboard = await render_inventory_page(bot_name, inv_type, app_id, context_id, int(page_value))
+ text, keyboard = await render_inventory_page(
+ bot_name, inv_type, app_id, context_id, int(page_value)
+ )
if text is None:
await callback.message.edit_text("Не удалось загрузить inventory") # type: ignore[union-attr]
return
diff --git a/bot/handlers/messages.py b/bot/handlers/messages.py
index 2cd773a..9f743fd 100644
--- a/bot/handlers/messages.py
+++ b/bot/handlers/messages.py
@@ -5,7 +5,11 @@ from aiogram.types import Message
from bot.api.asf import get_all_bots, send_command
from bot.filters import AdminFilter
-from bot.services.redeem import extract_keys, redeem_all_bots_keys, redeem_single_bot_keys
+from bot.services.redeem import (
+ extract_keys,
+ redeem_all_bots_keys,
+ redeem_single_bot_keys,
+)
from bot.state import (
bot_redeem_messages,
bot_redeem_users,
@@ -14,7 +18,11 @@ from bot.state import (
redeem_users,
)
from bot.ui.formatters import format_bot_ui, get_asf_status_text
-from bot.ui.keyboards import bot_details_keyboard, delete_message_keyboard, main_keyboard
+from bot.ui.keyboards import (
+ bot_details_keyboard,
+ delete_message_keyboard,
+ main_keyboard,
+)
router = Router()
@@ -64,7 +72,9 @@ async def handle_single_bot_redeem(message: Message) -> bool:
except Exception:
pass
try:
- await message.bot.delete_message(chat_id=message.chat.id, message_id=message.message_id)
+ await message.bot.delete_message(
+ chat_id=message.chat.id, message_id=message.message_id
+ )
except Exception:
pass
keys = extract_keys(message.text or "")
@@ -85,18 +95,24 @@ async def handle_all_bots_redeem(message: Message) -> bool:
menu_message = redeem_messages.pop(message.from_user.id, None) # type: ignore[union-attr]
if menu_message:
try:
- await menu_message.edit_text(get_asf_status_text(), reply_markup=main_keyboard())
+ await menu_message.edit_text(
+ get_asf_status_text(), reply_markup=main_keyboard()
+ )
except Exception:
pass
try:
- await message.bot.delete_message(chat_id=message.chat.id, message_id=message.message_id)
+ await message.bot.delete_message(
+ chat_id=message.chat.id, message_id=message.message_id
+ )
except Exception:
pass
keys = extract_keys(message.text or "")
if not keys:
await message.answer("Ключи не найдены")
return True
- checking = await message.answer(f"Найдено ключей: {len(keys)}\nНачинаю активацию...")
+ checking = await message.answer(
+ f"Найдено ключей: {len(keys)}\nНачинаю активацию..."
+ )
try:
await checking.edit_text(await redeem_all_bots_keys(keys))
except Exception as error:
diff --git a/bot/handlers/navigation.py b/bot/handlers/navigation.py
index b6aa1cb..7960eee 100644
--- a/bot/handlers/navigation.py
+++ b/bot/handlers/navigation.py
@@ -108,7 +108,9 @@ async def plugins_handler(callback: CallbackQuery) -> None:
else:
text = "📁 Плагины ASF:\n\n"
for plugin in plugins:
- text += f"{plugin.get('Name', '???')} ({plugin.get('Version', '???')})\n"
+ text += (
+ f"{plugin.get('Name', '???')} ({plugin.get('Version', '???')})\n"
+ )
await callback.message.edit_text(text.strip(), reply_markup=back_keyboard()) # type: ignore[union-attr]
except Exception as error:
await callback.message.edit_text(f"Ошибка: {error}") # type: ignore[union-attr]
diff --git a/bot/handlers/redeem.py b/bot/handlers/redeem.py
index 15e3a93..e75e73c 100644
--- a/bot/handlers/redeem.py
+++ b/bot/handlers/redeem.py
@@ -27,7 +27,9 @@ async def redeem_keys_menu(callback: CallbackQuery) -> None:
)
-@router.callback_query(lambda c: c.data and c.data.startswith("redeem_bot_"), AdminCallbackFilter())
+@router.callback_query(
+ lambda c: c.data and c.data.startswith("redeem_bot_"), AdminCallbackFilter()
+)
async def redeem_bot_menu(callback: CallbackQuery) -> None:
await callback.answer()
bot_name = callback.data.replace("redeem_bot_", "") # type: ignore[union-attr]
diff --git a/bot/handlers/twofa.py b/bot/handlers/twofa.py
index eb21d6d..c8361ad 100644
--- a/bot/handlers/twofa.py
+++ b/bot/handlers/twofa.py
@@ -13,7 +13,9 @@ router = Router()
@router.callback_query(
- lambda c: c.data and c.data.startswith("2fa_") and not c.data.startswith("2fa_refresh_"),
+ lambda c: c.data
+ and c.data.startswith("2fa_")
+ and not c.data.startswith("2fa_refresh_"),
AdminCallbackFilter(),
)
async def twofa_handler(callback: CallbackQuery) -> None:
@@ -52,7 +54,9 @@ async def confirm_trades(callback: CallbackQuery) -> None:
await callback.message.edit_text(f"Ошибка: {error}") # type: ignore[union-attr]
-@router.callback_query(lambda c: c.data and c.data.startswith("confirm_list_"), AdminCallbackFilter())
+@router.callback_query(
+ lambda c: c.data and c.data.startswith("confirm_list_"), AdminCallbackFilter()
+)
async def confirm_list(callback: CallbackQuery) -> None:
await stop_twofa_task(callback.message.message_id) # type: ignore[union-attr]
await callback.answer()
@@ -72,7 +76,9 @@ async def confirm_list(callback: CallbackQuery) -> None:
await callback.message.edit_text(f"Ошибка: {error}") # type: ignore[union-attr]
-@router.callback_query(lambda c: c.data and c.data.startswith("confirm_all_"), AdminCallbackFilter())
+@router.callback_query(
+ lambda c: c.data and c.data.startswith("confirm_all_"), AdminCallbackFilter()
+)
async def confirm_all(callback: CallbackQuery) -> None:
await stop_twofa_task(callback.message.message_id) # type: ignore[union-attr]
await callback.answer()
diff --git a/bot/services/bots.py b/bot/services/bots.py
index b731fc2..d3ea260 100644
--- a/bot/services/bots.py
+++ b/bot/services/bots.py
@@ -9,7 +9,9 @@ def is_bot_playing(bot_name: str) -> bool:
return False
data = response.json()
bot = data.get("Result", {}).get(bot_name, {})
- return bool(bot.get("PlayingBlocked", False)) or bool(bot.get("CurrentGamesPlayed", []))
+ return bool(bot.get("PlayingBlocked", False)) or bool(
+ bot.get("CurrentGamesPlayed", [])
+ )
def is_idle_enabled(bot_name: str, app_id: int) -> bool:
diff --git a/bot/services/inventory.py b/bot/services/inventory.py
index 122e10a..2f1bee8 100644
--- a/bot/services/inventory.py
+++ b/bot/services/inventory.py
@@ -92,7 +92,8 @@ async def render_inventory_page(
text = (
f"📦 {inv_name} Inventory {bot_name}\n"
f"📄 Страница {page + 1}/{total_pages}\n\n"
- f"{stats}\n\n"
- + "\n".join(lines)
+ f"{stats}\n\n" + "\n".join(lines)
+ )
+ return text[:4000], inventory_page_keyboard(
+ inventory_type, bot_name, page, total_pages
)
- return text[:4000], inventory_page_keyboard(inventory_type, bot_name, page, total_pages)
diff --git a/bot/services/redeem.py b/bot/services/redeem.py
index ab583ca..eae94f4 100644
--- a/bot/services/redeem.py
+++ b/bot/services/redeem.py
@@ -69,8 +69,7 @@ async def redeem_single_bot_keys(bot_name: str, keys: list[str]) -> str:
text = (
f"Результат активации для {bot_name}\n\n"
f"✅ Успешно: {success_count}\n"
- f"❌ Ошибок: {failed_count}\n\n"
- + "\n".join(results[:50])
+ f"❌ Ошибок: {failed_count}\n\n" + "\n".join(results[:50])
)
return text[:4000] + ("\n\n...обрезано" if len(text) > 4000 else "")
@@ -119,7 +118,6 @@ async def redeem_all_bots_keys(keys: list[str]) -> str:
text = (
"Результат активации\n\n"
f"✅ Успешно: {success_count}\n"
- f"❌ Ошибок: {failed_count}\n\n"
- + "\n".join(results[:50])
+ f"❌ Ошибок: {failed_count}\n\n" + "\n".join(results[:50])
)
return text[:4000] + ("\n\n...обрезано" if len(text) > 4000 else "")
diff --git a/bot/ui/keyboards.py b/bot/ui/keyboards.py
index 482018b..3a3d59f 100644
--- a/bot/ui/keyboards.py
+++ b/bot/ui/keyboards.py
@@ -66,7 +66,11 @@ def bot_details_keyboard(
[InlineKeyboardButton(text="🔐 2FA", callback_data=f"2fa_{bot_name}")]
)
keyboard.append(
- [InlineKeyboardButton(text="⌚ Накрутка часов", callback_data=f"games_{bot_name}")]
+ [
+ InlineKeyboardButton(
+ text="⌚ Накрутка часов", callback_data=f"games_{bot_name}"
+ )
+ ]
)
keyboard.append(
[
@@ -77,7 +81,11 @@ def bot_details_keyboard(
]
)
keyboard.append(
- [InlineKeyboardButton(text="📦 Инвентарь", callback_data=f"inventory_{bot_name}")]
+ [
+ InlineKeyboardButton(
+ text="📦 Инвентарь", callback_data=f"inventory_{bot_name}"
+ )
+ ]
)
keyboard.append([InlineKeyboardButton(text="🔙 Назад", callback_data="bots")])
return InlineKeyboardMarkup(inline_keyboard=keyboard)
@@ -114,7 +122,9 @@ def confirmations_keyboard(bot_name: str) -> InlineKeyboardMarkup:
)
-def confirm_action_keyboard(confirm_data: str, cancel_data: str) -> InlineKeyboardMarkup:
+def confirm_action_keyboard(
+ confirm_data: str, cancel_data: str
+) -> InlineKeyboardMarkup:
return InlineKeyboardMarkup(
inline_keyboard=[
[InlineKeyboardButton(text="Да", callback_data=confirm_data)],
@@ -188,5 +198,7 @@ def console_keyboard() -> InlineKeyboardMarkup:
def delete_message_keyboard() -> InlineKeyboardMarkup:
return InlineKeyboardMarkup(
- inline_keyboard=[[InlineKeyboardButton(text="Удалить", callback_data="delete_msg")]]
+ inline_keyboard=[
+ [InlineKeyboardButton(text="Удалить", callback_data="delete_msg")]
+ ]
)