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) {
var listenOn = (function(name) {
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 {
slack.replyUser(slack.text);
} catch (e) {
slack.error(e.toString());
}
}
return function(ee) { return function(ee) {
ee.on('roll', function(slack) { _.forEach(listenOn, function(commandName) {
try { ee.on(commandName, handler);
slack.replyUser(slack.text);
} catch (e) {
slack.error(e.toString());
}
}); });
}; };
}; };

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": {