Last active
March 25, 2019 14:51
-
-
Save prashanth-sams/3389ea9ea475473e64acd887616aee7e to your computer and use it in GitHub Desktop.
GitHub closed issues 1 - Chatbot
This file contains hidden or 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
# Description: | |
# Show closed issues from a Github repository | |
# Commands: | |
# hubot closed <assignee> <label> -- Lists all the closed issues with specific label. | |
_ = require("underscore") | |
module.exports = (robot) -> | |
github = require("githubot")(robot) | |
robot.respond /closed (.*) (.*)$/i, (msg) -> | |
query_params = state: "closed", sort: "created" | |
query_params.per_page=100 | |
query_params.assignee = msg.match[1] if msg.match[1]? | |
query_params.labels = msg.match[2] | |
console.log "============" | |
console.log query_params | |
console.log "============" | |
base_url = process.env.HUBOT_GITHUB_API || 'https://api.github.com' | |
github.get "#{base_url}/repos/#{process.env.HUBOT_GITHUB_USER}/#{process.env.HUBOT_GITHUB_REPO}/issues", query_params, (issues) -> | |
if !_.isEmpty issues | |
for issue in issues | |
msg.send "> `issue ##{issue.number}` #{issue.title}" | |
else | |
msg.send "No closed issues with this filter" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment