/telegram-shell-bot

A telegram Bot to run shell commands

Primary LanguagePython

Telegram Shell Bot

This is a Telegram Bot to run shell commands.

Requirments

  • Python 3.6+
  • Pipenv

Install

  1. Create a bot and get token from BotFather bot

  2. Clone Telegram Shell Bot

     git clone https://github.com/vicalloy/telegram-shell-bot.git
    
  3. Copy settings.py.sample to settings.py and config it.

    • TOKEN Bot token generated by BotFather
    • ENABLED_USERS Your telegram user id. Only enabled users can use this bot.
    • CMD_WHITE_LIST Only command in CMD_WHITE_LIST can be execute. Let it empty if no restriction.
    • CMD_BLACK_LIST Ignore command in CMD_BLACK_LIST.
    • CMD_BLACK_CHARS Ignore command contain char in CMD_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.
  4. Create a virtual environment and install required packages

     pipenv --python 3
     pipenv install -d --skip-lock
     pipenv shell
    

Run

pipenv shell
python bot.py

Usage

  1. Talk to the bot. Every message will be treated as a shell command.

  2. /tasks to show all running tasks

  3. /kill to kill a running task

  4. /sudo_login to call sudo

  5. /script to run scripts in ./scripts directory

  6. 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