Skip to content

Conversation

@laurentiuNiculae
Copy link
Contributor

Hi

This PR adds a minimal implementation for reminder command.

Usage

!addreminder <duration> <Reminder text>

Example

!addreminder 30m30s Prepare for stream.

Effect

After 30 minutes and 30 seconds the bot will ping the Author with the message.

Known problems

Reminders are lost at server restart, they need to be persisted in the DB.

To keep the scope of this PR small I haven't included this addition yet.

type UserId = string

var mutex = &sync.Mutex{}
var reminders = map[UserId]context.CancelFunc{}
Copy link
Member

@rexim rexim Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem I see with this approach is that reminders do not survive the bot restart. We should store the reminders in the database. We should also just have a single goroutine that queries the database periodically for fired off reminders.

Maybe the resolution of the duration should be one minute? Querying the database every minute instead of every second is much better plus reminders that fire off within seconds are useless anyway.

What do you think?

UPD. Ah, I see, you mentioned the persistence in the description, sorry. I read it after the code 4Head. I feel persistence is important in this case. Cause people may start adding very long reminders which have very high probability of being lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the observations!

I have finalized the integration with the database. Reminders are now stored persistently.

We poll for overdue reminders every minute, send them, and then clean up their entries in the database.

Commands added

We have the main remind command that adds a new reminder based on the delay specified:

  • !remind 20m Hello reminder world!

To complement it, i've added these 2 helper functions for managing reminders:

  • !reminders: Displays all available reminders, their index in the user's reminder list, and the time remaining until they trigger. Reminders are sorted by the soonest to fire.
  • !delreminder: Deletes unwanted reminders based on the index provided by the !reminders command.

Notes

Some decision I took that you might want to reconsider:

  • All users can have at max 5 reminders
  • Reminder body size is limited to 256 runes
  • Reminder pooling interval is 1 minute
  • The bot sends all reminder messages in #bot-shrine discord channel

Thank you for your time reviewing this addition!

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