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
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/
. Sample-config
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 Sample-config
- 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.
Edit the docker-compose.yml file.
Add:
spoolman:
image: ghcr.io/donkie/spoolman:latest
restart: unless-stopped
volumes:
- ./spoolman:/home/app/.local/share/spoolman
ports:
- "7912:8000"
environment:
- TZ=Asia/Yekaterinburg
Open the port in the firewall, if you are using one:
iptables -I INPUT -p tcp --dport 7912 -j ACCEPT
Create the spoolman
directory:
mkdir spoolman
chmod 777 spoolman
Restart Docker:
docker-compose down && docker-compose up -d
or
docker compose down && docker compose up -d
On the printer, add to mod_data/user.moonraker.conf
external_IP
— the external IP address of the server running Docker.
The printer MUST have access to this IP.
[spoolman]
server: http://external_IP:7912
sync_rate: 5
Edit the file docker-compose.yml
Specify your time zone. The example file specifies TZ=Asia/Yekaterinburg
docker-compose down && docker-compose up -d
or docker compose down && docker compose up -d
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
Download and install helm https://helm.sh/docs/intro/install/
Clone helm chart from repo
git clone https://github.com/aldiserg/zmod_ff5m_tg_bot.git
Changes:
-
persistence.enabled change to "false" if you nont planned to store timelapses
-
persistence.volumes...storageClass change if you will use external storage
-
configMapAsFile.data.telegram.conf - this is main config file, should be changed a few lines:
[bot] server: 3D_printer_host:7125 bot_token: 1111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA chat_id: 111111111 [camera] host: http://3D_printer_host:8080/?action=stream host_snapshot: http://3D_printer_host:8080/?action=snapshot
How to get bot_token and chat_id look here
Installation:
You should be in helm chart folder to run install/upgrade command
helm upgrade --install zmod_ff5m_tg_bot ./ -n default -f values.yaml