Framework changes
This commit is contained in:
parent
4f9da70120
commit
283dddfac9
32
index.js
32
index.js
|
@ -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);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "slack-phrase-command",
|
||||
"version": "0.0.0",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in a new issue