A sophisticated Telegram bot designed to monitor the Digital Egypt Pioneers Initiative (DEPI) schedule API. It runs entirely on GitHub Actions, making it free and serverless, while providing real-time updates to students about their training schedules.
- Automated Monitoring: Runs every 5 minutes to check for schedule changes.
- Smart Diffs: Doesn't just say "Updated"; it tells you exactly what changed (New sessions added, sessions removed, or details updated).
- Bilingual Support: Fully localized in English and Arabic.
- Multi-User Support: Allows multiple students to subscribe to updates.
- Admin Priority: Admin receives notifications immediately. Subscribers receive them after a 10-minute delay (to allow admin verification).
- Remote Control: Admin can Stop and Start the bot directly from Telegram buttons.
- Token Management: Update the expired API token by simply pasting it into the chat. No need to open GitHub Settings!
- Self-Destruct: "Nuke Subscribers" button to clear the database if needed.
- A GitHub Account.
- A Telegram Account.
- Python 3.12+ (for local token generation).
You can view the real-time status of the bot, including the last run time, subscriber count, and latest schedule changes here: 🔗 View Status Dashboard (Note: Enable GitHub Pages in Settings > Pages > Source: "Deploy from a branch" > Branch: "main" / "root")
- A GitHub Account.
- A Telegram Account.
- Python 3.12+ (for local token generation).
- Fork or Push this repository to your own GitHub account.
- Navigate to Settings > Secrets and variables > Actions.
- Add the following Repository Secrets:
| Secret Name | Value / Description |
|---|---|
TELEGRAM_TOKEN |
Get this from @BotFather on Telegram. |
TELEGRAM_ADMIN_ID |
Your numeric Telegram ID (use @userinfobot to find it). |
DEPI_TOKEN |
The initial Bearer token (see "Getting the Token" below). |
SCHEDULE_API |
https://api.depi.gov.eg/api/Schedule/GetUserSchedules |
ENCRYPTION_KEY |
Required for Public Repos. Run python generate_key.py to get this. |
-
Install dependencies:
pip install playwright requests cryptography playwright install
-
Generate Encryption Key:
python generate_key.py
Copy the output key and add it as
ENCRYPTION_KEYin GitHub Secrets. This ensures your data is encrypted before being saved to the public repo. -
Get DEPI Token:
python get_token.py
Copy the token and add it as
DEPI_TOKENin GitHub Secrets.
- Go to Settings > Pages.
- Under Build and deployment, select Source: Deploy from a branch.
- Select Branch: main and folder /(root).
- Click Save.
/startorHello: Subscribe to updates and show the main menu.- 📅 Check Schedule / جدول المواعيد: Checks if the bot is running and when the next update is due.
- ℹ️ About Bot / عن البوت: Shows information about the bot.
Admin Commands (Hidden)
- 🛑 Stop Bot: Pauses the bot. It will still run on GitHub but will exit immediately without checking the API.
▶️ Start Bot: Resumes normal operation.- 💣 Nuke Subscribers: Deletes all subscribers from
subscribers.json(except the admin). - Paste Token: Simply paste a long token string (containing dots) into the chat to update the
DEPI_TOKENfor the next run.
The bot is stateless but persistent.
- GitHub Action triggers
depi.pyevery 5 minutes. - It loads state from
state.json(encrypted) andsubscribers.json(encrypted). - It fetches the API.
- If changes are found, it notifies the admin and queues messages for subscribers.
- It updates
status.json(unencrypted, safe data) for the dashboard. - It commits and pushes the updated files back to the repository.
When the token expires (usually after a few hours or days):
- The bot will message the Admin: "
⚠️ Token expired! Please paste the new token here..." - Run
python get_token.pyon your local machine. - Copy the new token.
- Paste it directly into the Telegram chat.
- The bot will save it to
state.jsonand use it for the next run.
depi.py: The brain of the bot. Handles logic, Telegram API, encryption, and diffing.index.html: The status dashboard.get_token.py: Local tool to bypass CloudWAF and get a valid session token.generate_key.py: Tool to generate the encryption key.state.json: Encrypted state file.subscribers.json: Encrypted subscribers list.status.json: Public status data for the dashboard..github/workflows/schedule.yml: Configuration for the 5-minute CRON timer.
- Bot not replying? GitHub Actions might be delayed. Check the "Actions" tab in your repo.
- 403/401 Errors? Your token is expired. Generate a new one and paste it in the chat.
- GitHub Action failing to push? Ensure "Workflow permissions" in Settings > Actions > General are set to "Read and write permissions".