Permalink
Browse files

implemented signup and updated readme to mark implemented features

  • Loading branch information...
1 parent b0f2ff4 commit 231df40d7d072bed3104b63d55305c2ea1166441 @nikhilm committed Jul 4, 2011
Showing with 27 additions and 6 deletions.
  1. +5 −5 README.md
  2. +22 −1 lunchbot.js
View
@@ -12,10 +12,10 @@ How
All commands require you to explicitly mention lunchbot at the beginning of the line,
either as 'lunchbot:' or 'lunchbot'
-1) ask everyone in channel for lunch
+1) ask everyone in channel for lunch [IMPLEMENTED]
- ask everyone
-2) ask ops for lunch (At mozilla, all current interns have ops)
+2) ask ops for lunch (At mozilla, all current interns have ops) [IMPLEMENTED]
- ask ops
3) express interest in lunch
@@ -25,7 +25,7 @@ either as 'lunchbot:' or 'lunchbot'
once you do this you will be pinged for lunch regardless of you signing up for alarms
or exclusion.
-4) create a lunch time and ping everyone interested at that time (this is pretty useless without options)
+4) create a lunch time and ping everyone interested at that time (this is pretty useless without options) [IMPLEMENTED]
- lunch at HH:MM [+options] [message]
eg. lunch at 12:30 at Le Boulanger
@@ -37,8 +37,8 @@ Options:
5) view lunch times
- lunches
-6) signup for a lunch time
-- signup for HH:MM
+6) signup for a lunch time [IMPLEMENTED]
+- signup HH:MM with <nick>
You will be pinged 5 minutes before the time.
View
@@ -22,7 +22,11 @@ LunchTime.prototype.add = function(by, message) {
this._list.push({by: by, message: message, signups: []});
}
-LunchTime.prototype.signup = function(with_) {
+LunchTime.prototype.signup = function(nick, with_) {
+ for (var i = 0; i < this._list.length; i++) {
+ if (this._list[i].by == with_)
+ this._list[i].signups.push(nick);
+ }
}
LunchTime.prototype.notify = function() {
@@ -99,13 +103,30 @@ lunches: function(command) {
lunchesStr += lunchtime;
}
conn.privmsg(command.options.channel, lunchesStr);
+},
+
+signup: function(command) {
+ var args = command.unshifted();
+ var time = args[0];
+ var match = time.match(/^(0?[0-9]|1[0-9]|2[0-3]):(0[0-9]|[1-5][0-9])$/);
+ if (!match)
+ conn.privmsg(command.options.channel, sanitizeNick(command.options.nick) + ': invalid time');
+ if (!(args[1] == 'with'))
+ conn.privmsg(command.options.channel, sanitizeNick(command.options.nick) + ': invalid syntax');
+
+ if (!args[2])
+ conn.privmsg(command.options.channel, sanitizeNick(command.options.nick) + ': with whom?');
+
+ if (lunches[time])
+ lunches[time].signup(command.options.nick, args[2]);
}
};
var dispatcher = cmd.use({
'ask': commands.ask,
'lunch': commands.lunch,
'lunches': commands.lunches,
+ 'signup': commands.signup,
_unhandled: function(cmd) {
console.log("don't understand", cmd);
}

0 comments on commit 231df40

Please sign in to comment.