Telegram_en - ghzserg/zmod GitHub Wiki
A macro is a small program written in Klipper/Gcode language.
It can be called from:
- A GCODE file
- The Fluidd/Mainsail console (press
C
in Fluidd)
Note
The value in parentheses is the default value
🔷 Telegram Bot 🔷 |
|
---|---|
Description | Bot Registration |
One-Command Telegram Bot Installation on Debian | Step-by-Step Telegram Bot Installation |
Adding SSH Keys | Starting ZSSH on the Printer |
For ArmBian |
Core Idea: Our hardware is very slow and has limited memory. Therefore, running the moonraker-telegram-bot directly on the hardware is impractical. However, we can run it on an external server. This requires any server (physical/virtual) that the printer can reach via SSH.
The new version automatically generates SSH keys (used for passwordless authentication).
Key locations:
-
/mod_data/ssh.pub.txt
— public key. Copy its contents to the server's~/.ssh/authorized_keys
file. -
/mod_data/ssh.key
— private key. Used by the printer to connect to the server.
You don’t need the keys themselves. Simply call the ZSSH_ON macro with the following parameters:
-
SSH_SERVER
— IP or hostname of your server -
SSH_PORT
— SSH port on the server (default: 22) -
SSH_USER
— SSH server username -
VIDEO_PORT
— Server port for receiving video stream from the camera (default: 8080) -
MOON_PORT
— Server port for receiving data from moonraker (default: 7125) -
REMOTE_enN
— Command to execute on the remote server
SSH usage consumes approximately 300 KB of memory.
If the printer and server are on the same network, SSH is optional. Refer to the telegram.conf configuration file.
Download the configuration file from the printer at mod/telegram/
.
How to register your bot:
- Go to @BotFather
- Send
/newbot
- Enter any name you like
- Enter the bot name (must end with
_bot
, e.g.,ff5msuper_bot
) - You’ll receive a long ID — add this to the bot’s
bot_token
parameter in the settings.
Install the Telegram bot with one command on Debian:
Execute as the root
user:
bash <(wget --cache=off -q -O - https://github.com/ghzserg/zmod_ff5m/raw/refs/heads/1.5/telegram/telegram.sh)
If wget
is not installed:
apt update && apt install wget -y
This script will:
- Install Docker
- Download docker-compose.yml and telegram.conf
- Create a
tbot
user - Guide you through bot registration and request the
bot_token
- Guide you to obtain the
chat_id
and request it - Install ff5m.sh
Add SSH keys manually.
- Copy docker-compose.yml from the printer’s
mod/telegram/
directory. - Install Docker (Debian instructions):
apt update
apt upgrade -y
apt install docker.io docker-compose docker apparmor -y
- Create a directory for the bot:
mkdir bot1
cd bot1
-
Place docker-compose.yml here.
-
Create subdirectories:
mkdir config log timelapse_finished timelapse
chmod 777 config log timelapse_finished timelapse
- Copy telegram.conf from
mod/telegram/
toconfig/
and edit it.
For more bot configuration details, see here.
- Start the bot:
docker-compose up -d
- Create a user and grant permissions:
useradd tbot
usermod -a -G docker tbot
-
Log in as the
tbot
user:su - tbot
-
Add SSH keys:
mkdir .ssh cat > .ssh/authorized_keys
Paste the public key from
mod_data/ssh.pub.txt
, then pressCtrl + D
.
After setup, run the ZSSH_ON macro on the printer with the required parameters.
SSH will automatically restart 3 minutes after each reboot.
Download Debian Minimal/IOT images with Armbian from the website https://www.armbian.com/download/
Install Armbian on an SD card using balenaEtcher from https://etcher.balena.io/
Boot the system, set a root password, and create a new user
Proceed under the root user:
su - root
Configure Wi-Fi if not set up during user creation:
sudo armbian-config
Update the system:
sudo apt update && sudo apt upgrade -y
Install AppArmor (Linux kernel security module):
sudo apt install -y apparmor apparmor-utils
Install Telegram bot:
bash <(wget --cache=off -q -O - https://github.com/ghzserg/zmod_ff5m/raw/refs/heads/1.5/telegram/telegram.sh)
Add SSH keys:
Switch to the tbot
user from root:
su - tbot
Set up SSH keys:
mkdir -p .ssh
cat > .ssh/authorized_keys
Enter the public key from the file mod_data/ssh.pub.txt
on your host system, then press CTRL+D
Reboot the system:
sudo reboot