Skip to content

Instantly share code, notes, and snippets.

@spoike
Created February 20, 2015 09:26
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 spoike/6a9b7ecb8ae85d00a1af to your computer and use it in GitHub Desktop.
Save spoike/6a9b7ecb8ae85d00a1af to your computer and use it in GitHub Desktop.
Hubot make me a sandwich!
# Description:
# Hubot make me a sandwich
#
# Dependencies:
# google-images
#
# Configuration:
# None
#
# Commands:
# hubot make me a sandwich - Make me a sammich!
#
# Author:
# spoike
client = require 'google-images'
sandwiches = ['sandwich']
random = (items) ->
items[ Math.floor(Math.random() * items.length) ]
module.exports = (robot) ->
getRandomSandwich = (cb) ->
client.search random(sandwiches), (err, images) ->
cb (random images).url
robot.respond /(sudo )?make( me)?( a)? sandwict?s?h/i, (msg) ->
if msg.match[1] is "sudo "
getRandomSandwich (sandwich) ->
msg.reply "Okay #{sandwich}"
else
msg.reply "What? Make it yourself."
robot.hear /sudo .* make( me?)( a)? sandwict?s?h/i, (msg) ->
getRandomSandwich (sandwich) ->
msg.reply "Okay #{sandwich}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment