π₯π₯π₯ππ₯ππ₯βοΈπ£ <--- πββ¬
A delightful Telegram bot that behaves like your real pet! Send photos to build a collection, then feed your virtual pet with emoji food to receive random photos from your gallery.
- Unique Responses: Every interaction gets a different pre-defined message, just like a real pet
- Flexible Storage: Each participant has their own photo storage that can be shared with family members
- Unpredictable: Randomly selects images to reply after feeding, keeping interactions exciting
- Asynchronous Architecture: Built with modern async/await patterns for optimal performance
- Persistent Storage: All chat history and photos stored in PostgreSQL database
- Custom Middleware System: Familiar middleware pattern similar to web frameworks
- Comprehensive Testing: Automated E2E tests running in Telegram's test environment
- Python 3.10+
- PostgreSQL 13+
- Telegram Bot Token
-
Clone the repository
git clone https://github.com/MishaVyb/bart-bot.git cd bart-bot
-
Set up virtual environment
make venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
make install
-
Configure environment
cp build.env.example build.env # Edit build.env with your configuration
-
Set up database
make database
-
Run the bot
python -m src.polling
For production deployment using Docker:
# Build and run with Docker Compose
make build_run
- Start the bot: Send
/start
to begin - Upload photos: Send any photo to build your pet's photo collection
- Feed your pet: Use the emoji food buttons (π₯π₯π₯ππ₯ππ₯βοΈπ£) to feed your virtual pet
- Get responses: Your pet will reply with random photos from your collection
- Forward messages from other users to share their photo storage
- Request permission from storage owners to join their family
- Collaborative feeding with family members
/admin_loaddata
- Load data from dump file (admin only)/count
- Check total media count in your storage
bart-bot/
βββ src/
β βββ application/ # Bot application logic
β β βββ handlers.py # Message handlers
β β βββ middlewares.py # Custom middleware
β β βββ tasks.py # Background tasks
β βββ database/ # Database models and engine
β βββ content.py # Bot content and messages
β βββ configurations.py # Configuration management
βββ tests/ # Test suite
βββ alembic/ # Database migrations
βββ data/ # Data storage
The project uses several tools to maintain code quality:
# Run all code quality checks
make ci
# Format code
black .
isort .
# Type checking
mypy .
# Linting
flake8 .
# Run tests
pytest
# Run with coverage
pytest --cov=src
# Reset database and migrations
make database
# Create new migration
alembic revision --autogenerate
# Apply migrations
alembic upgrade head
Key configuration options in build.env
:
# Bot Configuration
BOT_TOKEN=your_telegram_bot_token
ADMIN_ID=your_telegram_user_id
# Database
DATABASE_URL=postgresql://user:password@localhost/bart_bot
# Content
CONTENT_FILEPATH=bart-bot.content.yaml
# Scheduling
SEND_FEED_ME_MESSAGE_CRONS=["0 9 * * *"] # Daily at 9 AM
# Build image
docker build -t vybornyy/bart-bot .
# Run with Docker Compose
docker-compose up -d
- polling: Main bot application
- db: PostgreSQL database
The bot includes comprehensive logging and monitoring:
- Structured logging with configurable levels
- Database query monitoring
- Error tracking and reporting
- Performance metrics
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Follow the existing code style (Black, isort, flake8)
- Add tests for new features
- Update documentation as needed
- Use type hints throughout
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with python-telegram-bot
- Database powered by SQLAlchemy
- Testing with pytest
- Containerized with Docker
Made with β€οΈ for pet lovers everywhere πΎ