Skip to content

Commit 72c9ee2

Browse files
committed
(feat) improve number of bots in active btos command
1 parent aeb7b39 commit 72c9ee2

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

β€Žhandlers/bots/menu.pyβ€Ž

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,28 @@ def _build_main_menu_keyboard(bots_dict: Dict[str, Any]) -> InlineKeyboardMarkup
3737
"""
3838
keyboard = []
3939

40-
# Add a button for each bot (max 5)
41-
for bot_name in list(bots_dict.keys())[:5]:
42-
# Truncate name for button
43-
display_name = bot_name[:30] + "..." if len(bot_name) > 30 else bot_name
44-
keyboard.append([
45-
InlineKeyboardButton(f"πŸ“Š {display_name}", callback_data=f"bots:bot_detail:{bot_name}")
46-
])
40+
# Add a button for each bot (show all bots)
41+
# Group bots in rows of 2 for better layout when there are many bots
42+
bot_names = list(bots_dict.keys())
43+
44+
# For 1-3 bots: one per row
45+
# For 4+ bots: two per row for better space utilization
46+
if len(bot_names) <= 3:
47+
for bot_name in bot_names:
48+
display_name = bot_name[:30] + "..." if len(bot_name) > 30 else bot_name
49+
keyboard.append([
50+
InlineKeyboardButton(f"πŸ“Š {display_name}", callback_data=f"bots:bot_detail:{bot_name}")
51+
])
52+
else:
53+
# Two bots per row for better space utilization
54+
for i in range(0, len(bot_names), 2):
55+
row = []
56+
for j in range(i, min(i + 2, len(bot_names))):
57+
bot_name = bot_names[j]
58+
# Shorter display name when two per row
59+
display_name = bot_name[:25] + "..." if len(bot_name) > 25 else bot_name
60+
row.append(InlineKeyboardButton(f"πŸ“Š {display_name}", callback_data=f"bots:bot_detail:{bot_name}"))
61+
keyboard.append(row)
4762

4863
# Action buttons - historical
4964
keyboard.append([

β€Žutils/telegram_formatters.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def format_active_bots(
448448
message += f"{'Controller':<28} {'PnL':>8} {'Vol':>7}\n"
449449
message += f"{'─'*28} {'─'*8} {'─'*7}\n"
450450

451-
for idx, (ctrl_name, ctrl_info) in enumerate(list(performance.items())[:6]):
451+
for idx, (ctrl_name, ctrl_info) in enumerate(list(performance.items())):
452452
if isinstance(ctrl_info, dict):
453453
ctrl_status = ctrl_info.get("status", "running")
454454
ctrl_perf = ctrl_info.get("performance", {})

0 commit comments

Comments
Β (0)