From 7d614ea4bd34bb54c93ebd9ba33122714d75b3e9 Mon Sep 17 00:00:00 2001 From: Kegan Myers Date: Sat, 9 Aug 2014 18:11:33 -0500 Subject: [PATCH] Add try methods to response, update readme --- .gitignore | 3 ++- README.md | 2 +- index.js | 23 ++++++++++++++++++++--- package.json | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index b512c09..34977ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +.idea \ No newline at end of file diff --git a/README.md b/README.md index 7a4a918..b60fce2 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,4 @@ slack-command-router This is a simple library that exposes both a way to add event handlers for slack commands, and connect middleware to facilitate the simple addition of a slack command handler to any project. -This project is written as a standalone library, but primarily designed for use in `slack-command-server` \ No newline at end of file +This project is written as a standalone library, but primarily designed for use in [slack-command-server](https://github.com/terribly-lazy/slack-command-server) \ No newline at end of file diff --git a/index.js b/index.js index c97ad11..f7766c8 100644 --- a/index.js +++ b/index.js @@ -34,14 +34,31 @@ _.assign(SlashCommand.prototype, { this._generalReply(); this.res.end(message); }, - replyChannel: function () { - this._generalReply(); - this.res.end(); + tryReplyUser: function(message) { + if (this.hasReplied) + return false; + + this.replyUser(message); + + return true; }, + /* TODO + replyChannel: function () { + this._generalReply(); + this.res.end(); + },*/ error: function (message) { this._generalReply(); this.res.writeHead(400); this.res.end(message); + }, + tryError: function (message) { + if (this.hasReplied) + return false; + + this.error(message); + + return true; } }); diff --git a/package.json b/package.json index bd7e839..b76380f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "slack-command-router", - "version": "0.0.0", + "version": "0.0.1", "description": "A slack slash command handler routing framework", "main": "index.js", "scripts": {