Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit 9eb44cf

Browse files
committed
Merge pull request #303 from tenfef/master
Added a Github Issue Link Generator. (Listens for #xxx and links to that issue number for your default Github Repo)
2 parents a5149ea + 8c6e1e0 commit 9eb44cf

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/scripts/github-issue-link.coffee

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Github issue link looks for #nnn and links to that issue for your default repo. Eg. "Hey guys check out #273"
2+
# Requires vars HUBOT_GITHUB_REPO, and HUBOT_GITHUB_TOKEN to be set.
3+
#
4+
# Listens for #nnn and links to the issue for your default repo on github
5+
6+
module.exports = (robot) ->
7+
robot.hear /.*(#(\d+)).*/, (msg) ->
8+
issue_number = msg.match[1].replace /#/, ""
9+
if isNaN(issue_number)
10+
return
11+
12+
bot_github_repo = process.env.HUBOT_GITHUB_REPO
13+
oauth_token = process.env.HUBOT_GITHUB_TOKEN
14+
issue_title = ""
15+
msg.http("https://api.github.com/repos/#{bot_github_repo}/issues/" + issue_number)
16+
.headers(Authorization: "token #{oauth_token}", Accept: "application/json")
17+
.get() (err, res, body) ->
18+
19+
if err
20+
return
21+
22+
issue_obj = JSON.parse(body)
23+
issue_title = issue_obj.title
24+
msg.send "Issue " + issue_number + ": " + issue_title + " http://github.com/" + bot_github_repo + '/issues/' + issue_number

0 commit comments

Comments
 (0)