Permalink
Browse files

Revised syntax

  • Loading branch information...
1 parent 6beff89 commit b03b85a2de563f1ef49376f8e0f96b56dd7503d9 @rehandalal rehandalal committed Oct 2, 2012
Showing with 22 additions and 32 deletions.
  1. +19 −25 standup-irc.js
  2. +3 −7 utils.js
View
@@ -269,31 +269,6 @@ var commands = {
}
},
- 'comment': {
- func: function(user, channel, message, reply_to) {
- utils.ifAuthorized(user, channel, function() {
- var project = null;
-
- if (user !== channel) {
- project = args[0];
- if (project[0] === '#') {
- project = project.slice(1);
- }
- }
-
- var response = api.status.create(user, project, message, reply_to);
-
- response.once('ok', function(data) {
- utils.talkback(channel, user, 'Ok, commented on #' + reply_to + ' with #' + data.id);
- });
-
- response.once('error', function(err, data) {
- utils.talkback(channel, user, 'Uh oh, something went wrong.');
- });
- });
- }
- },
-
/* Delete a status by id number. */
'delete': {
help: "Delete a status by id.",
@@ -403,6 +378,25 @@ var commands = {
}
},
+ /* Comment on a status */
+ 're': {
+ help: "Comment on a status",
+ usage: "<id> <comment>",
+ func: function(user, channel, message, args) {
+ utils.ifAuthorized(user, channel, function() {
+ var response = api.status.create(user, null, args.slice(1).join(' '), parseInt(args[0]));
+
+ response.once('ok', function(data) {
+ utils.talkback(channel, user, 'Ok, commented on #' + args[0] + ' with #' + data.id);
+ });
+
+ response.once('error', function(err, data) {
+ utils.talkback(channel, user, 'Uh oh, something went wrong.');
+ });
+ });
+ }
+ },
+
/* Create a status. */
'status': {
usage: "<project> status message",
View
@@ -128,13 +128,9 @@ exports.respond = function(message, user, channel, commands) {
// message = "!cmd arg1 arg2 arg3"
var cmd_name = message.split(' ')[0].slice(1);
var args = message.split(' ').slice(1);
- if (_.isFinite(parseInt(cmd_name)) && (parseInt(cmd_name) == cmd_name)) {
- commands['comment'].func(user, channel, args.join(' '), cmd_name);
- } else {
- args = this.parseArgs(args);
- var cmd = commands[cmd_name] || commands['default'];
- cmd.func(user, channel, message, args);
- }
+ args = this.parseArgs(args);
+ var cmd = commands[cmd_name] || commands['default'];
+ cmd.func(user, channel, message, args);
} else {
if (message.toLowerCase() === 'botsnack') {
// Special case for botsnack

0 comments on commit b03b85a

Please sign in to comment.