A comprehensive Telegram bot built with Aiogram 3.22 for managing nutrition products, orders, and delivery services. The bot helps users with proper nutrition by providing meal recommendations and managing orders with delivery or pickup options.
- Product Browsing: Browse products by category (Weight Loss / Weight Gain)
- Shopping Basket: Add products to basket with quantity management
- Order Management: Create orders with flexible delivery options
- Delivery Options:
- π Home Delivery (with location sharing)
- π’ Branch Pickup (choose from available branches)
- Order Tracking: View order status updates in real-time
- Product Management: Full CRUD operations for products
- Add/Edit/Delete products
- Upload product images
- Set product types (weight loss/gain)
- Manage pricing and descriptions
- Branch Management: Full CRUD operations for branches
- Add/Edit/Delete branches
- Upload branch images
- Set branch locations and descriptions
- Order Notifications: Receive order notifications in a dedicated group
- Order Status Control: Update order status (Waiting/Cancelled/Delivered)
- Python 3.11+
- Aiogram 3.22 - Telegram Bot Framework
- SQLAlchemy 2.0 - ORM for database operations
- PostgreSQL - Database
- asyncio - Asynchronous programming
MassfitDenou/
βββ app/
β βββ database/
β β βββ models.py # Database models
β β βββ engine.py # Database engine configuration
β β βββ requests.py # User database operations
β β βββ product_requests.py # Product database operations
β β βββ order_requests.py # Order database operations
β β βββ branch_requests.py # Branch database operations
β βββ handlers/
β β βββ start.py # Start command and phone registration
β β βββ admin/
β β β βββ __init__.py # Admin router aggregator
β β β βββ panel.py # Admin panel navigation
β β β βββ products.py # Product CRUD operations
β β β βββ branches.py # Branch CRUD operations
β β βββ user/
β β βββ __init__.py # User router aggregator
β β βββ products.py # Product browsing
β β βββ basket.py # Basket management
β β βββ orders.py # Order creation and management
β βββ keyboards/
β β βββ reply.py # Reply keyboard layouts
β β βββ inline.py # Inline keyboard layouts
β βββ config.py # Configuration and environment variables
βββ main.py # Application entry point
βββ requirements.txt # Python dependencies
βββ .env # Environment variables (create from .env.example)
βββ .env.example # Environment variables template
βββ README.md # Project documentation
- Python 3.11 or higher
- PostgreSQL database
- Telegram Bot Token (from @BotFather)
-
Clone the repository
git clone git@github.com:avazcoderr/MassfitDenou.git cd MassfitDenou -
Create virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
cp .env.example .env # Edit .env with your actual values -
Configure PostgreSQL Database
- Create a new PostgreSQL database
- Update
DATABASE_URLin.envfile with your database credentials
-
Run the bot
python3 main.py
See .env.example for all required environment variables:
BOT_TOKEN- Your Telegram bot token from BotFatherADMIN_ID- Telegram user ID of the adminGROUP_ID- Telegram group ID for order notificationsDATABASE_URL- PostgreSQL connection string
- Telegram user information
- Phone number for contact
- Order history
- Name, price, description
- Product type (weight_loss/weight_gain)
- Product image
- Branch name and location
- Description and image
- Pickup point information
- User information
- Order items and total price
- Delivery type (pickup/delivery)
- Location or branch information
- Order status (waiting/cancelled/delivered)
- Start the bot:
/start - Share phone number: Required for order contact
- Browse products: Choose between "Lose Weight" or "Gain Weight"
- Add to basket: Select products and adjust quantities
- My Orders: View basket and confirm order
- Choose delivery method:
- Delivery: Share your location
- Pickup: Select a branch
- Confirm: Receive order confirmation
- Access admin panel:
/admin - Manage Products: Add, edit, or delete products
- Manage Branches: Add, edit, or delete pickup locations
- Monitor Orders: Receive notifications in the configured group
- Update Status: Mark orders as cancelled or delivered
- Users can choose between home delivery or branch pickup
- Delivery orders require location sharing
- Pickup orders display all available branches with details
- Real-time order notifications to admin group
- Dynamic quantity adjustment with +/- buttons
- Real-time price calculation
- Items automatically removed when quantity reaches 0
- Clean basket after order confirmation
- Intuitive inline keyboard navigation
- Step-by-step product/branch creation
- Image upload support
- Edit individual fields without recreating entries
- Pending updates cleanup on bot restart (prevents flooding)
- HTML parse mode for formatted messages
- Graceful error handling with user-friendly messages
- New Handler: Create in appropriate handler directory
- New Model: Add to
app/database/models.py - New Database Operations: Create requests file in
app/database/ - Register Router: Include in
main.pyor appropriate__init__.py
- Follow existing patterns for consistency
- Use async/await for all database operations
- Implement FSM (Finite State Machine) for multi-step processes
- Always use HTML parse mode for formatted messages
- Check if
BOT_TOKENis correct - Ensure bot is not running elsewhere
- Verify network connection
- Verify PostgreSQL is running
- Check
DATABASE_URLformat - Ensure database exists
- All messages should use HTML parse mode
- Check for unclosed HTML tags
Contributions are welcome! Please follow the existing code structure and style.
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions, please open an issue on GitHub or contact the maintainer.
Built with β€οΈ using Aiogram 3.22