No description
Find a file
2026-10-24 14:20:51 +03:00
.env Improve MSWT bot: add .env config, requirements.txt, fix security, improve bot.py and bot.service 2026-10-24 14:20:51 +03:00
.env.example Improve MSWT bot: add .env config, requirements.txt, fix security, improve bot.py and bot.service 2026-10-24 14:20:51 +03:00
bot.py Improve MSWT bot: add .env config, requirements.txt, fix security, improve bot.py and bot.service 2026-10-24 14:20:51 +03:00
bot.service Improve MSWT bot: add .env config, requirements.txt, fix security, improve bot.py and bot.service 2026-10-24 14:20:51 +03:00
README.md Improve MSWT bot: add .env config, requirements.txt, fix security, improve bot.py and bot.service 2026-10-24 14:20:51 +03:00
requirements.txt Improve MSWT bot: add .env config, requirements.txt, fix security, improve bot.py and bot.service 2026-10-24 14:20:51 +03:00

MSWT - ManageServerWithTG

Manage your server via Telegram bot.

Features

  • System info: CPU, RAM, Disk, OS, Battery (/info)
  • Shell terminal: Execute commands safely (/sh)
  • Auto-start bots: Run -start.sh/-start.bat files (/bots)
  • Service restart: Trigger restart_daemon.sh (/restart)
  • Server reboot (with confirmation) (/stop)

Requirements

  • Python 3.8+
  • Linux (systemd for service)
  • Dependencies in requirements.txt

Installation

git clone <repo>
cd MSWT
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Configuration

Copy .env.example to .env and edit:

cp .env.example .env
nano .env

Required variables:

Variable Description Example
API_ID Telegram API ID (from my.telegram.org) 2860432
API_HASH Telegram API Hash 2fde6ca0f8ae7bb58844457a239c7214
OWNER_IDS Comma-separated Telegram user IDs with access 1084116847,5466899247
VERSION Bot version string 1.3.0
TELEGRAM_TOKEN Optional: Bot token. If set, uses bot account. If omitted, uses my_account.session file (user account). 123456:ABC-DEF...

Two auth modes:

  1. Bot token — set TELEGRAM_TOKEN in .env (recommended for production).
  2. User session — leave TELEGRAM_TOKEN empty; bot reads my_account.session (created after first login).

Run manually

python3 bot.py

Systemd service (Linux)

# Edit paths in bot.service
sudo cp bot.service /etc/systemd/system/mswt.service
sudo systemctl daemon-reload
sudo systemctl enable --now mswt

Commands

Command Description
/start, /help Show help
/info System stats
/sh <cmd> Execute shell command
/bots Start all *-start.sh/bat files in cwd
/restart Run restart_daemon.sh
/stop Reboot server (sudo)

Security notes

  • /sh blocks dangerous commands (rm -rf, reboot, shutdown, kill -9, etc.)
  • Only users in OWNER_IDS can use the bot
  • Use bot token mode for production; avoid running as root

License

MIT