Admin levels
The bot has two admin permission levels configured via environment variables:Primary admins
- Access admin menu (
/admin) - Create and send broadcasts
- View and edit announcement messages
Secondary admins
- Send direct messages to users (
/msg) - Export user list (
/export) - View error details in error messages
Admin menu commands
/admin - Open admin menu
Opens the admin keyboard with broadcast controls:- 👁🗨 Check message - Preview current announcement
- ✏ Edit message - Create/update announcement
- 📢 Send message - Broadcast to all users
- 🔽 Hide keyboard - Minimize keyboard
👁🗨 Check message - Preview announcement
Shows a preview of the current announcement message:✏ Edit message - Create announcement
Enters edit mode to create or update the announcement:- Text messages
- Images with captions
- Videos with captions
- Formatted text (HTML/Markdown)
- Buttons and inline keyboards
📢 Send message - Broadcast to all users
Sends the announcement to all users in the database:- Rate limiting (0.04s between sends = 25 messages/second)
- Error tracking (blocked users, failed sends)
- Comprehensive statistics after completion
- Continues on individual failures
🔽 Hide keyboard - Minimize keyboard
Secondary admin commands
/msg - Send direct message to user
Send a message to a specific user/chat ID:/msg, /tell, /say, /send
/export - Export user list
Exports all user IDs to a text file:Admin filters
Commands are protected by custom filters:IsAdmin filter
ADMIN_IDS list.
IsSecondAdmin filter
SECOND_IDS list.
FSM states for announcements
The broadcast feature uses Finite State Machine for multi-step flows:- Admin clicks ”✏ Edit message”
- Bot enters
AdminMenu.addstate - Admin sends message content
- Bot stores message and returns to menu
- State cleared automatically
Cancel/Back commands
/stop, /cancel, /back, or “↩Return” button
Error visibility for admins
Secondary admins see detailed error messages:Configuration
Environment variables
Loading configuration
Best practices
Broadcast guidelines
- Preview first: Always use ”👁🗨 Check message” before broadcasting
- Rate limiting: Built-in 0.04s delay prevents Telegram rate limits
- Error tolerance: Broadcast continues even if individual sends fail
- Statistics: Review success/blocked/error counts after completion
Direct messaging
- Use for: Responding to specific user issues
- Avoid for: Mass messages (use broadcast instead)
- Handle errors: User might have blocked the bot
User export
- Privacy: Exported data contains only user IDs, no personal info
- Use cases: Analytics, migration, backup
- Format: Plain text, one ID per line
Security considerations
- Commands only work in private chats (except keyboard buttons)
- Admin IDs must be configured before deployment
- No runtime admin promotion (must restart bot)
- Filters prevent unauthorized access
- Error messages sanitized for non-admins

