From e8c46e20ad2520341d0bbf7ee690475afe6d4b8f Mon Sep 17 00:00:00 2001 From: taikai <297.1951@gmail.com> Date: Mon, 25 Aug 2014 20:07:42 +0900 Subject: [PATCH 1/2] Fixes a bug when parse payload from github --- example/bots/github.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/bots/github.js b/example/bots/github.js index e065295..be1de3b 100644 --- a/example/bots/github.js +++ b/example/bots/github.js @@ -1,7 +1,7 @@ module.exports = function (chabot) { // WebHook で受けたデータをセット - var payload = JSON.parse(chabot.data.payload); + var payload = chabot.data; // ChatWork API の endpoint をセット var endpoint = '/rooms/' + chabot.roomid + '/messages'; // templats/ 内のメッセージテンプレートを読み込む @@ -20,4 +20,4 @@ module.exports = function (chabot) { .fail(function (err) { chabot.error(err); }); -}; \ No newline at end of file +}; From 470f587102c19ac015b183b9120b7c6d7957ac87 Mon Sep 17 00:00:00 2001 From: taikai <297.1951@gmail.com> Date: Wed, 27 Aug 2014 18:42:24 +0900 Subject: [PATCH 2/2] Pass request headers to bot for judging events --- lib/bots.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bots.js b/lib/bots.js index c67e462..e55251f 100644 --- a/lib/bots.js +++ b/lib/bots.js @@ -31,6 +31,7 @@ fs.readdirSync(path.join(process.cwd(), 'bots')).forEach(function (botfile) { roomid: req.params.roomid, data: req.body, render: ejs.render, + headers: req.headers, readTemplate: function (filepath) { return fs.readFileSync(path.join('./templates/', filepath), 'utf8'); }, @@ -42,4 +43,4 @@ fs.readdirSync(path.join(process.cwd(), 'bots')).forEach(function (botfile) { }; console.log('loaded bot: '.green + botname); -}); \ No newline at end of file +});