A Telegram bot that creates beautiful quote stickers from chat messages.
- 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 22+
- MongoDB database
- Redis database
- quote-api service
- Telegram API ID and hash for TDLib
Clone the repository
git clone https://github.com/LyoSU/quote-bot.git cd quote-botInstall dependencies
npm install
Set up environment variables
cp .env.example .env # Edit .env with your configurationSet up TDLib
- The bot uses the
prebuilt-tdlibnpm package by default. - Set
TELEGRAM_API_IDandTELEGRAM_API_HASHin your environment.
- The bot uses the
Start the bot
npm start
This repository includes railway.json, .env.example, and a single-container starter for Railway.
- Create or connect this GitHub repository in Railway.
- Add MongoDB, then add the Redis variables from
.env.example. - Add all required variables from
.env.examplein the Railway service variables tab. - Deploy the quote-api service separately and set
QUOTE_API_URIto that service URL. - Deploy. Railway will build with the Dockerfile, run
npm start, and check/health.
npm start runs one update collector plus MAX_WORKERS worker processes. Use npm run start:collector or npm run start:worker only when you intentionally want to run one role by itself.
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-botcd quote-bot docker compose --profile dev up -d # Start quote-apicd ../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 |
REDIS_HOST | Redis host, for example redis-10702.c261.us-east-1-4.ec2.cloud.redislabs.com | Yes |
REDIS_PORT | Redis port, for example 10702 | Yes |
REDIS_USERNAME | Redis username, usually default for Redis Cloud | Yes |
REDIS_PASSWORD | Redis password from Redis Cloud | Yes |
TELEGRAM_API_ID | Telegram API ID for TDLib | Yes |
TELEGRAM_API_HASH | Telegram API hash for TDLib | Yes |
- 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/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
/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
- Database Layer: MongoDB with Mongoose ODM
- Redis Queue: Collector distributes Telegram updates to worker queues
- Railway Starter:
railway-start.jsruns collector, workers, and/health
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
├── updates-collector.js # Telegram update collector
├── updates-worker.js # Update processor worker
├── railway-start.js # Railway single-container process manager
└── handler.js # Main bot composer
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.
Made by LyoSU