Repository navigation
add !remindme - #42
Merged
Merged
Conversation
!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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.s/sek/sekunde(n),m/min/minute(n),h/std/stunde(n),d/t/tag(e), and combinations like1h 30m.!remindmelists your pending reminders, and!remindme löschen <nr>deletes one.REMINDERS_PATH(defaultreminders.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.ymlnow mounts./data:/dataand setsREMINDERS_PATH=/data/reminders.json. The compose file on the server needs the same change. The NixOS module usesStateDirectory.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 checkrun in CI.🤖 Generated with Claude Code