A Python-based Telegram year progress bot, rewritten from RedL0tus/YearProgressBot.
The prime of life never returns, one morning is hard to come again. Seize the day and encourage yourself, time and tide wait for no man. — Tao Yuanming
- 📊 Display current year progress percentage
- ⏰ Send daily progress updates at a fixed time
- 🔄 Auto-detect progress changes and only push when the progress bar changes to avoid spamming
- 📱 Broadcast to multiple chat IDs
- 🌍 Custom timezone support (e.g.
Asia/Shanghai) - 📏 Configurable progress bar length
The project requires Python 3.11 or higher.
Install dependencies with pip:
pip install -r requirements.txtOr, using uv to install dependencies:
uv syncCreate a .env file in the project root and configure the following environment variables:
TELEGRAM_TOKEN=Your Telegram bot token (required)
TELEGRAM_CHAT_ID=Your chat ID (multiple IDs separated by commas, optional)
TELEGRAM_ADMIN_ID=User ID that can use admin commands (optional, recommended)
TZ=Timezone (optional, e.g. Asia/Shanghai)
SCHEDULE_TIME=Scheduled sending time (optional, format HH:MM, 24-hour)
PROGRESS_BAR_LENGTH=Progress bar length (optional, default 20)Notes:
- If
TELEGRAM_CHAT_IDis not set, the bot will not auto-push messages and you can only query progress interactively. - If
TZis not set or is invalid, the bot falls back to the system local timezone. - If
SCHEDULE_TIMEis not set or invalid, the bot automatically switches to “auto-detection mode” based on progress changes.
In the project root, run:
python -m ypbAfter startup, the bot will:
- Periodically check or send year progress based on your configuration
- Continuously poll Telegram updates and respond to commands
-
/status
Show the current time and year progress, and indicate how the next automatic send will be triggered:- If
SCHEDULE_TIMEis configured, it shows the next fixed send time - Otherwise, it shows “send when progress increases by 1%”
- If
-
/test
Test whether message sending works:- If
TELEGRAM_ADMIN_IDis configured, only that user can use this command - Unauthorized users will receive a “not authorized” message
- If
When a valid SCHEDULE_TIME (for example 09:00) is set, the bot will:
- Send one year progress message (with two decimal places) every day at the specified time
- Use the configured
TZfor time calculation; if not set, the system local timezone is used
When SCHEDULE_TIME is not set or is invalid, the bot switches to auto-detection mode:
- It checks the current year progress at a fixed interval (default every 5 seconds)
- A message is only sent when the textual progress bar differs from the last one
- This effectively avoids sending duplicate messages in a short period
- Well, I haven't tested it; please report any issues.
- Use
pytelegrambotapito interact with the Telegram Bot API - Use
apschedulerto manage scheduled jobs (interval-based and daily cron triggers) - Use
python-dotenvfor environment variable management - Use
pytzfor timezone handling - Use
aiohttpas the underlying HTTP client (required by async pytelegrambotapi)
- 🔄 Rewritten from a Bash script into a Python implementation
- 🧠 Local cache to only push when the progress bar changes, reducing noise
- 🛡️ Additional configuration validation and logging for better robustness
- 🔧 Support for multiple chat IDs, configurable progress bar length, and custom timezones
This project is a Python rewrite of RedL0tus/YearProgressBot, which is licensed under WTFNMFPLv1.
The code in this repository is licensed under the GNU General Public License v3.0 (GPL-3.0).
Issues and Pull Requests are welcome!