Development
Development Environment Setup
Prerequisites
- Node.js 18+ and npm
- Git
- SQLite3
- Text editor (VSCode recommended)
- Telegram account for testing
Initial Setup
Environment Configuration
Development Workflow
Code Structure
Running in Development
VSCode Configuration
.vscode/launch.json:
Adding Features
Creating a New Command
- Create command handler:
- Register in bot:
- Add translations:
Adding Database Tables
- Create migration:
- Update types:
- Add database functions:
Testing During Development
Manual Testing
- Create test bot:
- Talk to @BotFather
- Create new bot for testing
- Get test token
- Test database:
- Test commands:
Automated Testing
Debugging
Debug Logging
Common Issues
- Bot not responding:
- Check BOT_TOKEN is correct
- Verify bot is not running elsewhere
- Check network connectivity
- Database locked:
- Ensure only one instance running
- Check file permissions
- Use WAL mode
- RPC errors:
- Verify RPC URL is accessible
- Check rate limits
- Monitor network latency
Code Style
TypeScript Guidelines
Error Handling
Performance Considerations
Development Profiling
Development Tools
- nodemon: Auto-restart on changes
- ts-node: Run TypeScript directly
- source-map-support: Better stack traces
- dotenv: Environment management
Git Workflow
Branch Strategy
Commit Messages
Pre-commit Hooks
.husky/pre-commit: