GitHub - rscircus/the-telegram-telegram: Using a thermal receipt printer to send _real_ telegrams

2 min read Original article ↗

Skip to content

Navigation Menu

Repository files navigation

The Telegram Telegram

This is a Telegram bot that receives messages and prints them directly to a networked thermal receipt printer (ESC/POS). It supports text wrapping, custom fonts, and emoji rendering.

The printer in action.

Prerequisites

Hardware

  • A networked ESC/POS thermal printer (e.g., Epson TM-T88 or compatible).
  • Network connection to the printer.

Software

  • Python 3.12+
  • uv (Python package and project manager)

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd the-telegram-telegram
  2. Install dependencies using uv:

Configuration

Open brrrzzt_emoji_bot.py and configure the following variables at the top of the file:

  • BOT_TOKEN: Your Telegram Bot API token (get one from @BotFather).
  • ALLOWED_USER_IDS: A list of Telegram user IDs allowed to use the bot (get yours from @userinfobot).
  • PRINTER_IP: The IP address of your thermal printer.
  • PRINTER_PORT: The port of your thermal printer (usually 9100).
  • FONT_REGULAR: Absolute path to a regular TrueType font file.
  • FONT_BOLD: Absolute path to a bold TrueType font file.

Usage

  1. Start the bot:

    uv run python brrrzzt_emoji_bot.py
  2. Send a message to your bot on Telegram.

  3. The message will be processed, formatted as a receipt image, and printed on your thermal printer.

Features

  • Renders emojis correctly using pilmoji.
  • Automatically wraps text to fit the paper width.
  • Formats messages with a header, metadata (sender, time), and body.
  • Restricts usage to specific user IDs.