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

View File

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