Custom Commands & Placeholders
Relevant source files
The following files were used as context for generating this wiki page:
The Telegram Summary Bot provides a framework for handling both built-in and user-defined interactions within Telegram chats. The system enables automated message processing through commands and enhances message personalization using dynamic placeholders.
This module allows administrators to manage channel and group interactions by creating custom responses and automating welcome or moderation tasks. It bridges the gap between raw message data and structured, context-aware bot responses.
Sources: README.md:118-124, bot.py:102-126
Command Architecture
The bot processes commands by evaluating incoming message text for specific prefixes. The process_message function identifies commands and routes them to the appropriate logic or summary generation.
Command Processing Flow
The following diagram illustrates how the bot handles an incoming message to determine if it is a command or standard text.
The flow shows the branching logic for standard messages versus command execution.
Sources: bot.py:102-126
Built-in Commands
| Command | Action | Description |
|---|---|---|
/start | Health Check | Validates the bot is active and responding. |
/help | Information | Displays a list of available commands and usage tips. |
/summary | Summarization | Summarizes the last MAX_STORED_MESSAGES in the chat. |
/summary <text> | Input Summarization | Summarizes the specific text provided after the command. |
Sources: bot.py:108-124, README.md:9-12
Custom Commands
The system supports the creation of unlimited custom bot responses to extend functionality beyond the default summarization tools. These are managed via the TelePilot dashboard.
- Admin-only Commands: Restricts execution to authorized users.
- Usage Statistics: Tracks how often specific commands are triggered.
- Multi-lingual Support: Custom responses can be localized into 15 built-in languages.
Sources: README.md:118-120, README.md:162-164
Dynamic Placeholders
Placeholders allow for dynamic content injection into bot responses, welcome messages, and broadcast campaigns. The system replaces these tags with real-time metadata from the Telegram context.
Supported Placeholders
| Placeholder | Context | Description |
|---|---|---|
{name} | User | The first name or full name of the Telegram user. |
{username} | User | The @username of the Telegram user. |
{channel} | Chat | The title of the channel or group where the message is sent. |
Sources: README.md:120, README.md:124
Placeholder Implementation in Auto-Messages
The bot uses placeholders in two primary automated message types:
- Welcome Messages: Greets new members using
{name}and{channel}info. - Goodbye Messages: Sends a customized farewell when a member leaves.
# Example of how placeholders are structured in system prompts
welcome_template = "Welcome {name} to {channel}!"
Sources: README.md:122-125
Summarization Logic
The /summary command utilizes a local extractive summarizer. It extracts specific sentences based on the SUMMARY_SENTENCES configuration.
The sequence shows the interaction between the command handler and the text processing logic.
Sources: bot.py:75-90, bot.py:118-124
Summarization Configuration
Users can control the behavior of the summarizer through environment variables:
MAX_STORED_MESSAGES: Limits the history size used for the summary (default 100).SUMMARY_SENTENCES: Determines the length of the generated summary (default 5).
Sources: bot.py:22-23, README.md:38-39
Conclusion
Custom commands and placeholders provide the flexibility required to manage complex Telegram communities. By combining local summarization with dynamic data injection, the bot automates engagement while maintaining administrative control over the chat environment.