Skip to content

Commit

Permalink
feat: add snooze buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
dwickr committed Sep 5, 2023
1 parent 694e209 commit 084043c
Show file tree
Hide file tree
Showing 5 changed files with 2,772 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
data/
*.tar.gz
.nyc_output/
software.zip
39 changes: 38 additions & 1 deletion lib/reminder-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,45 @@ class ReminderBot extends WickrBot {
return this.reminders.filter(r => r.vgroupid === vgroupid)
}

_createSnoozeButtons(reminder) {
const reminderText = `${reminder.infinitive ? 'to ' : ''}${reminder.action}`
const snoozeLengths = [
{
buttonText: '20m',
msgText: '20 minutes',
},
{
buttonText: '1h',
msgText: '1 hour',
},
{
buttonText: '3h',
msgText: '3 hours',
},
{
buttonText: '24h',
msgText: '24 hours',
},
]
const properties = {
meta: { buttons: [] }
}

for (const snooze of snoozeLengths) {
properties.meta.buttons.push({
type: 'message',
text: `Snooze ${snooze.buttonText}`,
message: `/remind me in ${snooze.msgText} ${reminderText}`
})
}

return properties
}

sendReminder(reminder) {
this.send(reminder.vgroupid, `You asked me to remind you ${reminder.infinitive ? 'to ' : ''}"${reminder.action}".`)
const properties = this._createSnoozeButtons(reminder)

this.send(reminder.vgroupid, `You asked me to remind you ${reminder.infinitive ? 'to ' : ''}"${reminder.action}".`, properties)
}

deleteReminder(id) {
Expand Down
Loading

0 comments on commit 084043c

Please sign in to comment.