Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created March 2, 2016 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitode909/5c216a92509b5dc1e900 to your computer and use it in GitHub Desktop.
Save hitode909/5c216a92509b5dc1e900 to your computer and use it in GitHub Desktop.
Registerable Hubot LGTM Command
# 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