From 283dddfac92750e77835e184f4d8959a81d82a9b Mon Sep 17 00:00:00 2001 From: Kegan Myers Date: Sat, 9 Aug 2014 17:20:03 -0500 Subject: [PATCH] Framework changes --- index.js | 32 ++++++++++++++++++++++++++------ package.json | 2 +- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 351e5a0..fb8fd07 100644 --- a/index.js +++ b/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); }); }; }; diff --git a/package.json b/package.json index 5738d99..6bbfb73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "slack-phrase-command", - "version": "0.0.0", + "version": "0.0.1", "description": "", "main": "index.js", "scripts": {