This Telegram bot monitors specific channels for cryptocurrency token deployment announcements and forwards relevant messages based on user-configured tracking lists. The bot supports tracking tokens from multiple sources with different message formats.
- Multi-channel monitoring: Tracks token deployments from multiple Telegram channels
- Customizable tracking: Add/remove tokens with simple commands
- Source-specific filtering: Different commands for different announcement channels
- Persistent storage: Maintains tracking lists between sessions
- Automatic recovery: Self-healing connection with automatic reconnection
- User-friendly interface: Simple commands with helpful responses
Requirements:
- Python 3.7+
- Telethon library
Steps:
-
Install dependencies:
pip install telethon
-
Create required files:
echo "[]" > DB.txt echo "[]" > take_token_from_only.txt
-
Run the bot:
python main.py
-
First install PM2 globally:
npm install pm2 -g
-
Start the bot with PM2:
pm2 start main.py --name "telegram-token-bot" --interpreter python3 -
Useful PM2 commands:
pm2 logs telegram-token-bot # View logs pm2 restart telegram-token-bot # Restart bot pm2 stop telegram-token-bot # Stop bot
Dockerfile:
FROM python:3.9-slim
WORKDIR /app
COPY . .
RUN pip install telethon
# Create empty database files if they don't exist
RUN touch DB.txt take_token_from_only.txt && \
echo "[]" > DB.txt && \
echo "[]" > take_token_from_only.txt
CMD ["python", "main.py"]Build and Run:
-
Build the image:
docker build -t telegram-token-bot . -
Run the container:
docker run -d --name token-bot --restart unless-stopped -v ./data:/app telegram-token-bot
-
For Docker Compose (docker-compose.yml):
version: '3' services: token-bot: build: . container_name: telegram-token-bot restart: unless-stopped volumes: - ./data:/app
-
Create service file at
/etc/systemd/system/telegram-token-bot.service:[Unit] Description=Telegram Token Tracking Bot After=network.target [Service] User=yourusername WorkingDirectory=/path/to/bot ExecStart=/usr/bin/python3 /path/to/bot/main.py Restart=always RestartSec=15 [Install] WantedBy=multi-user.target
-
Enable and start the service:
sudo systemctl daemon-reload sudo systemctl enable telegram-token-bot sudo systemctl start telegram-token-bot
For all deployment methods except direct Python execution, ensure:
- The
DB.txtandtake_token_from_only.txtfiles are preserved between restarts - For Docker, use volumes as shown in the example
- For PM2/Systemd, ensure the working directory is correct and persistent
For better security, consider modifying the code to use environment variables for sensitive data:
import os
api_id = os.getenv('TELEGRAM_API_ID', '12345678')
api_hash = os.getenv('TELEGRAM_API_HASH', 'sindf341ljhdsa12')Then run with:
TELEGRAM_API_ID=your_id TELEGRAM_API_HASH=your_hash python main.pyOr in Docker:
docker run -d -e TELEGRAM_API_ID=your_id -e TELEGRAM_API_HASH=your_hash ...For production deployments, consider adding:
- Log rotation (for PM2 or Systemd)
- Health checks (for Docker)
- Resource limits
- Regular backups of the data files
To update the bot:
- For direct Python/PM2: Replace the file and restart
- For Docker: Rebuild the image and redeploy
- For Systemd: Replace file and
systemctl restart telegram-token-bot
Remember to backup your DB.txt and take_token_from_only.txt files before updating!
-
Data Persistence:
- For Docker deployments, ensure you mount volumes for the database files
- The example above uses
-v ./data:/appto persist data in a localdatadirectory
-
Environment Variables: For better security, consider modifying the code to use environment variables for:
- API credentials (api_id and api_hash)
- Target chat IDs
- File paths
-
Logs Monitoring:
- For Docker:
docker logs telegram-token-bot -f - For systemd:
journalctl -u telegram-token-bot -f
- For Docker:
-
Resource Considerations:
- The bot is lightweight but ensure your server has:
- Stable internet connection
- At least 512MB RAM
- Basic CPU resources
- The bot is lightweight but ensure your server has:
-
Updates:
- When updating the code, remember to:
- For Docker: Rebuild the image and restart containers
- For systemd: Restart the service (
sudo systemctl restart telegram-token-bot)
- When updating the code, remember to:
add $TOKEN - Track token from OttoBASEDeployments/bananadeployerBASE
vd add $TOKEN - Track token from virtuals_deploy
bds add $TOKEN - Track token from bananadeployerSOL
dell $TOKEN - Remove token from tracking
show - List all tracked tokens
help - Show help menu
.
├── Untitled.py - Main bot script
├── DB.txt - Database of tracked tokens
├── take_token_from_only.txt - Tracking preferences
├── Dockerfile - Docker configuration
└── README.md - This file