Telegram_en - ghzserg/zmod GitHub Wiki

Telegram Bot

Прочитать на русском языке

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

Telegram Bot

Description

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/.

Top


Bot Registration

How to register your bot:

  1. Go to @BotFather
  2. Send /newbot
  3. Enter any name you like
  4. Enter the bot name (must end with _bot, e.g., ff5msuper_bot)
  5. You’ll receive a long ID — add this to the bot’s bot_token parameter in the settings.

Top


Server Deployment

One-Command Telegram Bot Installation on Debian

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:

  1. Install Docker
  2. Download docker-compose.yml and telegram.conf
  3. Create a tbot user
  4. Guide you through bot registration and request the bot_token
  5. Guide you to obtain the chat_id and request it
  6. Install ff5m.sh

Add SSH keys manually.

Top


Step-by-Step Telegram Bot Installation

  1. Copy docker-compose.yml from the printer’s mod/telegram/ directory.
  2. Install Docker (Debian instructions):
apt update 
apt upgrade -y
apt install docker.io docker-compose docker apparmor -y
  1. Create a directory for the bot:
mkdir bot1
cd bot1
  1. Place docker-compose.yml here.

  2. Create subdirectories:

mkdir config log timelapse_finished timelapse
chmod 777 config log timelapse_finished timelapse
  1. Copy telegram.conf from mod/telegram/ to config/ and edit it.

For more bot configuration details, see here.

  1. Start the bot:
docker-compose up -d
  1. Create a user and grant permissions:
useradd tbot
usermod -a -G docker tbot

Top


Adding SSH Keys

  1. Log in as the tbot user:

    su - tbot
  2. Add SSH keys:

    mkdir .ssh
    cat > .ssh/authorized_keys

    Paste the public key from mod_data/ssh.pub.txt, then press Ctrl + D.

Top


Starting ZSSH on the Printer

After setup, run the ZSSH_ON macro on the printer with the required parameters.

SSH will automatically restart 3 minutes after each reboot.

Top

Installation and Setup for Armbian (by noyhay)

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

Back Top Forward

⚠️ **GitHub.com Fallback** ⚠️