Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prashanth-sams/3389ea9ea475473e64acd887616aee7e to your computer and use it in GitHub Desktop.
Save prashanth-sams/3389ea9ea475473e64acd887616aee7e to your computer and use it in GitHub Desktop.
GitHub closed issues 1 - Chatbot
# 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