Created
June 27, 2014 09:48
-
-
Save saboyutaka/6b939233ab64b8bbf711 to your computer and use it in GitHub Desktop.
新しく作られたissueをidobata-hubotで表示するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date-utils' | |
_ = require 'lodash' | |
github = require 'githubot' | |
getSince = -> | |
date = Date.today() | |
if date.getDay() is 1 | |
date.addDays -3 # since Friday if today is Monday | |
else | |
date.addDays -1 | |
module.exports = (robot) -> | |
robot.respond /new issues/, (msg) -> | |
return msg.send 'HUBOT_GITHUB_TOKEN is unset' unless process.env.HUBOT_GITHUB_TOKEN | |
return msg.send 'HUBOT_GITHUB_REPO is unset' unless process.env.HUBOT_GITHUB_REPO | |
repo = process.env.HUBOT_GITHUB_REPO | |
url = "https://api.github.com/repos/#{repo}/issues" | |
sinceDate = getSince() | |
criteria = | |
status: 'open' | |
since: sinceDate.toFormat('YYYY-MM-DDTHH:MM:SSZ') | |
github.get url, criteria, (issues) -> | |
reponse = ["Newly Opened Issues since #{sinceDate.toFormat('MM-DD')}"] | |
_.each issues, (issue) -> | |
reponse.push "#{issue.user.login} ##{issue.number} #{issue.created_at}\n#{issue.title}\n#{issue.html_url}" | |
msg.send reponse.join('\n\n') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment