Skip to content

Instantly share code, notes, and snippets.

@rahulsom
Created April 12, 2015 03:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulsom/ffe4c2d8e1f3890e0475 to your computer and use it in GitHub Desktop.
Save rahulsom/ffe4c2d8e1f3890e0475 to your computer and use it in GitHub Desktop.
Hubot lgtm script
# Description:
# When someone says LGTM, presents an image from LGTM.in
#
# Will ignore users set in HUBOT_LGTM_IGNORE_USERS (by default, none).
#
# Dependencies:
# None
#
# HUBOT_LGTM_IGNORE_USERS (optional, format: "user1|user2", default "lgtm|jira")
#
# Commands:
#
# Author:
# rahulsom
module.exports = (robot) ->
lgtmPattern = /.*(lgtm|looks good to me).*/gi
lgtmIgnoreUsers = process.env.HUBOT_LGTM_IGNORE_USERS
if lgtmIgnoreUsers == undefined
lgtmIgnoreUsers = "lgtm|jira"
robot.hear eval(lgtmPattern), (msg) ->
return if msg.message.user.name.match(new RegExp(lgtmIgnoreUsers, "gi"))
msg.http('http://www.lgtm.in/g/rahulsom')
.headers(Accept: 'application/json')
.get() (err, response, body) ->
json = JSON.parse(body)
msg.send json.actualImageUrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment