π¬π§ English | πͺπΈ EspaΓ±ol
Professional Telegram bot to manage and monitor WireGuard through the WGDashboard API. Allows administrators to manage peers, monitor server status, and execute administrative actions directly from Telegram.
- π‘ Configuration Management: View all WireGuard configurations
- π₯ Peer Management: Create, delete, view details, and monitor peers
- π Restrictions: Restrict/allow access for specific peers
- π§Ή Traffic Cleanup: Reset data counters for peers
- β° Schedule Jobs: Create scheduled tasks (data limits and expiration dates)
- π₯οΈ System Status: Monitor CPU, memory, disks, and interfaces
- π Statistics: View detailed system information
- π· Operator Supervision: Monitor authorized operator activity
- π Multi-language: Support for Spanish and English
- β Create Temporary Peers: Generate peers with automatic limits
- π₯ Download Config: Get
.conffile for the new peer - π Change Language: Select between Spanish and English
- β³ Automatic Limits: 1 GB data and 24 hours duration per peer
TGBot-saveOK/
βββ main.py # Bot entry point
βββ config.py # Configuration and environment variables
βββ handlers.py # Command and callback handlers (4100+ lines)
βββ keyboards.py # Telegram inline keyboards
βββ i18n.py # Multi-language translation system
βββ operators.py # Authorized operator control
βββ utils.py # Utility functions
βββ wg_api.py # WGDashboard API client
βββ setup_logging.py # Logging configuration
βββ .env # Environment variables (DO NOT commit)
βββ requirements.txt # Project dependencies
βββ README.md # This file
βββ locales/
β βββ es.json # Spanish translation
β βββ en.json # English translation
βββ info/
βββ resumen.md # Technical documentation
βββ CAMBIOS_REALIZADOS.md # Change history
βββ IMPLEMENTACION_*.md # Feature documentation
- Linux (Ubuntu 22.04 LTS or higher recommended)
- Python 3.10 or higher
- pip (Python Package Manager)
- WireGuard: Installed and configured on the server
- WGDashboard: Running and accessible via API
- Telegram Bot: Created with @BotFather
git clone https://github.com/WGDashboard/WGErinys
cd WGErinyspython3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activatepip install -r requirements.txtCreate .env file in the project root:
# ===== TELEGRAM =====
TELEGRAM_BOT_TOKEN=your_token_here # Get from @BotFather on Telegram
# ===== WGDASHBOARD API =====
WG_API_BASE_URL=https://your-domain.com/api # Base URL of the API
WG_API_KEY=your_api_key_here # WGDashboard API Key
WG_API_PREFIX=wg # API prefix (if applicable)
API_TIMEOUT=10 # Timeout in seconds
# ===== LOGGING =====
LOG_FILE=wg_bot.log # Log file
LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR
# ===== ACCESS =====
ALLOWED_USERS=123456789,987654321 # Authorized Telegram IDs
ROLE_ADMIN=admin # Administrator role
ROLE_OPERATOR=operator # Operator role
ADMIN_IDS=123456789 # IDs that are administrators
OPERATOR_IDS=987654321,111222333 # IDs that are operators
# ===== OPERATOR LIMITS =====
OPERATOR_DATA_LIMIT_GB=1 # GB per created peer
OPERATOR_TIME_LIMIT_HOURS=24 # Hours of peer durationEdit config.py and add Telegram IDs:
# Authorized IDs to use the bot
ALLOWED_USERS = [
123456789, # Admin 1
987654321, # Admin 2
111222333, # Operator 1
]
# Role configuration
ADMIN_USERS = [123456789, 987654321]
OPERATOR_USERS = [111222333]
# Operator limits
OPERATOR_DATA_LIMIT_GB = 1 # 1 GB per peer
OPERATOR_TIME_LIMIT_HOURS = 24 # 24 hours durationTo get your Telegram ID:
- Open @userinfobot on Telegram
- The bot will show your ID
# With virtual environment activated
python main.pyCreate service file:
sudo nano /etc/systemd/system/wgbot.serviceFile content:
[Unit]
Description=WGDashboard Telegram Bot
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=wgbot
Group=wgbot
WorkingDirectory=/home/wgbot/TGBot-saveOK
Environment="PATH=/home/wgbot/TGBot-saveOK/.venv/bin"
ExecStart=/home/wgbot/TGBot-saveOK/.venv/bin/python main.py
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.targetEnable and start the service:
# Reload systemd
sudo systemctl daemon-reload
# Enable to start automatically
sudo systemctl enable wgbot
# Start the bot
sudo systemctl start wgbot
# Check status
sudo systemctl status wgbot
# View logs in real-time
sudo journalctl -u wgbot -f
# Stop
sudo systemctl stop wgbot
# Restart
sudo systemctl restart wgbot# Build image
docker build . -f docker/Dockerfile -t wgerinys:latest
# Run container
docker run -d --name wgerinys --env-file .env wgerinys:latest# Install tmux
sudo apt-get install tmux
# Create session
tmux new-session -d -s wgbot -c /path/to/bot python main.py
# View sessions
tmux list-sessions
# Connect to session
tmux attach-session -t wgbot
# Disconnect (Ctrl+b, then d)| Command | Description |
|---|---|
/start |
Start bot and show main menu |
/help |
Show help and available commands |
/stats |
Show system statistics |
/configs |
List all WireGuard configurations |
Functions via menu:
- π‘ Configurations - Manage all configs
- π₯ Peers - View, create, delete, list
- π₯οΈ System Status - CPU, RAM, disks, network
- β‘ Protocols - View enabled protocols
- π· Operators - View operator activity
- π Language - Switch between Spanish and English
| Command | Description |
|---|---|
/start |
Show menu to create peers |
/help |
Information about limits and functions |
Functions:
- β Create Peer - Generate new temporary peer
- π₯ Download - Get configuration file
- π Language - Change language
Administrator (full access)
- All bot functions
- Full peer management
- Access to statistics
- Operator supervision
Operator (limited access)
- Only create temporary peers
- Download configuration of created peers
- No access to existing peer management
Unauthorized (no access)
- Bot rejects any command
- Error message: "Access restricted"
-
WGDashboard API Key
- Use environment variables
.env - Never commit
.envto git - Add to
.gitignore
- Use environment variables
-
Telegram Bot Token
- Keep in
.env - Change if exposed
- Use webhook restrictions if possible
- Keep in
-
Server Access
- Active firewall
- SSH with public keys
- Change default SSH port
- Monitor logs regularly
-
WGDashboard
- Behind reverse proxy (nginx)
- HTTPS mandatory
- Strong authentication
- Regular backups
- Unique name
- Automatic IP
- WireGuard keys generated
.conffile sent directly- Automatic limits applied
- Network information (IP, endpoint, DNS)
- Connection status (connected/disconnected)
- Traffic (sent, received, cumulative)
- Keys (public, pre-shared)
- Scheduled jobs
- Shared links
- Restrict peer (blocks connection)
- Allow access (removes restriction)
- Pagination
- Available filters
Scheduled jobs allow:
- Data Limit: Restrict when reaching X GB
- Expiration Date: Auto restrict on date X
- Create/delete jobs on the fly
- Full task management
Monitor in real-time:
- π» CPU usage (%)
- π§ RAM usage (% and details)
- πΎ Disk usage (main drives)
- π‘ Network interfaces (traffic)
- π WireGuard interfaces
The bot automatically supports:
- πͺπΈ Spanish - Complete Spanish interface
- π¬π§ English - Complete English interface
Users can change language from the menu at any time. Preferences are automatically saved.
# If using systemd
sudo journalctl -u wgbot -f
# If running directly
tail -f wg_bot.logDEBUG - Detailed information for debugging
INFO - Important events
WARNING - Warnings (potential issues)
ERROR - Errors affecting functionality
Edit .env:
LOG_LEVEL=DEBUG # For more detail in development
# Check if it's running
sudo systemctl status wgbot
# View logs
sudo journalctl -u wgbot -n 50
# Restart
sudo systemctl restart wgbot- Verify
WG_API_BASE_URLin.env - Verify
WG_API_KEYis correct - Test connectivity:
curl https://your-url/api/handshake - Check firewall/proxy allows connection
- Verify
TELEGRAM_BOT_TOKENin.env - Create new token with @BotFather
- Check for whitespace
# Restart to load changes
sudo systemctl restart wgbot
# Or if using tmux
tmux send-keys -t wgbot "C-c"
python main.pyinfo/resumen.md- Technical API analysisinfo/CAMBIOS_REALIZADOS.md- Change historyinfo/IMPLEMENTACION_*.md- Feature details
Contributions are welcome. Please:
- Fork the project
- Create a branch for your feature (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Jorge EliΓ‘n Martinez Perdomo
Professional Telegram bot for WireGuard administration using WGDashboard
- GitHub: @jemartinezp1994
- Telegram: @jemp01K
- Discord: ff_c3r0
Last Updated: January 11, 2026 Version: 2.0