Created
March 2, 2016 07:56
-
-
Save hitode909/5c216a92509b5dc1e900 to your computer and use it in GitHub Desktop.
Registerable Hubot LGTM Command
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: | |
# LGTM | |
# | |
# Commands: | |
# hubot LGTM - LGTM | |
# hubot lgtm register <URL> - register a new LGTM | |
BRAIN_KEY = 'lgtm' | |
module.exports = (robot) -> | |
robot.hear /lgtm register (http.+)/i, (msg) -> | |
image = msg.match[1] | |
images = robot.brain.get(BRAIN_KEY) or [] | |
images.push image | |
robot.brain.set(BRAIN_KEY, images) | |
msg.send "LGTM Registered" | |
robot.hear /lgtm(?:\s*)$/i, (msg) -> | |
default_images = [ | |
'https://i.gyazo.com/a5461fbbc35cc4ecf02738fdfbe1cd06.gif' | |
] | |
images = default_images.concat(robot.brain.get(BRAIN_KEY) || []) | |
msg.send msg.random images | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment