Skip to content

CleverWild/untis_telegram_bot

Repository files navigation

untis_telegram_bot

A service Telegram bot that periodically fetches schedules from Untis and posts status/notifications to a target chat. The workspace is split into three crates for clean layering:

Techniques used

  • Active Record pattern on Diesel models: instance methods like insert(), update(), reload(), delete() in db/src/models.rs simplify data lifecycle and keep call sites clean.
  • Optimistic concurrency: update_optimistic(expected_updated_at, changeset) gates updates on a version check (updated_at), reducing contention while preserving correctness.
  • Lazy, global connection pool via OnceCell + r2d2 in db/src/diesel_impl.rs, providing a single thread‑safe pool for the process.
  • Hybrid transport: JSON‑RPC for most methods, but direct REST for homeworks in untis/src/client.rs, extending beyond the public RPC surface.
  • Structured async logging with environment‑driven filters (tracing + tracing-subscriber) and different production/debug formatters in src/main.rs.
  • Worker orchestration with Tokio JoinSet: observer loop starts/stops workers based on DB state; crashed workers are restarted in the next tick.
  • Periodic data hygiene: a daily cleanup task removes outdated lessons to keep tables lean.
  • JSON encoding/decoding via serde with hand‑rolled JSON‑RPC envelopes in untis/src/jsonrpc.rs. For general JSON concepts see MDN JSON docs.
  • Cookie handling and DNS options with reqwest (cookies, hickory‑dns). MDN reference for HTTP cookies: MDN HTTP cookies. For date/time concepts in client platforms, see MDN Intl.DateTimeFormat.

Notable libraries and tech

Source links referenced

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages