allygator / fred-for-discord

The fam has moved to Discord so we are reincarnating Fred to Discord as well
MIT License
2 stars 1 forks source link

Add reminder support #24

Open allygator opened 4 years ago

allygator commented 4 years ago

This might not be possible with the current setup, but support for "fred remind X to Y in Z (time unit)" has been requested.

SammyIsra commented 4 years ago

If we approach this we're getting into hosted DB territory which would be over our budget of "however much electricity the Pi consumes"

allygator commented 4 years ago

We could host a database on the pi, online options could also include firebase maybe?

asasine commented 4 years ago

SQLite is usually pretty easy to configure for local storage. It could track four things:

Finding overdue and incomplete reminders is then a simple SQL query where Z >= NOW && !Complete

For normal operation, we set a timer for every incomplete reminder, send a ping when the timer wakes up, and mark the reminder as complete in the DB. Alternatively, we can use a timer on a fixed interval (e.g. 1 minute) that scans for incomplete, overdue reminders and sends at that time. You might get some inorganic batching this way if there are multiple reminders within the same interval (but were actually seconds apart in real life).

For times that become overdue when fred is down, we don't need hosting if late reminders are acceptable. On startup, fred can check for all that have not been reminded and are overdue and ping with a polite "Whoops! Bots need vacations too. Here's your [reminder]."