GithubHelp home page GithubHelp logo

serverbot's Introduction

ServerBot

Telegram Bot to manage a server.

Installation

Get a Telegram bot

First, you will need a telegram bot. Ask this to BotFather by sending him the /newbot command.

Configure it with /setcommands and sent this:

hello - say hello
disk - show hard drives usage
uptime - uptime
memory - show memory and swap usage
wakeonlan - wake machines
shutdown - shutdown server
cmd - run custom commands

Install

Install depandancies:

# Debian/Ubuntu
sudo apt install python3 python3-pip python3-venv

Clone the repo

git clone https://github.com/xgaia/serverbot.git
cd serverbot

Create and source a Python virtual environment

python3 -m venv venv
source venv/bin/activate

Install

python3 setup.py install

Configure

Create a config file with the template and edit it

cp config.ini.template config.ini
vim config.ini # Edit the file
  • [telegram]

    • token: the bot token
    • [telegram:authorized_users]: list of username who are authorized to use the bot. Example: me = xgaiia
  • [server]

    • name: the name of the managed server
    • [server:disks]: disks path to manage. Example: root = /
    • [server:cmd]: list of shell command. Example: ls = ls -l
  • [wakeonlan]: list of machine to wake. Example: warmachine = 00:00:00:00:00:00

Run

serverbot -c /path/to/config.ini

Run as a service

Create a /etc/systemd/system/serverbot.service file like:

[Unit]
Description=Telegram bot to manage a Linux server
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/root
ExecStart=/path/to/serverbot -c /path/to/serverbot/config.ini
Restart=on-failure
[Install]
WantedBy=multi-user.target

Control the service

# Control whether bot start on boot
systemctl enable serverbot
systemctl disable serverbot

# Manual start and stop
systemctl start serverbot
systemctl stop serverbot

# Status
systemctl status serverbot

serverbot's People

Contributors

xgaia avatar

Stargazers

Franco Torres avatar Kevin Laurence avatar Aleksandar Gvozden avatar  avatar Chiqui avatar  avatar

Watchers

 avatar

Forkers

fnracotorres

serverbot's Issues

Roles

authorize some commands to roles. a role is a list of authorized users

remove / in README.md

Botfather accept commands description like

command1 - Description
command2 - Another description

so remove the /

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.