Skip to content

add !remindme - #42

Merged
kiliankoe merged 4 commits into
swiftde:mainfrom
mludi:feature/reminder
Nov 6, 2026
Merged

kiliankoe merged 4 commits into
swiftde:mainfrom
mludi:feature/reminder

Conversation

@mludi

@mludi mludi commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Adds !remindme <dauer> [text], e.g. !remindme 2,5h Pizza aus dem Ofen. Once the duration has passed, the bot replies to the original message and pings only its author.

  • Durations: decimals with a comma or point, units s/sek/sekunde(n), m/min/minute(n), h/std/stunde(n), d/t/tag(e), and combinations like 1h 30m.
  • Limits: 30 seconds to 30 days, 5 pending reminders per user, text up to 100 characters.
  • Managing reminders: !remindme lists your pending reminders, and !remindme löschen <nr> deletes one.
  • Persistence: reminders are stored in a JSON file at REMINDERS_PATH (default reminders.json) so they survive the restart on every deploy. Reminders that came due during downtime are delivered on startup with a note on the delay. A corrupt file is moved aside to .corrupt.

Deployment: docker-compose.yml now mounts ./data:/data and sets REMINDERS_PATH=/data/reminders.json. The compose file on the server needs the same change. The NixOS module uses StateDirectory.

Testing: the parser, request validation, message texts and the store (persistence, limit, deletion, overdue delivery, corrupt file) are covered by tests. Tested locally with Swift 6.4 on macOS only; the Linux build and nix flake check run in CI.

🤖 Generated with Claude Code

mludi and others added 4 commits November 5, 2026 21:39
!remindme <duration> [text] replies to the invoking message once the
duration has passed, pinging only its author. Durations accept decimal
commas, German and short unit names and combinations like 1h 30m.
Without an argument it lists the user's pending reminders, and
!remindme löschen <n> deletes one.

Reminders live in a JSON file at REMINDERS_PATH so the restart on every
deploy doesn't drop them; reminders that came due during downtime are
delivered on startup with a note on the delay. docker-compose puts the
file on a volume and the NixOS module in its state directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Anyone who reacted with the alarm clock on the invoking message is
pinged too. The reactions are read at delivery, so nothing is stored
and reactions added during downtime count. DiscordBM drops the limit
parameter, so only Discord's default of 25 users are seen. Used as a
reply, the delivery and the list link the replied-to message.

Reminders now keep a per-user number, so one firing cannot redirect a
deletion to another.

Adding or deleting a reminder now fails visibly when the file cannot be
written, and the reaction only appears after a successful save. A file
that cannot be read is left alone, and adding fails until the next
start. Files without the number field count as corrupt.

The command layer has no tests and has not run against Discord.
Saving and moving the file run under the unit's real sandboxing, which
the store's unit tests cannot cover.
On x86_64 Linux, Swift Testing segfaults capturing a backtrace of the
error a cancelled Task.sleep throws, which fails the Nix build while
macOS and aarch64 pass. The bot itself is not affected, since the hook
exists only in the test library.

The task of a deleted reminder now sleeps until its due time and fire
ignores it, costing a little memory for up to 30 days or until the next
restart. The tests replace .timeLimit, which also cancels a sleep, with
an uncancelled task that ends the stream after a minute.
@kiliankoe
kiliankoe merged commit 09268a7 into swiftde:main Nov 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants