Files

116 lines
5.6 KiB
Markdown

---
name: brother-printer
description: Print PDF documents, text, and files directly to the Brother HL-L8240CDW duplex color laser printer at Grabengasse 7 (192.168.10.91). Handles interactive Telegram print options (Color/B&W, Pages per Sheet / N-Up, Duplex/Simplex) and live-updating Telegram status messages.
---
# 🖨️ Brother HL-L8240CDW Laser Printer
Direct network printing to the **Brother HL-L8240CDW** duplex color laser printer on the home network (`192.168.10.91:631`) via IPP Everywhere.
## 🎯 When to Use
- Whenever the user asks to print something: *"Bitte drucke XY"*, *"Druck das bitte aus"*, *"Kannst du das drucken?"*.
- Whenever the user sends a PDF, image, document, or ticket on Telegram with a request to print.
- Whenever the user asks to print recipes, shopping lists, flight tickets, packing lists, or notes.
- Whenever the user asks for printer status or toner levels: *"Wie viel Toner ist noch im Drucker?"*, *"Ist der Drucker online?"*.
---
## 🕹️ Interactive Telegram Options Protocol (CRITICAL)
When the user requests a print without specifying options (e.g. *"Bitte drucke die Rechnung"* or sends a PDF):
- **Single Invocation**: Call `ask_user` exactly ONCE. Do NOT print duplicate text option lists in the chat; `ask_user` renders the interactive buttons natively.
- **Skip if Already Specified**: If the user already gave preferences in their prompt (e.g. *"Druck das in Farbe"*, *"Drucke das bitte schwarz-weiß beidseitig auf 2 Seiten"*), **DO NOT call `ask_user`** — execute the print job immediately with their specified options!
- **Never Duplicate or Retry**: Once `ask_user` is sent, wait for the user to tap an option. Never re-trigger `ask_user` for the same document.
### Fast-Path Preset Menu via `ask_user`
Call `ask_user` with:
- `id`: `"print_options"`
- `header`: `"Drucker"`
- `question`: `"Wie möchtest du das Dokument drucken?"`
- `options`:
1. `label`: `"🌱 Spar-Druck: S/W, 2 Seiten, Duplex (Recommended)"`
`description`: `"Schwarz-Weiß, 2 Seiten pro Blatt, beidseitig (spart Papier)"`
*(Maps to: `--color monochrome --nup 2 --duplex two-sided-long-edge`)*
2. `label`: `"📄 Standard: S/W, 1 Seite, Duplex"`
`description`: `"Schwarz-Weiß, 1 Seite pro Blatt, beidseitig"`
*(Maps to: `--color monochrome --nup 1 --duplex two-sided-long-edge`)*
3. `label`: `"🎨 Vollfarbe: 1 Seite, Duplex"`
`description`: `"Farbdruck, 1 Seite pro Blatt, beidseitig"`
*(Maps to: `--color color --nup 1 --duplex two-sided-long-edge`)*
4. `label`: `"📄 Einseitig (Simplex): S/W, 1 Seite"`
`description`: `"Schwarz-Weiß, 1 Seite pro Blatt, nur Vorderseite"`
*(Maps to: `--color monochrome --nup 1 --duplex one-sided`)*
---
## 📍 Active Conversation & Thread Routing (CRITICAL)
**Never hardcode a chat ID!** To ensure status updates appear in the exact conversation and topic where requested (whether requested by Moritz, Amelie, or in a group topic like the Mila topic):
1. **`--chat-id`**: Set to the CURRENT session's chat ID (e.g. `-1004326921510` for group chat, or user ID if in private DM).
2. **`--thread-id`**: If the incoming message came from a forum topic / thread (e.g. `threadId: 22` / `message_thread_id: 22`), **YOU MUST PASS `--thread-id <threadId>`**. Without `--thread-id`, Telegram routes messages to the General topic instead of the active conversation thread!
---
## 🚀 Execution & Live Telegram Status Updates
Execute the bundled driver script with `uv run`:
### 1. Print a PDF file with selected options (in a topic or group)
```bash
uv run /home/node/mop-skills/mop-skills/skills/brother-printer/scripts/brother_printer.py print \
--file "/home/node/.openclaw/workspace/document.pdf" \
--color monochrome \
--nup 2 \
--duplex two-sided-long-edge \
--chat-id "<current_chat_id>" \
--thread-id "<current_thread_id>"
```
### 2. Print a document from a URL
```bash
uv run /home/node/mop-skills/mop-skills/skills/brother-printer/scripts/brother_printer.py print \
--url "https://example.com/ticket.pdf" \
--title "Konzertticket" \
--color color \
--nup 1 \
--duplex two-sided-long-edge \
--chat-id "<current_chat_id>"
```
### 3. Print plain text or notes
```bash
uv run /home/node/mop-skills/mop-skills/skills/brother-printer/scripts/brother_printer.py print \
--text "Einkaufsliste für Samstag:\n- Hafermilch\n- Kaffee\n- Bananen" \
--title "Einkaufszettel" \
--color monochrome \
--nup 1 \
--duplex one-sided \
--chat-id "<current_chat_id>"
```
### 4. Check status & toner levels
```bash
uv run /home/node/mop-skills/mop-skills/skills/brother-printer/scripts/brother_printer.py status
```
---
## ⚙️ CLI Options Reference
| Argument | Values / Type | Default | Description |
|---|---|---|---|
| `--file` | File path | None | Local PDF path to print |
| `--url` | URL string | None | Download and print PDF from web |
| `--text` | String | None | Text content to format as A4 PDF and print |
| `--title` | String | Basename | Document title for print queue and Telegram header |
| `--color` | `monochrome`, `color` | `monochrome` | Print color mode |
| `--nup` | `1`, `2`, `4` | `1` | Hardware pages per sheet (1 = normal, 2 = 2 pages/sheet) |
| `--duplex` | `two-sided-long-edge`, `one-sided`, `two-sided-short-edge` | `two-sided-long-edge` | Duplex binding mode |
| `--copies` | Integer | `1` | Number of printed copies |
| `--chat-id` | Telegram Chat ID | None | Target chat ID for live status updates (use current chat) |
| `--thread-id` | Integer | None | Target forum topic / message thread ID (mandatory for topics) |
| `--max-pages`| Integer | `30` | Safety limit to prevent runaway printing |
| `--force` | Flag | `false` | Bypass page limit |