planbot (0.1.0)

Published 2026-04-04 22:52:51 +02:00 by goeranh in goeranh/planbot

Installation

[registries.forgejo]
index = "sparse+" # Sparse index
# index = "" # Git

[net]
git-fetch-with-cli = true
cargo add planbot@0.1.0 --registry forgejo

About this package

Planbot

A Rust CLI tool that syncs dhsn schedule events from planlos.dd.dhsn.de to Nextcloud calendars via CalDAV. Scrapes iCal links from HTML pages, fetches events, and keeps your calendar up-to-date with intelligent sync logic.

How It Works

Planbot scrapes an HTML page to find an iCal download link, fetches the calendar events, and syncs them to a Nextcloud calendar via CalDAV. It tracks event state using content hashes to detect changes between runs, minimizing unnecessary updates and duplicate events.

The sync algorithm compares events by their UID: new events are added, modified events are updated (based on content hash), and removed events are optionally deleted from your calendar. Events are filtered to include only future occurrences starting from today.

For week-based calendars (URLs with ?woche= parameter), planbot automatically fetches multiple weeks ahead, deduplicating events and stopping after detecting two consecutive empty weeks or reaching the maximum fetch limit.

Operation Modes

One-shot Mode (default): Run once and exit, perfect for cron jobs or systemd timers. Configure your schedule source and target calendar, then run manually or via scheduled tasks.

Daemon Mode: Continuous operation with configurable sync intervals. Ideal for Docker containers and Kubernetes deployments. Handles graceful shutdown and continues running after transient errors.

NixOS Integration: Native NixOS module with systemd service/timer, security hardening, credential management, and automatic firewall configuration. Supports both oneshot and daemon modes.

Quick Start

# Build and run
cargo build --release
./target/release/planbot --config config.toml

# Or with Nix
nix run . -- --config config.toml

# List available calendars
planbot --list-calendars

# Preview changes without modifying calendar
planbot --dry-run

Configuration

See config.example.toml for one-shot/cron mode and config.daemon.example.toml for daemon mode. Store your CalDAV password in the PLANBOT_TARGET_PASSWORD environment variable instead of the config file.

Key settings: source HTML and iCal URLs, CalDAV credentials and calendar name, timezone configuration, sync behavior (delete removed events), state file location, and optional daemon/metrics settings.

Docker Deployment

docker build -t planbot .
docker run -v $(pwd)/config.toml:/config/config.toml:ro \
           -e PLANBOT_TARGET_PASSWORD=your-password \
           -p 9090:9090 \
           planbot --config /config/config.toml

Requires daemon mode enabled in config. Optional Prometheus metrics available on port 9090 for monitoring sync operations.

NixOS Module

services.planbot = {
  enable = true;
  configFile = "/etc/planbot/config.toml";
  passwordFile = "/run/secrets/planbot-password";
  interval = "hourly";  # or set daemonMode = true
};

See nixos-examples/ for complete configuration examples.

Dependencies

ID Version
anyhow ^1.0
chrono ^0.4
chrono-tz ^0.10
clap ^4.5
config ^0.14
env_logger ^0.11
icalendar ^0.17
log ^0.4
prometheus ^0.13
regex ^1.10
reqwest ^0.12
scraper ^0.26
serde ^1.0
serde_json ^1.0
signal-hook ^0.3
tiny_http ^0.12
toml ^0.8
urlencoding ^2.1
Details
Cargo
2026-04-04 22:52:51 +02:00
4
44 KiB
Assets (1)
Versions (1) View all
0.1.0 2026-04-04