diff --git a/Dockerfile b/Dockerfile index 42f05ea..6651255 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ FROM node:latest -RUN mkdir /bot +RUN mkdir /bot && cd /bot ADD . /bot EXPOSE 9999 -CMD cd /bot; bin/hubot --adapter slack +WORKDIR /bot + +CMD ["bin/hubot", "--adapter", "slack"] diff --git a/README.md b/README.md index 54ecf9b..3e65e7b 100644 --- a/README.md +++ b/README.md @@ -99,8 +99,7 @@ Where `` is the name of your adapter without the `hubot-` prefix. [hubot-adapters]: https://github.com/github/hubot/blob/master/docs/adapters.md -fennecbot -========= +# fennecbot ### Installation @@ -111,11 +110,21 @@ docker build -t fenneclab/fennecbot . ### Run ``` -docker run -e HUBOT_SLACK_TOKEN="***" \ - -e HUBOT_SLACK_TEAM="***" \ - -e HUBOT_SLACK_BOTNAME="fennec.bot" \ +docker run -e HUBOT_SLACK_TOKEN="${HUBOT_SLACK_TOKEN}" \ + -e HUBOT_SLACK_TEAM="${HUBOT_SLACK_TEAM}" \ + -e HUBOT_SLACK_BOTNAME="${HUBOT_SLACK_BOTNAME}" \ -e PORT=9999 \ + -e HUBOT_REDMINE_BASE_URL="${HUBOT_REDMINE_BASE_URL}" \ + -e HUBOT_REDMINE_TOKEN="${HUBOT_REDMINE_TOKEN}" \ -d -p 9999:9999 \ -v "$(pwd)":/bot \ fenneclab/fennecbot + +# or shell mode +docker run -v "$(pwd)":/bot \ + -it -p 9999:9999 \ + -e HUBOT_REDMINE_TOKEN="${HUBOT_REDMINE_TOKEN}" \ + -e HUBOT_REDMINE_BASE_URL="${HUBOT_REDMINE_BASE_URL}" \ + fenneclab/fennecbot \ + bin/hubot ``` diff --git a/hubot-scripts.json b/hubot-scripts.json index 2e8ac37..e583b38 100644 --- a/hubot-scripts.json +++ b/hubot-scripts.json @@ -1,4 +1,3 @@ [ - "google.coffee", - "redmine.coffee" + "google.coffee" ] diff --git a/package.json b/package.json index 825f7f2..90afff1 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "hubot-redis-brain": "0.0.2", "hubot-scripts": "^2.5.16", "hubot-slack": "^2.2.0", - "hubot-youtube": "^0.1.2" + "hubot-youtube": "^0.1.2", + "request": "^2.47.0" }, "engines": { "node": "0.10.x" diff --git a/scripts/example.coffee b/scripts/example.coffee deleted file mode 100644 index 989018a..0000000 --- a/scripts/example.coffee +++ /dev/null @@ -1,106 +0,0 @@ -# Description: -# Example scripts for you to examine and try out. -# -# Notes: -# They are commented out by default, because most of them are pretty silly and -# wouldn't be useful and amusing enough for day to day huboting. -# Uncomment the ones you want to try and experiment with. -# -# These are from the scripting documentation: https://github.com/github/hubot/blob/master/docs/scripting.md - -module.exports = (robot) -> - - # robot.hear /badger/i, (msg) -> - # msg.send "Badgers? BADGERS? WE DON'T NEED NO STINKIN BADGERS" - # - # robot.respond /open the (.*) doors/i, (msg) -> - # doorType = msg.match[1] - # if doorType is "pod bay" - # msg.reply "I'm afraid I can't let you do that." - # else - # msg.reply "Opening #{doorType} doors" - # - # robot.hear /I like pie/i, (msg) -> - # msg.emote "makes a freshly baked pie" - # - # lulz = ['lol', 'rofl', 'lmao'] - # - # robot.respond /lulz/i, (msg) -> - # msg.send msg.random lulz - # - # robot.topic (msg) -> - # msg.send "#{msg.message.text}? That's a Paddlin'" - # - # - # enterReplies = ['Hi', 'Target Acquired', 'Firing', 'Hello friend.', 'Gotcha', 'I see you'] - # leaveReplies = ['Are you still there?', 'Target lost', 'Searching'] - # - # robot.enter (msg) -> - # msg.send msg.random enterReplies - # robot.leave (msg) -> - # msg.send msg.random leaveReplies - # - # answer = process.env.HUBOT_ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE_THE_UNIVERSE_AND_EVERYTHING - # - # robot.respond /what is the answer to the ultimate question of life/, (msg) -> - # unless answer? - # msg.send "Missing HUBOT_ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE_THE_UNIVERSE_AND_EVERYTHING in environment: please set and try again" - # return - # msg.send "#{answer}, but what is the question?" - # - # robot.respond /you are a little slow/, (msg) -> - # setTimeout () -> - # msg.send "Who you calling 'slow'?" - # , 60 * 1000 - # - # annoyIntervalId = null - # - # robot.respond /annoy me/, (msg) -> - # if annoyIntervalId - # msg.send "AAAAAAAAAAAEEEEEEEEEEEEEEEEEEEEEEEEIIIIIIIIHHHHHHHHHH" - # return - # - # msg.send "Hey, want to hear the most annoying sound in the world?" - # annoyIntervalId = setInterval () -> - # msg.send "AAAAAAAAAAAEEEEEEEEEEEEEEEEEEEEEEEEIIIIIIIIHHHHHHHHHH" - # , 1000 - # - # robot.respond /unannoy me/, (msg) -> - # if annoyIntervalId - # msg.send "GUYS, GUYS, GUYS!" - # clearInterval(annoyIntervalId) - # annoyIntervalId = null - # else - # msg.send "Not annoying you right now, am I?" - # - # - # robot.router.post '/hubot/chatsecrets/:room', (req, res) -> - # room = req.params.room - # data = JSON.parse req.body.payload - # secret = data.secret - # - # robot.messageRoom room, "I have a secret: #{secret}" - # - # res.send 'OK' - # - # robot.error (err, msg) -> - # robot.logger.error "DOES NOT COMPUTE" - # - # if msg? - # msg.reply "DOES NOT COMPUTE" - # - # robot.respond /have a soda/i, (msg) -> - # # Get number of sodas had (coerced to a number). - # sodasHad = robot.brain.get('totalSodas') * 1 or 0 - # - # if sodasHad > 4 - # msg.reply "I'm too fizzy.." - # - # else - # msg.reply 'Sure!' - # - # robot.brain.set 'totalSodas', sodasHad+1 - # - # robot.respond /sleep it off/i, (msg) -> - # robot.brain.set 'totalSodas', 0 - # robot.respond 'zzzzz' diff --git a/scripts/redmine.coffee b/scripts/redmine.coffee new file mode 100644 index 0000000..8c32da8 --- /dev/null +++ b/scripts/redmine.coffee @@ -0,0 +1,34 @@ +# Description: +# Redmineにチケットを登録する +# +# Configuration: +# HUBOT_REDMINE_BASE_URL +# HUBOT_REDMINE_TOKEN +# +# Commands: +# hubot redmine create - RedmineのBuddyプロジェクトにチケットを登録します +# +# Author: +# satoshun00 + +request = require 'request' + +module.exports = (robot) -> + robot.respond /redmine create (.+)$/i, (msg) -> + data = + issue: + project_id: 'Buddy' + subject: msg.match[1] + url = process.env.HUBOT_REDMINE_BASE_URL.replace /\/$/, '' + request + url: url + '/issues.json' + method: 'POST' + headers: + Accept: 'application/json' + "X-Redmine-API-Key": process.env.HUBOT_REDMINE_TOKEN + json: true + body: data + , (err, res, body) -> + msg.send '@satoshun00 Redmineのチケット作成に失敗したよ =͟͟͞͞((☞ ՞ਊ ՞)☞' + err if err? + if body? + msg.send '◜◡‾)◞つくたよ http://redmine.fenneclab.com/issues/' + body.issue.id