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.
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
-
Clone the repository:
git clone <repository-url> cd the-telegram-telegram
-
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
-
Start the bot:
uv run python brrrzzt_emoji_bot.py
-
Send a message to your bot on Telegram.
-
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.
