Skip to content

Telegram bot to execute a command from a configurable list

License

Notifications You must be signed in to change notification settings

aceberg/LinuxExecBot

Repository files navigation

Go Report Card Maintainability Codacy Badge Binary-release GitHub

LinuxExecBot

Telegram bot to execute a command from a configurable list on your Linux machine

1. Installation
2. Usage
3. Options

1. Installation

From .deb repository (recommended)

curl -s --compressed "https://aceberg.github.io/ppa/KEY.gpg" | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/aceberg.gpg
sudo curl -s --compressed -o /etc/apt/sources.list.d/aceberg.list "https://aceberg.github.io/ppa/aceberg.list"
sudo apt update && sudo apt install linuxexecbot

From .deb file

Download latest release, install with your package maneger

From .tar.gz

Download latest release, then

tar xvzf LinuxExecBot-*.tar.gz
cd LinuxExecBot
sudo ./install.sh

With go

go install github.com/aceberg/LinuxExecBot/cmd/LinuxExecBot@latest

2. Usage

As root

  1. Edit /etc/LinuxExecBot/config.yaml, put your Telegram bot's Token and ChatID there. Add your commands. Example:
config:
  token: 5XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  #id: 111111111 
  ids:     # Use either id (for one user) or ids (for several bot users)
    - 111111111
    - 222222222
  args: no # If set to "yes", allows to send arguments with bot commands
           # WARNING! Could be dangerous, if someone gets access to your bot
commands:
- name: la
  exec: "ls -al"
  desc: "List all files"

- name: ping
  exec: "ping -c 3 8.8.8.8"
  desc: "Ping Google DNS"

Only commands with not empty desc field will be shown in Bot Menu.
/help command lists all available commands

  1. Enable and start service
systemctl enable linuxexecbot.service
systemctl start linuxexecbot.service
  1. Go to your bot in Telegram and try to execute command. Example: /la

As user

  1. Copy config example
mkdir -p ~/.config/LinuxExecBot
cp /etc/LinuxExecBot/config.yaml ~/.config/LinuxExecBot/config.yaml
  1. Edit config.yaml, put your bot's Token and ChatID there
  2. Enable and start service, replace MYUSER with your username
systemctl enable linuxexecbot@MYUSER.service
systemctl start linuxexecbot@MYUSER.service
  1. Go to your bot in Telegram and try to execute command.

3. Options

Key Description Default
-c Path to config yaml file config.yaml