Framework changes

This commit is contained in:
Kegan Myers 2014-08-09 17:20:03 -05:00
parent 4f9da70120
commit 283dddfac9
2 changed files with 27 additions and 7 deletions

View file

@ -1,11 +1,31 @@
var _ = require('lodash');
module.exports = function(configuration) { module.exports = function(configuration) {
return function(ee) { var listenOn = (function(name) {
ee.on('roll', function(slack) { switch (typeof name) {
case "string":
return [name];
case "object":
if (name instanceof Array) {
return name;
}
//fallthrough
default:
return ["phrase"];
}
})(configuration.command);
function handler(slack) {
try { try {
slack.replyUser(slack.text); slack.replyUser(slack.text);
} catch (e) { } catch (e) {
slack.error(e.toString()); slack.error(e.toString());
} }
}
return function(ee) {
_.forEach(listenOn, function(commandName) {
ee.on(commandName, handler);
}); });
}; };
}; };

View file

@ -1,6 +1,6 @@
{ {
"name": "slack-phrase-command", "name": "slack-phrase-command",
"version": "0.0.0", "version": "0.0.1",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {