Scheduled Posts
Relevant source files
The following files were used as context for generating this wiki page:
Scheduled Posts is a core component of the TelePilot dashboard system that manages the automated delivery of content to Telegram channels. It allows administrators to queue various message types for future delivery, ensuring consistent engagement without manual intervention.
This system integrates with the broader management suite to provide retry logic, engagement tracking, and administrative controls such as pinning or auto-deleting messages after delivery.
Sources: README.md:143-148
System Features and Capabilities
The scheduling module supports a wide range of message types and post-delivery actions. Administrators use the MiniApp control panel to configure these settings per channel.
| Feature | Description |
|---|---|
| Multi-Media Support | Schedules photos, videos, documents, and polls. |
| Retry Logic | Automatically attempts to resend messages if delivery fails. |
| Post Actions | Supports pinning, unpinning, and auto-deletion of scheduled content. |
| Engagement Tracking | Monitors how users interact with scheduled messages. |
Sources: README.md:136-139, README.md:144-147
Architecture and Data Flow
The scheduling system operates within the TelePilot dashboard, which communicates with the Telegram Bot API. While the local bot.py handles real-time commands, the scheduling logic is managed by the PHP-based control panel backend using a MySQL database for persistence.
Logic Flow for Scheduled Content
The following diagram illustrates the lifecycle of a scheduled post from creation to execution.
The diagram shows the transition of a message from the management interface to the database and its eventual release via the API.
Sources: README.md:143-147, README.md:213-217
Component Interaction
The scheduling system relies on specific environment configurations and external dependencies defined in the project structure.
- MiniApp Panel: Provides the UI for scheduling messages across unlimited channels and groups.
- Database: Stores post content, scheduled timestamps, and target channel IDs.
- Telegram Bot API: The
bot.pyscript utilizesurllib3to communicate with Telegram's servers for message delivery.
The sequence shows the asynchronous nature of the scheduling system where the admin interaction is decoupled from the actual delivery.
Sources: README.md:213-217, bot.py:38-51
Implementation Details
The bot infrastructure uses standard HTTP requests to interact with Telegram. Scheduled posts leverage the same telegram_api method used for standard message responses.
Request Handling
The bot sends data to the Telegram API using the urllib3 library. The telegram_api function handles payload serialization and headers.
def telegram_api(method: str, payload: dict[str, Any] | None = None) -> dict[str, Any]:
response = http.request(
"POST",
f"https://api.telegram.org/bot{BOT_TOKEN}/{method}",
body=json.dumps(payload or {}).encode("utf-8"),
headers={"Content-Type": "application/json"},
timeout=urllib3.Timeout(connect=10.0, read=POLL_TIMEOUT + 10.0),
)
# ... logic for response parsing
Sources: bot.py:38-51
Administrative Roles
Access to scheduling features is restricted based on the user's role within the system.
- Super Admin: Full access to all scheduling and channel configurations.
- Admin: Can schedule posts for assigned channels.
- Moderator: Limited permissions, typically focused on oversight rather than creation.
Sources: README.md:195-197
Conclusion
Scheduled Posts provide a robust framework for automated content distribution within the Telegram ecosystem. By combining the local bot's API handling with a centralized PHP/MySQL dashboard, the system enables complex scheduling workflows, media support, and post-delivery management for professional channel operators.