From 64bffd534e4505d6dbca9217ed9a8fcbeef82dd8 Mon Sep 17 00:00:00 2001 From: amki Date: Sun, 5 Apr 2015 19:34:04 +0200 Subject: [PATCH] Added remind module with ~remind and ~remindme commands --- modules/remind/README.md | 20 +++++++++++ modules/remind/remind.js | 73 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 modules/remind/README.md create mode 100644 modules/remind/remind.js diff --git a/modules/remind/README.md b/modules/remind/README.md new file mode 100644 index 0000000..1eee130 --- /dev/null +++ b/modules/remind/README.md @@ -0,0 +1,20 @@ +## Remind + +Reminder! + +### Description +This module reminds you! + +### TIME +The TIME parameter for this module needs to be in a fashion NdNhNmNs. +Example: 4d3h2m1s +You can give skip parameters if you like. (Example: 4d5m) + +### Commands + +#### ~remind [USER] [TIME] [MESSAGE] +Reminds you in now+TIME with message [MESSAGE] + +#### ~remindme [TIME] [MESSAGE] +Reminds the given user in now+TIME with message [MESSAGE] + diff --git a/modules/remind/remind.js b/modules/remind/remind.js new file mode 100644 index 0000000..ddf1c11 --- /dev/null +++ b/modules/remind/remind.js @@ -0,0 +1,73 @@ +/** + * Module Name: Remind + * Description: Reminds you + */ + +var remind = function(dbot) { + var self = this; + + this.internalAPI = { + 'getSeconds': function(number,interval) { + switch(interval) { + case "d": + return number*24*60*60; + case "h": + return number*60*60; + case "m": + return number*60; + case "s": + return number; + } + }.bind(this), + 'doReminder': function(event,user,time,message) { + var now = Date.now(); + var datesplits = time.match(/[0-9]+[dhms]/g); + if(datesplits == null) { + event.reply("The time parameter was not a valid time mah boy, it was "+time); + return; + } + var timeinseconds = 0; + for(var i=0;i