|
7 | 7 | from botspot.components.new.llm_provider import aquery_llm_structured |
8 | 8 | from botspot.user_interactions import ask_user_choice, ask_user |
9 | 9 | from botspot.utils import send_safe, markdown_to_html |
| 10 | +from botspot.utils.admin_filter import AdminFilter |
| 11 | +from botspot.types import Visibility |
10 | 12 | from loguru import logger |
11 | 13 | from textwrap import dedent |
12 | 14 |
|
@@ -63,19 +65,13 @@ async def help_handler(message: Message, app: App): |
63 | 65 | await send_safe(message.chat.id, help_message) |
64 | 66 |
|
65 | 67 |
|
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()) |
67 | 70 | @router.message(Command("stats")) |
68 | 71 | async def stats_handler(message: Message, app: App): |
69 | 72 | """Stats command handler - shows usage statistics for all users""" |
70 | 73 | assert message.from_user is not None |
71 | 74 |
|
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 | | - |
79 | 75 | # Get user statistics |
80 | 76 | try: |
81 | 77 | stats = await app.get_user_statistics() |
|
0 commit comments