Skip to content

Commit

Permalink
Add github integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
miyukki committed Apr 9, 2015
1 parent bee5090 commit adc5996
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"description": "Arch Bot",
"dependencies": {
"cron": "^1.0.5",
"github": "^0.2.3",
"hubot": "^2.11.0",
"hubot-diagnostics": "0.0.1",
"hubot-google-images": "^0.1.2",
Expand Down
26 changes: 26 additions & 0 deletions scripts/bento.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
github = new (require 'github')
version: '3.0.0'
github.authenticate type: 'token', token: process.env['GITHUB_API_TOKEN']

module.exports = (robot) ->
robot.brain.autoSave = true

robot.hear /^bento\s+create\s+(.*?)\s+(.+)$/, (msg) ->
date = msg.match[1]
shop = msg.match[2]

body =
switch shop
when 'デリカ', '木の子', 'デリカ木の子'
'デリカ木の子 http://web.sfc.wide.ad.jp/~miyukki/rg/kinoko.pdf'
when '大戸屋'
'大戸屋 https://www.ootoya.com/menu.asp?bcid=1&tcid=8'
else
shop

github.issues.create
user: 'sfc-arch'
repo: 'reading'
title: "#{date} 輪講会お弁当調査"
body: ":bento: 今週のお店 #{body}"
labels: ['question']
, (err, result) ->
msg.send "@channel :bento: #{date} 輪講会お弁当調査 #{result.html_url}"

robot.respond /(.*(bento|:bento:|?弁当).*)/i, (msg) ->
user = robot.brain.userForId(msg.message.user.id)
user.lastBento = msg.match[1]
Expand Down
15 changes: 15 additions & 0 deletions scripts/github.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
github = new (require 'github')
version: '3.0.0'
github.authenticate type: 'token', token: process.env['GITHUB_API_TOKEN']

module.exports = (robot) ->
robot.hear /^issue\s+(.+)$/, (msg) ->
title = msg.match[1]

github.issues.create
user: 'sfc-arch'
repo: 'documents'
title: title
labels: []
, (err, result) ->
msg.send "@#{msg.message.user.name} :ticket: #{result.html_url}"

0 comments on commit adc5996

Please sign in to comment.