Wolbot is a python powerd telegram bot for Wak On LAN tasks.
- List devices (All/Online/Offline) with status.
- Send magic packet to wake up the devices.
- Loguru a library which aims to bring enjoyable logging in Python.
- PyYAML a data serialization format designed for human readability and interaction with scripting languages.
- pyTelegramBotAPI A simple, but extensible Python implementation for the Telegram Bot API.
- wakeonlan A small python module for wake on lan.
Wolbot can be installed and run as a system service or a Docker container.
-
Create new telegram bot and get the token Open Telegram messenger, sign in to your account or create a new one.
Enter @Botfather in the search tab and choose this bot (Official Telegram bots have a blue checkmark beside their name.)
Click “Start” to activate BotFather bot.
In response, you receive a list of commands to manage bots. Choose or type the /newbot command and send it.
Choose a name for your bot — your subscribers will see it in the conversation. And choose a username for your bot — the bot can be found by its username in searches. The username must be unique and end with the word “bot.”
After you choose a suitable name for your bot — the bot is created. You will receive a message with a link to your bot t.me/<bot_username>, recommendations to set up a profile picture, description, and a list of commands to manage your new bot.
-
Update the configuration file with the list of network objects. the file should be place under config folder:
computers: - name: ip: mac:
-
Set the following environment variables:
- BOT_TOKEN=#Telegram bot Token generated in the previous step.
- ALLOWED_IDS= #List of telegram id's allowed to communicate with the bot, comma-separated values.
-
If you want to run Wolbot as a docker container, copy the following code into your docker-compose.yaml:
version: "3.6" services: wolbot: image: techblog/wolbot container_name: wolbot restart: always environment: - BOT_TOKEN= #Telegram bot Token. - ALLOWED_IDS= #List of telegram id's allowed to communicate with the bot, comma-separated values.
**Make sure to set all the environment variables before running the "docker-compose up -d" command.
-
If you want to run Wolbot as a systemd service, clone the repository using the following command:
git clone https://github.com/t0mer/wolbot
enter the wolbot folder and install the dipendencies:
pip3 install -r requirements.txt
Next, create a file names "wolbot.service" under /etc/systemd/system" and paste the following content:
[Unit] Description=Wake On Lan bot After=network-online.target Wants=network-online.target systemd-networkd-wait-online.service StartLimitIntervalSec=5 StartLimitBurst=5 [Service] EnvironmentFile=/etc/environment KillSignal=SIGINT WorkingDirectory=/opt/dev/wolbot/app/ Type=simple User=root ExecStart=/usr/bin/python3 /opt/dev/wolbot/app/app.py Restart=always [Install] WantedBy=multi-user.target
Make sure to adjust the path for "WorkingDirectory" and "ExecStart" accordingly to the path of the Wolbot location
Next, run the following command to enable and start the service:
systemctl enable wolbot.service systemctl start wolbot.service
To check the status of the service, run the following command:
systemctl status wolbot.servies
To start using Wolbot send one of the following commands: /start ot /help. A shortcut menu will be opened, with four options:
- Show all computers.
- Show online computers.
- Show offline computers.
- Cancel.
Click on one of the first three options, and a list of computers will be displayed:
Click on one of the computers to wake it up: