Files
2026-07-02 13:06:24 +00:00

87 lines
4.7 KiB
Markdown

*** This project lives @ https://git.rickelobe.com/rich/R0b3BOT ***
# Description
This is R0b3's bot, originally built as a Discord bot to display 3D printer status. It now also runs as a Matrix bot, both operating simultaneously in the same process.
# Features
* Query & Monitor OctoPrint 3D Printer Status using the `$octostat` command (Requires that your printer is connected to [Octoprint](https://octoprint.org/))<br>
![](images/Discord_Printstat_Command.png)
* Query & Monitor Bambu Lab Printer Status using the `$bambustat` command (Requires a Bambu Lab printer accessible on the local network via MQTT)
* Displays print state, progress percentage, time remaining, current layer, bed temp, nozzle temp, and chamber temp
* Optionally captures and attaches a camera snapshot from the printer's RTSPS stream (requires [ffmpeg](https://ffmpeg.org/) on the host)
* Updates the bot's Discord status to show live print progress; alternates between OctoPi and Bambu status every 30 seconds when both printers are running simultaneously
* Query both printers at once using the `$printstat` command
* Play a selection of sound clips to voice channel members using the various commands (`$trololo`, `$oops`, `$promoted`, etc) — Discord only
* **Matrix support** — the bot can connect to a self-hosted Matrix homeserver (Synapse/Dendrite) and respond to the same text commands in E2E-encrypted rooms
# Commands
![Screenshot of $help](images/command_list.png)
All text commands are available on both Discord and Matrix. Sound/voice commands are Discord-only.
# Requirements
Install all Python dependencies using the provided `requirements.txt`:
```
pip install -r requirements.txt
```
Dependencies:
- `discord.py[voice]` >= 2.6.4 — Discord bot framework (voice support included)
- `requests` >= 2.32.3 — HTTP client for HomeAssistant REST API calls
- `bambu-connect` >= 0.3.1 — Bambu Lab printer integration via local MQTT
- `paho-mqtt` >= 2.0 — MQTT client library (required by bambu-connect)
- `matrix-nio[e2e]` >= 0.21 — Matrix bot client with E2E encryption support (optional, only needed if using Matrix)
**Optional: Camera snapshot support**
To enable camera snapshots with `$bambustat`, [ffmpeg](https://ffmpeg.org/) must be installed on the host running the bot. Set `bambu_camera_enable = true` in `bot_config.conf` once ffmpeg is available.
**Optional: Matrix E2E encryption**
Matrix support with E2E encryption requires the `libolm` system library:
```
apt-get install libolm3 # Debian/Ubuntu
```
# Configuration
1. Create a Discord Bot via the [Discord Developer Portal](https://discord.com/developers/applications)
2. Copy `bot_config.conf.example` to `bot_config.conf` and fill in your values (see below)
3. Rename `octoapi.conf.example` to `octoapi.conf` and configure OctoPrint settings (if using OctoPrint)
## bot_config.conf Keys
### [bot-config]
| Key | Description |
|-----|-------------|
| `discord_auth_token` | Bot token from the Discord Developer Console |
| `bot_command_prefix` | Command prefix (e.g. `$`, `!`, `/`) |
| `hass_url` | URL to your Home Assistant instance |
| `hass_token` | Long-lived access token for Home Assistant REST API |
| `hass_light` | Entity ID of the light at your printer |
| `octoprint_ip_address` | IP address of your OctoPrint/OctoPi host |
| `bambu_ip_address` | IP address of your Bambu Lab printer on the local network |
| `bambu_access_code` | Access code shown on the printer screen (Settings > WLAN) |
| `bambu_serial_number` | Serial number of your Bambu Lab printer |
| `bambu_camera_enable` | Set to `true` to capture camera snapshots with `$bambustat` (requires ffmpeg) |
| `statping_enable` | Set to `true` to enable StatPing service status integration |
| `statping_url` | URL of your StatPing instance |
| `statping_api_key` | API key for StatPing |
| `mmr_checker_enable` | Set to `true` to enable MMR checker |
| `mmr_checker_interval` | Seconds between MMR checks |
| `mmr_api_url` | MMR API URL |
### [matrix-config] (optional)
Adding this section enables the Matrix bot. All five keys are required to activate it.
| Key | Description |
|-----|-------------|
| `matrix_homeserver` | Full URL of your Matrix homeserver (e.g. `https://matrix.example.org`) |
| `matrix_user_id` | Full Matrix user ID for the bot account (e.g. `@r0b3bot:example.org`) |
| `matrix_password` | Password for the bot account. Used on first run to register the device; credentials are then saved to `matrix_store_path` and reused on subsequent restarts |
| `matrix_room_ids` | Comma-separated list of room IDs to listen in (e.g. `!abc123:example.org,!def456:example.org`) — use room IDs, not aliases |
| `matrix_store_path` | Directory for the E2E crypto store (Olm sessions, device keys). Default: `./matrix_store/` |