A Telegram bot for managing charitable donations with Persian language support and Jalali calendar integration.
- User Authentication: PIN-based user verification using seed data from CSV
- Donation Management: Track and manage monthly donations
- Payment Tracking: Monitor payment status (pending, approved, failed)
- Automatic Notifications:
- 3rd of each Jalali month: Donation payment reminders
- 7th of each Jalali month: Follow-up reminders for unpaid donations
- 10th of each Jalali month: Monthly reports in Excel and PDF format
- Admin Approval: Payment image verification workflow
- Jalali Calendar Support: Full Persian calendar integration with Asia/Tehran timezone
- Type Hints: Full type hinting throughout the codebase using Python 3.11+
- Data Validation: Pydantic models for all data structures
aharar-bot/
├── main.py # Main bot application
├── config.py # Configuration and constants
├── database.py # SQLite database management
├── models.py # Pydantic data models
├── handlers.py # User interaction handlers
├── scheduler.py # Scheduled tasks for notifications
├── utils.py # Utility functions (Jalali calendar, formatting)
├── requirements.txt # Python dependencies
├── Dockerfile # Docker container setup
├── docker-compose.yml # Docker Compose configuration
├── .env.example # Environment variables template
├── data/ # Seed data directory
│ └── seed_data.csv # User data with PIN codes
├── messages.md # Message templates
└── payments/ # Uploaded payment images
- Python 3.11+: Core language with type hints
- python-telegram-bot 20.7: Telegram bot framework
- SQLite3: Lightweight database
- Pydantic 2.5: Data validation and serialization
- pytz: Timezone management
- openpyxl: Excel report generation
- reportlab: PDF report generation
- Docker & Docker Compose: Containerization
- Docker and Docker Compose (recommended)
- OR Python 3.11+ and pip
- Clone the repository and navigate to the project directory:
cd aharar-bot- Create
.envfile from template:
cp .env.example .env- Edit
.envand add your bot token and admin chat ID:
BOT_TOKEN=your_telegram_bot_token
ADMIN_CHAT_ID=your_admin_chat_id- Start the bot with Docker Compose:
docker-compose up -d- Access SQLite web viewer at
http://localhost:8080
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create
.envfile:
cp .env.example .env-
Edit
.envwith your bot token and admin chat ID -
Run the bot:
python main.py/start- Start the bot and verify with PIN code/کارت- Show donation card number/لینک- Get donation payment link/مبلغ- Show your donation amount/آپلود- Upload payment receipt image/سابقه- View payment history/گزارش- Get latest charity report
- Receive payment notifications and images
- Approve or deny payments with inline buttons
- Receive monthly reports (Excel and PDF)
- Verification: User starts bot → Enters PIN code → Confirms identity
- Main Menu: Access donation information, upload payments, view history
- Payment Upload: User uploads payment receipt → Admin reviews → User notified of approval/denial
- Automated Notifications:
- Day 3: Monthly donation reminders sent to all users
- Day 7: Follow-up reminders for unpaid donations
- Day 10: Monthly summary reports sent to admin
id: Unique identifierpin_code: User's PIN for verificationfull_name: User's full nametelegram_id: Telegram user ID (added after verification)donation_amount: Monthly donation amountdonation_link: Payment linkstatus: Account status (unverified, verified, pending_admin)created_at,updated_at: Timestamps
id: Unique identifieruser_id: Reference to userjalali_month: Jalali calendar monthjalali_year: Jalali calendar yearstatus: Payment status (pending, approved, failed)image_path: Path to payment receipt imagecreated_at,updated_at: Timestamps
id: Unique identifieruser_id: Reference to userstatus: Approval statuscreated_at: Timestamp
Edit config.py to customize:
- Bot behavior
- Notification timing
- Jalali calendar month names
- Payment status constants
- User status constants
Create a .env file with:
BOT_TOKEN=your_telegram_bot_token_here
ADMIN_CHAT_ID=your_admin_chat_id_here
DATABASE_PATH=aharar_bot.db
SEED_DATA_PATH=./data/seed_data.csv
TIMEZONE=Asia/Tehran- Add handlers in
handlers.py - Add database methods in
database.py - Add data models in
models.py - Update main.py to register handlers
- Use type hints throughout
- Access SQLite web viewer at
http://localhost:8080(when using Docker) - Seed data is automatically imported from
data/seed_data.csvon first run
- Excel and PDF reports are generated automatically on the 10th of each month
- Reports include all users and their payment status
- Check
BOT_TOKENin.envis correct - Verify bot has proper permissions in Telegram
- Check logs:
docker logs aharar_bot
- Verify
TIMEZONEis set toAsia/Tehran - Check admin user IDs are saved in database
- Review
scheduler.pynotification settings
- Ensure
/paymentsdirectory exists - Check file permissions in Docker volume
- Verify ADMIN_CHAT_ID is correct
This project is created for Aharar Charity.
For technical issues or feature requests, contact the development team.