Skip to content

Instantly share code, notes, and snippets.

@ecylmz
Created February 2, 2012 22:09
Show Gist options
  • Save ecylmz/1726109 to your computer and use it in GitHub Desktop.
Save ecylmz/1726109 to your computer and use it in GitHub Desktop.
module.exports = (robot) ->
robot.respond /gist ([0-9]+)/i, (msg) ->
getGist(msg)
robot.hear /https?:\/\/gist\.github\.com\/([0-9]+)/i, (msg) ->
getGist(msg)
getGist = (msg) ->
msg.http("https://api.github.com/gists/#{msg.match[1]}")
.get() (err, res, body) ->
gbody = JSON.parse(body)["files"]
for key of gbody
content = " " + gbody[key]["content"].replace /\n/g, "\n "
msg.send content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment