Skip to content

Commit 1795d5c

Browse files
cursoragentcalmmage
andcommitted
Implement admin-only stats command with AdminFilter and Visibility
Co-authored-by: petr.b.lavrov <petr.b.lavrov@gmail.com>
1 parent 154bf6c commit 1795d5c

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/router.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from botspot.components.new.llm_provider import aquery_llm_structured
88
from botspot.user_interactions import ask_user_choice, ask_user
99
from botspot.utils import send_safe, markdown_to_html
10+
from botspot.utils.admin_filter import AdminFilter
11+
from botspot.types import Visibility
1012
from loguru import logger
1113
from textwrap import dedent
1214

@@ -63,19 +65,13 @@ async def help_handler(message: Message, app: App):
6365
await send_safe(message.chat.id, help_message)
6466

6567

66-
@commands_menu.botspot_command("stats", "Show usage statistics (admin only)")
68+
@commands_menu.botspot_command("stats", "Show usage statistics (admin only)", visibility=Visibility.ADMIN_ONLY)
69+
@router.message(AdminFilter())
6770
@router.message(Command("stats"))
6871
async def stats_handler(message: Message, app: App):
6972
"""Stats command handler - shows usage statistics for all users"""
7073
assert message.from_user is not None
7174

72-
# TODO: Implement proper admin checking
73-
# For now, you can add admin user IDs to check against
74-
# admin_user_ids = [123456789, 987654321] # Replace with actual admin user IDs
75-
# if message.from_user.id not in admin_user_ids:
76-
# await send_safe(message.chat.id, "❌ This command is only available to administrators.")
77-
# return
78-
7975
# Get user statistics
8076
try:
8177
stats = await app.get_user_statistics()

0 commit comments

Comments
 (0)