A Telegram bot that tracks product prices from Flipkart and Amazon, using SQLite for data storage.
- Track product prices from Flipkart and Amazon
- Get notifications when prices change
- View price history and statistics
- Restricted access to trusted users (by ID or username)
- Price checks every hour
- Easy to deploy and maintain with SQLite
- Run the create_release.py script to generate a release zip:
python create_release.pyThis will create a zip file named pricetracker_v1_TIMESTAMP.zip containing all necessary source files.
- Extract the zip file:
unzip pricetracker_v1_*.zipgit clone <repository-url>- Install dependencies:
pip install -r requirements.txt-
Create .env file:
- Copy .env_example to .env
- Fill in your Telegram API credentials
- Add trusted users (comma-separated Telegram user IDs and usernames)
# You can use both user IDs and usernames TRUSTED_USERS=123456789,@john_doe,987654321,@jane_smith
-
The SQLite database will be automatically created when you first run the bot
- Access control by both Telegram user IDs and usernames
- Users can be trusted by either:
- Their numeric Telegram ID (e.g., 123456789)
- Their Telegram username (e.g., @username)
- Non-trusted users receive a clear message to contact the administrator
- All bot commands and features are protected by the trusted user filter
- Usernames are case-insensitive for better usability
/start- Start the bot and get welcome message/help- View available commands and usage/my_trackings- View all products you're tracking/product <id>- Get detailed information about a product/stop <id>- Stop tracking a product
The bot uses SQLite with the following tables:
- Stores global product information
- Tracks current, previous, and historical prices
- Maintains price bounds (upper/lower)
- Maps users to their tracked products
- Stores Telegram chat IDs for notifications
- Ensures unique user-product combinations
- Stores user information
- Tracks user activity and preferences
- Manages notification settings
The bot checks prices every hour and will notify trusted users of any changes. Price history is maintained in the SQLite database, allowing for historical price analysis.
pricetracker/
├── main.py # Main bot file
├── database.py # SQLite database operations
├── helpers.py # Helper functions
├── scheduler.py # Price check scheduler
├── scraper.py # Web scraping functionality
├── regex_patterns.py # URL patterns
├── requirements.txt # Dependencies
├── .env_example # Environment variables template
└── create_release.py # Script to create release zip
main.py: Main bot logic and command handlersdatabase.py: SQLite database managementhelpers.py: Helper functions for bot operationsscheduler.py: Price checking schedulerscraper.py: Web scraping functionsregex_patterns.py: URL validation patternscreate_release.py: Creates a zip file containing all source code.env_example: Template for configuration
To create a zip file containing all necessary source code:
- Run create_release.py:
python create_release.py- The script will:
- Create a timestamped zip file
- Include all necessary source files
- Exclude unnecessary files (.env, pycache, etc.)
- Print a list of included files
The generated zip file can be easily shared and deployed on other systems.
- All database operations include proper error handling
- Failed operations are logged for debugging
- Users are notified of any issues through the bot
Main dependencies:
- pyrogram - Telegram bot framework
- aiosqlite - Async SQLite support
- schedule - Task scheduling
- beautifulsoup4 - Web scraping
- python-dotenv - Environment configuration
See requirements.txt for complete list.
Feel free to open issues or submit pull requests for any improvements.