Created
April 12, 2015 03:35
-
-
Save rahulsom/ffe4c2d8e1f3890e0475 to your computer and use it in GitHub Desktop.
Hubot lgtm script
This file contains 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: | |
# 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