Created
February 20, 2015 09:26
-
-
Save spoike/6a9b7ecb8ae85d00a1af to your computer and use it in GitHub Desktop.
Hubot make me a sandwich!
This file contains hidden or 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: | |
# 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