Base Commands (/start, /help)
Relevant source files
The following files were used as context for generating this wiki page:
The base commands /start and /help provide the primary interface for users to verify bot operations and understand available features. These commands act as the entry point for interaction, ensuring the bot is responsive and providing guidance on how to utilize the summarization capabilities.
These commands are processed within a long-polling loop that monitors the Telegram Bot API for incoming updates. When a user sends a message beginning with these specific triggers, the bot identifies the command and returns a predefined text response to the originating chat.
Sources: bot.py:108-142, README.md:5-10
Architecture and Command Logic
The bot uses a centralized processing function, process_message, to evaluate incoming text. If a message contains the /start or /help strings at the beginning, the bot executes a corresponding response branch.
Command Processing Flow
The following diagram illustrates how the bot handles the identification and response for base commands.
The logic ensures that the bot remains responsive to basic status checks and provides documentation directly within the chat interface.
Sources: bot.py:108-124
The /start Command
The /start command serves as a health check. When triggered, the bot sends a static string confirming that it is operational and directs the user toward the help menu.
- Trigger: Text starting with
/start. - Action: Invokes
send_messagewith a hardcoded confirmation string. - Parameters: Includes the
message_idto reply directly to the user's prompt.
Sources: bot.py:116-118, README.md:7
The /help Command
The /help command provides a list of all supported bot commands and usage tips. The text for this response is generated by the help_text() function.
- Trigger: Text starting with
/help. - Action: Returns a detailed list of commands including
/summary. - Documentation: Informs users about group privacy settings required for the bot to read messages in group chats.
Sources: bot.py:94-105, bot.py:120-122, README.md:8
Implementation Details
API Interaction
Both commands rely on the telegram_api function to communicate with the sendMessage endpoint. This function handles the HTTP POST request, JSON encoding, and error checking.
| Parameter | Type | Description |
|---|---|---|
chat_id | Integer | The unique identifier for the target chat. |
text | String | The message content (truncated to 4096 characters). |
reply_to_message_id | Integer | (Optional) The ID of the message being replied to. |
Sources: bot.py:59-71
Key Functions
| Function | File | Description |
|---|---|---|
help_text() | bot.py | Returns the multi-line string containing the command list. |
process_message(message) | bot.py | Parsed the update and routes logic based on command prefixes. |
send_message(...) | bot.py | Prepares the payload for the Telegram API. |
Sources: bot.py:74-78, bot.py:94-105, bot.py:108-132
Summary of Base Functionality
The base commands /start and /help establish the foundational user experience for the Telegram Summary Bot. By providing immediate feedback and clear documentation, they allow users to verify the bot's deployment status and discover how to interact with the core summarization features. These commands are implemented using simple string prefix matching and standard Telegram API calls, ensuring high reliability with minimal external dependencies.
Sources: bot.py:1-5, README.md:12-16