A Python-based Telegram bot that sends automated reminders in telegram to friends on the 23rd of every month at 9 AM to remind them of paying for that one family subscription service we purchased as a group. The bot uses apscheduler for scheduling
- Sends scheduled reminders with a QR code attachment.
- Dynamically loads recipients from a JSON file.
- Configurable scheduling using apscheduler.
- Logging with color-coded outputs for better readability.
telegram-payment-bot/
βββ bot/
β βββ __init__.py # Marks the directory as a Python package
β βββ main.py # Main entry point for the bot
β βββ scheduler.py # Scheduler logic for reminders
β βββ utils.py # Helper functions (e.g., loading recipients)
β βββ logger.py # Logging configuration
βββ data/
β βββ payment_qr.png # QR code image to attach to reminders
β βββ receivers.json # JSON file containing recipient data
β βββ receivers.example.json # Example JSON file
βββ tests/
β βββ test_scheduler.py # Tests for scheduling logic
βββ .env # Environment variables file
βββ .gitignore # Ignored files and directories
βββ requirements.txt # Python dependencies
βββ README.md # Documentation file
Python 3.8 or higher Telegram bot token (create a bot via BotFather)
a. Clone the repository:
git clone https://github.com/your-username/telegram-reminder-bot.git
cd telegram-reminder-bot
b. Create a Python virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
c. Install dependencies:
pip install -r requirements.txt
d. Set up the .env file: Create a .env file in the root directory and add:
TELEGRAM_TOKEN=<YOUR_TELEGRAM_BOT_TOKEN>
e. Update recipients.json: Add recipient chat IDs in data/recipients.json:
{
"@username1": "123456789",
"@username2": "987654321"
}
Start the bot:
python -m bot.main
The bot will send reminders to all recipients on the 23rd of every month at 9 AM. The reminder includes a predefined message and the attached QR code.