This is a Telegram Bot to run shell commands.
- Python 3.8+
- Poetry
-
Create a bot and get token from BotFather bot
-
Clone
Telegram Shell Bot
git clone https://github.com/vicalloy/telegram-shell-bot.git
-
Copy
settings.py.sample
tosettings.py
and config it.TOKEN
Bot token generated by BotFatherENABLED_USERS
Your telegram user id. Only enabled users can use this bot.-999999
will disable authentication. Public bot is very danger for your server, dont's use root to run this bot. You must add settingsCMD_WHITE_LIST
orONLY_SHORTCUT_CMD=True
(recommend) for a public bot.
CMD_WHITE_LIST
Only command inCMD_WHITE_LIST
can be execute. Let it empty if no restriction.CMD_BLACK_LIST
Ignore command inCMD_BLACK_LIST
.CMD_BLACK_CHARS
Ignore command contain char inCMD_BLACK_LIST
.PROXY_URL
Proxy url.SC_MENU_ITEM_ROWS
Command shortcut config.ONLY_SHORTCUT_CMD
Run command by shortcut menu only. Other commands will be ignored.
-
Create a virtual environment and install required packages
poetry install --only main poetry shell
poetry shell
python bot.py
pm2 is one of the best tools today for server production and make your bot for remote online 24/7 hours
install and doc for pm2 in https://pm2.keymetrics.io/
start bot with
pm2 start telegram-shell-bot.yml
pm2 save # save runing command
pm2 startup # for autostart on bot
-
Talk to the bot. Every message will be treated as a shell command.
-
/tasks
to show all running tasks -
/kill
to kill a running task -
/download
to download file from server.ex: /download README.md
-
The file send to bot will upload to folder
./upload/
. -
/sudo_login
to call sudo -
/script
to run scripts in ./scripts directory -
The bot sends first 3sec's output for every command. You can add
oa
in command to send all output. E.g.:oa;ping google.com /script oa;demo.py