A powerful Telegram bot that creates beautiful quote stickers from chat messages with AI-powered features.
- Beautiful Quote Stickers: Convert messages into stylish quote stickers
- Multiple Formats: WebP stickers, PNG images, or document files
- Customizable Design: Custom background colors, emoji brands, and scaling
- Privacy Protection: Optional user anonymization
- High Performance: Cluster architecture with load balancing
- Rate Limiting: Smart rate limiting to prevent spam
- Health Monitoring: Built-in health checks and monitoring
- Business API: Support for Telegram Business connections
- Inline Queries: Works in inline mode
- Statistics: Usage tracking and analytics
- Node.js 16+
- MongoDB database
- quote-api service
- TDLib binary
-
Clone the repository
git clone https://github.com/LyoSU/quote-bot.git cd quote-bot -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env # Edit .env with your configuration -
Set up TDLib
- Download TDLib binary for your platform
- Place it at
helpers/tdlib/data/libtdjson.so(Linux) orhelpers/tdlib/data/libtdjson.dylib(macOS) - Or use the prebuilt-tdlib npm package
-
Start the bot
npm start
-
Pull repositories
git clone https://github.com/LyoSU/quote-bot.git git clone https://github.com/LyoSU/quote-api.git
-
Configure environment
- Edit
.envfiles in both repositories - Set up your bot token, database, and API keys
- Edit
-
Create Docker network
docker network create quotly
-
Set up TDLib
- Download TDLib binary for Linux
- Place it at
helpers/tdlib/data/libtdjson/libtdjson.so - Recommended: Use prebuilt-tdlib or tdlib.native builder
-
Start services
# Start quote-bot cd quote-bot docker compose --profile dev up -d # Start quote-api cd ../quote-api docker compose up -d
| Variable | Description | Required |
|---|---|---|
BOT_TOKEN |
Telegram bot token from @BotFather | Yes |
MONGODB_URI |
MongoDB connection string | Yes |
QUOTE_API_URI |
Quote generation API endpoint | Yes |
OPENAI_API_KEY |
OpenRouter API key for AI features | No |
ANTHROPIC_API_KEY |
Anthropic API key for AI features | No |
MAX_WORKERS |
Number of worker processes | No |
WORKER_HANDLER_TIMEOUT |
Worker timeout in milliseconds | No |
- MongoDB is required for storing user data, quotes, and statistics
- The bot will automatically create necessary collections and indexes
/q- Create a quote from replied message/q <number>- Create quote from multiple messages/q <text>- AI-powered message search and quote creation/qrand- Random quote from chat history/qtop- Top-rated quotes/help- Show help message
/q p- Generate as PNG image/q i- Generate as image file/q r- Include reply context/q rate- Enable rating buttons/q <color>- Set custom background color/q s1.5- Scale factor (1.5x larger)/q c- Crop image content
/q * <query>- AI-powered message selection- Example:
/q * funny moments- Find and quote funny messages - Example:
/q * jokes from John- Find jokes from specific user
/qcolor <color>- Set default background color/qemoji- Change emoji brand/qrate- Enable/disable rating system/privacy- Toggle privacy mode/lang- Change language
The bot uses a sophisticated cluster architecture:
- Master Process: Handles load balancing, queue management, and TDLib operations
- Worker Processes: Process individual Telegram updates
- Queue Manager: Manages update queues with priority handling
- Quote Generation: External API service for image generation
- AI Integration: OpenAI/Anthropic APIs for smart features
- Database Layer: MongoDB with Mongoose ODM
- Health Monitoring: Circuit breaker pattern and health checks
npm start# Lint code
npx eslint .
# Check for issues
npm audit- Create handlers in
handlers/directory - Add database models in
database/models/ - Implement middleware in
middlewares/ - Add utilities in
utils/
quote-bot/
├── handlers/ # Command and message handlers
├── database/ # Database models and connection
├── middlewares/ # Bot middleware
├── helpers/ # Utility functions and TDLib
├── locales/ # Internationalization files
├── utils/ # General utilities
├── master.js # Master process (cluster mode)
├── worker.js # Worker processes
├── bot.js # Main bot instance
└── index.js # Entry point
The bot requires the quote-api service for quote generation. This service handles:
- Quote image rendering
- Custom styling and themes
- Multiple output formats
- Image processing and optimization
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Telegraf - Modern Telegram Bot Framework
- TDLib - Telegram Database Library
- OpenRouter - AI API Gateway
- Anthropic - Claude AI Platform
Made with ❤️ by LyoSU