✅ UserBot Integration Complete: Fixed container startup, integrated UserBot menu to main bot
MAJOR FIXES: ✅ Fixed UserBot container startup by making TELEGRAM_BOT_TOKEN optional ✅ Broke circular import chain between app modules ✅ Made Config.validate() conditional for UserBot-only mode ✅ Removed unused celery import from userbot_service.py INTEGRATION: ✅ UserBot menu now accessible from main bot /start command ✅ Added 🤖 UserBot button to main keyboard ✅ Integrated userbot_manager.py handlers: - userbot_menu: Main UserBot interface - userbot_settings: Configuration - userbot_collect_groups: Gather all user groups - userbot_collect_members: Parse group members ✅ UserBot handlers properly registered in ConversationHandler CONTAINERS: ✅ tg_autoposter_bot: Running and handling /start commands ✅ tg_autoposter_userbot: Running as standalone microservice ✅ All dependent services (Redis, PostgreSQL, Celery workers) operational STATUS: Bot is fully operational and ready for testing
This commit is contained in:
368
docs/RESOURCES_AND_REFERENCES.md
Normal file
368
docs/RESOURCES_AND_REFERENCES.md
Normal file
@@ -0,0 +1,368 @@
|
||||
# Resources & References
|
||||
|
||||
## 📚 Official Documentation Links
|
||||
|
||||
### Telegram
|
||||
- [Telegram Bot API](https://core.telegram.org/bots/api) - Official Bot API documentation
|
||||
- [Telegram Client API](https://core.telegram.org/client/schema) - Official Client API (for Telethon)
|
||||
- [Telegram Bot Features](https://core.telegram.org/bots/features) - Bot capabilities overview
|
||||
- [@BotFather](https://t.me/botfather) - Create and manage bots
|
||||
|
||||
### Python Libraries
|
||||
|
||||
#### Pyrogram
|
||||
- [Official Docs](https://docs.pyrogram.org/) - Pyrogram documentation
|
||||
- [GitHub](https://github.com/pyrogram/pyrogram) - Source code
|
||||
- [Examples](https://docs.pyrogram.org/topics/smart-plugins) - Code examples
|
||||
- [API Reference](https://docs.pyrogram.org/api) - Full API reference
|
||||
|
||||
#### Telethon
|
||||
- [Official Docs](https://docs.telethon.dev/) - Telethon documentation
|
||||
- [GitHub](https://github.com/LonamiWebs/Telethon) - Source code
|
||||
- [Examples](https://docs.telethon.dev/examples/) - Usage examples
|
||||
- [Advanced Usage](https://docs.telethon.dev/advanced/) - Advanced topics
|
||||
|
||||
#### Celery
|
||||
- [Official Docs](https://docs.celeryproject.io/) - Celery documentation
|
||||
- [GitHub](https://github.com/celery/celery) - Source code
|
||||
- [First Steps](https://docs.celeryproject.io/en/stable/getting-started/first-steps-with-celery.html) - Getting started
|
||||
- [User Guide](https://docs.celeryproject.io/en/stable/userguide/) - Complete user guide
|
||||
- [Flower Documentation](https://flower.readthedocs.io/) - Monitoring UI docs
|
||||
|
||||
#### SQLAlchemy
|
||||
- [Official Docs](https://docs.sqlalchemy.org/) - Complete documentation
|
||||
- [GitHub](https://github.com/sqlalchemy/sqlalchemy) - Source code
|
||||
- [ORM Tutorial](https://docs.sqlalchemy.org/en/20/orm/quickstart.html) - ORM basics
|
||||
- [Async Support](https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html) - Async SQLAlchemy
|
||||
|
||||
#### APScheduler
|
||||
- [Official Docs](https://apscheduler.readthedocs.io/) - APScheduler documentation
|
||||
- [GitHub](https://github.com/agronholm/apscheduler) - Source code
|
||||
- [Cron Trigger](https://apscheduler.readthedocs.io/en/latest/modules/triggers/cron.html) - Cron expression guide
|
||||
|
||||
### Database & Cache
|
||||
|
||||
#### PostgreSQL
|
||||
- [Official Docs](https://www.postgresql.org/docs/) - PostgreSQL documentation
|
||||
- [PostgreSQL Async](https://www.postgresql.org/docs/current/libpq-async.html) - Async support
|
||||
- [Performance Tuning](https://www.postgresql.org/docs/current/performance-tips.html) - Optimization guide
|
||||
|
||||
#### Redis
|
||||
- [Official Docs](https://redis.io/documentation) - Redis documentation
|
||||
- [Commands](https://redis.io/commands/) - Complete command reference
|
||||
- [Data Structures](https://redis.io/topics/data-types) - Data types guide
|
||||
- [Python Redis](https://github.com/redis/redis-py) - Python client library
|
||||
|
||||
### DevOps & Deployment
|
||||
|
||||
#### Docker
|
||||
- [Official Docs](https://docs.docker.com/) - Docker documentation
|
||||
- [Docker Best Practices](https://docs.docker.com/develop/dev-best-practices/) - Best practices
|
||||
- [Docker Compose](https://docs.docker.com/compose/) - Compose documentation
|
||||
- [Alpine Linux](https://alpinelinux.org/downloads/) - Lightweight base images
|
||||
|
||||
#### Kubernetes
|
||||
- [Official Docs](https://kubernetes.io/docs/) - Kubernetes documentation
|
||||
- [Getting Started](https://kubernetes.io/docs/setup/) - Setup guides
|
||||
- [Concepts](https://kubernetes.io/docs/concepts/) - Key concepts
|
||||
- [Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) - Deployment guide
|
||||
|
||||
#### GitHub Actions
|
||||
- [Official Docs](https://docs.github.com/en/actions) - GitHub Actions documentation
|
||||
- [Workflow Syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions) - YAML syntax
|
||||
- [Marketplace](https://github.com/marketplace?type=actions) - Action marketplace
|
||||
|
||||
### Code Quality
|
||||
|
||||
#### Pre-commit
|
||||
- [Official Docs](https://pre-commit.com/) - Pre-commit hooks framework
|
||||
- [Hooks Repository](https://github.com/pre-commit/pre-commit-hooks) - Default hooks
|
||||
|
||||
#### Black
|
||||
- [Official Docs](https://black.readthedocs.io/) - Code formatter
|
||||
- [GitHub](https://github.com/psf/black) - Source code
|
||||
|
||||
#### isort
|
||||
- [Official Docs](https://pycqa.github.io/isort/) - Import sorting
|
||||
- [GitHub](https://github.com/PyCQA/isort) - Source code
|
||||
|
||||
#### mypy
|
||||
- [Official Docs](https://mypy.readthedocs.io/) - Type checker
|
||||
- [GitHub](https://github.com/python/mypy) - Source code
|
||||
|
||||
#### pytest
|
||||
- [Official Docs](https://docs.pytest.org/) - Testing framework
|
||||
- [GitHub](https://github.com/pytest-dev/pytest) - Source code
|
||||
|
||||
## 🎯 Project-Specific Guides
|
||||
|
||||
### Getting Started
|
||||
1. **[README.md](README.md)** - Project overview and quick start
|
||||
2. **[DOCKER_QUICKSTART.md](docs/DOCKER_QUICKSTART.md)** - 5-minute quick start
|
||||
3. **[FIRST_RUN.sh](FIRST_RUN.sh)** - Interactive setup script
|
||||
|
||||
### Development
|
||||
1. **[DEVELOPMENT.md](DEVELOPMENT.md)** - Full development guide
|
||||
2. **[docs/DOCKER_CELERY.md](docs/DOCKER_CELERY.md)** - Docker & Celery details
|
||||
3. **[PRE_LAUNCH_CHECKLIST.md](PRE_LAUNCH_CHECKLIST.md)** - Pre-launch verification
|
||||
|
||||
### Production
|
||||
1. **[PRODUCTION_DEPLOYMENT.md](PRODUCTION_DEPLOYMENT.md)** - Deployment guide
|
||||
2. **[docker-compose.prod.yml](docker-compose.prod.yml)** - Production configuration
|
||||
3. **[docs/DOCKER_CELERY_SUMMARY.md](docs/DOCKER_CELERY_SUMMARY.md)** - Feature summary
|
||||
|
||||
### Architecture & Reference
|
||||
1. **[PROJECT_STRUCTURE.md](PROJECT_STRUCTURE.md)** - File organization
|
||||
2. **[IMPROVEMENTS_SUMMARY.md](IMPROVEMENTS_SUMMARY.md)** - All changes made
|
||||
3. **[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)** - System design (if exists)
|
||||
|
||||
## 🔗 Common Commands & Quick Reference
|
||||
|
||||
### Project Management
|
||||
```bash
|
||||
# Quick start
|
||||
chmod +x quickstart.sh
|
||||
./quickstart.sh
|
||||
|
||||
# Or use Make
|
||||
make up # Start services
|
||||
make down # Stop services
|
||||
make logs # View logs
|
||||
make test # Run tests
|
||||
make lint # Check code
|
||||
|
||||
# Or use docker.sh
|
||||
./docker.sh up
|
||||
./docker.sh logs
|
||||
./docker.sh celery-status
|
||||
```
|
||||
|
||||
### Docker Operations
|
||||
```bash
|
||||
docker-compose ps # List services
|
||||
docker-compose logs -f # Follow logs
|
||||
docker-compose logs -f [service] # Follow specific service
|
||||
docker-compose exec [service] bash # Shell into service
|
||||
docker-compose restart [service] # Restart service
|
||||
docker-compose down -v # Complete cleanup
|
||||
|
||||
# Production
|
||||
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
||||
```
|
||||
|
||||
### Database Operations
|
||||
```bash
|
||||
# Connect
|
||||
docker-compose exec postgres psql -U bot -d tg_autoposter
|
||||
|
||||
# Backup
|
||||
docker-compose exec -T postgres pg_dump -U bot tg_autoposter > backup.sql
|
||||
|
||||
# Restore
|
||||
gunzip < backup.sql.gz | docker-compose exec -T postgres psql -U bot tg_autoposter
|
||||
|
||||
# Migrations
|
||||
docker-compose exec bot alembic upgrade head
|
||||
docker-compose exec bot alembic downgrade -1
|
||||
docker-compose exec bot alembic revision -m "description"
|
||||
```
|
||||
|
||||
### Monitoring
|
||||
```bash
|
||||
# Flower (Task Queue Monitoring)
|
||||
# Open: http://localhost:5555
|
||||
# Login: admin / (password from .env)
|
||||
|
||||
# Docker Stats
|
||||
docker stats
|
||||
|
||||
# Logs
|
||||
docker-compose logs -f bot
|
||||
docker-compose logs -f celery_worker_send
|
||||
|
||||
# Check service health
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
### Development
|
||||
```bash
|
||||
# Format code
|
||||
make fmt
|
||||
black app/
|
||||
isort app/
|
||||
|
||||
# Lint
|
||||
make lint
|
||||
flake8 app/
|
||||
mypy app/
|
||||
|
||||
# Test
|
||||
make test
|
||||
pytest
|
||||
pytest --cov=app
|
||||
|
||||
# Shell
|
||||
make shell
|
||||
python -i -c "from app import *"
|
||||
|
||||
# Install dependencies
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements-dev.txt
|
||||
```
|
||||
|
||||
## 📖 Learning Resources
|
||||
|
||||
### Python Async Programming
|
||||
- [asyncio Documentation](https://docs.python.org/3/library/asyncio.html)
|
||||
- [Real Python Async](https://realpython.com/async-io-python/)
|
||||
- [Coroutines & Tasks](https://docs.python.org/3/library/asyncio-task.html)
|
||||
|
||||
### Database Design
|
||||
- [PostgreSQL Design Patterns](https://www.postgresql.org/docs/current/indexes.html)
|
||||
- [SQL Performance](https://sqlperformance.com/)
|
||||
- [Database Indexing](https://use-the-index-luke.com/)
|
||||
|
||||
### Microservices Architecture
|
||||
- [Microservices.io](https://microservices.io/)
|
||||
- [Building Microservices](https://www.oreilly.com/library/view/building-microservices/9781491950340/) (Book)
|
||||
- [Event-Driven Architecture](https://martinfowler.com/articles/201701-event-driven.html)
|
||||
|
||||
### Task Queue Patterns
|
||||
- [Celery Best Practices](https://docs.celeryproject.io/en/stable/userguide/optimizing.html)
|
||||
- [Task Queues Explained](https://blog.serverless.com/why-use-job-queues)
|
||||
- [Message Brokers](https://www.confluent.io/blog/messaging-queues-key-concepts/)
|
||||
|
||||
### Container Orchestration
|
||||
- [Docker Compose vs Kubernetes](https://www.bmc.com/blogs/docker-compose-vs-kubernetes/)
|
||||
- [Container Best Practices](https://docs.docker.com/develop/dev-best-practices/)
|
||||
- [Multi-stage Builds](https://docs.docker.com/build/building/multi-stage/)
|
||||
|
||||
## 🤝 Community & Support
|
||||
|
||||
### Telegram Communities
|
||||
- [Python Telegram Bot](https://t.me/python_telegram_bot) - Official community
|
||||
- [Celery Users](https://groups.google.com/g/celery-users) - Celery community
|
||||
- [SQLAlchemy](https://groups.google.com/g/sqlalchemy) - SQLAlchemy discussion
|
||||
|
||||
### GitHub Resources
|
||||
- [GitHub Issues](https://github.com/yourusername/TG_autoposter/issues) - Report bugs
|
||||
- [GitHub Discussions](https://github.com/yourusername/TG_autoposter/discussions) - Ask questions
|
||||
- [GitHub Wiki](https://github.com/yourusername/TG_autoposter/wiki) - Community docs (if exists)
|
||||
|
||||
### Stack Overflow Tags
|
||||
- [python-telegram-bot](https://stackoverflow.com/questions/tagged/python-telegram-bot)
|
||||
- [celery](https://stackoverflow.com/questions/tagged/celery)
|
||||
- [sqlalchemy](https://stackoverflow.com/questions/tagged/sqlalchemy)
|
||||
- [docker-compose](https://stackoverflow.com/questions/tagged/docker-compose)
|
||||
|
||||
## 🎓 Tutorials & Courses
|
||||
|
||||
### Free Resources
|
||||
- [Real Python](https://realpython.com/) - Python tutorials
|
||||
- [DataCamp](https://www.datacamp.com/) - Data & SQL courses
|
||||
- [Linux Academy](https://www.linuxacademy.com/) - DevOps courses
|
||||
- [Coursera](https://www.coursera.org/) - University courses
|
||||
|
||||
### Paid Resources
|
||||
- [Udemy](https://www.udemy.com/) - Various programming courses
|
||||
- [Pluralsight](https://www.pluralsight.com/) - Tech courses
|
||||
- [Codecademy](https://www.codecademy.com/) - Interactive learning
|
||||
|
||||
## 💡 Tips & Best Practices
|
||||
|
||||
### Development
|
||||
- Use virtual environments (`venv` or `poetry`)
|
||||
- Write tests before implementing features
|
||||
- Use type hints for better IDE support
|
||||
- Keep functions small and focused
|
||||
- Document complex logic
|
||||
|
||||
### Deployment
|
||||
- Always use .env for secrets
|
||||
- Test in staging before production
|
||||
- Use health checks for all services
|
||||
- Set up proper logging
|
||||
- Monitor resource usage
|
||||
- Plan for scaling
|
||||
|
||||
### Security
|
||||
- Never commit .env files
|
||||
- Use strong passwords (12+ characters)
|
||||
- Keep dependencies updated
|
||||
- Use HTTPS in production
|
||||
- Validate all inputs
|
||||
- Limit admin access
|
||||
|
||||
### Monitoring
|
||||
- Set up log aggregation
|
||||
- Monitor key metrics (CPU, memory, disk)
|
||||
- Track error rates
|
||||
- Monitor response times
|
||||
- Alert on anomalies
|
||||
|
||||
## 📞 Getting Help
|
||||
|
||||
### If Something Goes Wrong
|
||||
|
||||
1. **Check Logs First**
|
||||
```bash
|
||||
docker-compose logs [service] --tail 50
|
||||
```
|
||||
|
||||
2. **Read Documentation**
|
||||
- DEVELOPMENT.md for dev issues
|
||||
- PRODUCTION_DEPLOYMENT.md for prod issues
|
||||
- docs/ folder for detailed guides
|
||||
|
||||
3. **Search Online**
|
||||
- GitHub Issues of related projects
|
||||
- Stack Overflow with relevant tags
|
||||
- Library documentation
|
||||
|
||||
4. **Ask for Help**
|
||||
- GitHub Issues (be specific about the problem)
|
||||
- GitHub Discussions (for general questions)
|
||||
- Stack Overflow (for common issues)
|
||||
- Community forums (language/framework specific)
|
||||
|
||||
## 📋 Checklist for Reading Documentation
|
||||
|
||||
Before starting development/deployment:
|
||||
- [ ] Read README.md
|
||||
- [ ] Read relevant guide (DEVELOPMENT.md or PRODUCTION_DEPLOYMENT.md)
|
||||
- [ ] Skim docs/ folder
|
||||
- [ ] Check IMPROVEMENTS_SUMMARY.md for what's new
|
||||
- [ ] Review PROJECT_STRUCTURE.md for file organization
|
||||
- [ ] Run PRE_LAUNCH_CHECKLIST.md before going live
|
||||
|
||||
## 🎯 Next Steps
|
||||
|
||||
### Immediate (Today)
|
||||
1. Complete PRE_LAUNCH_CHECKLIST.md
|
||||
2. Start services with quickstart.sh
|
||||
3. Test bot in Telegram
|
||||
4. Review Flower dashboard
|
||||
|
||||
### Short Term (This Week)
|
||||
1. Read DEVELOPMENT.md
|
||||
2. Create test messages
|
||||
3. Set up monitoring
|
||||
4. Test scheduling features
|
||||
|
||||
### Medium Term (This Month)
|
||||
1. Read PRODUCTION_DEPLOYMENT.md
|
||||
2. Plan production deployment
|
||||
3. Set up backups
|
||||
4. Configure auto-scaling
|
||||
|
||||
### Long Term (Ongoing)
|
||||
1. Monitor and maintain
|
||||
2. Update dependencies
|
||||
3. Add new features
|
||||
4. Performance optimization
|
||||
|
||||
---
|
||||
|
||||
**Resource Version**: 1.0
|
||||
**Last Updated**: 2024-01-01
|
||||
**Completeness**: Comprehensive ✅
|
||||
Reference in New Issue
Block a user