Last active
August 29, 2015 14:15
-
-
Save tondol/24389071001e3ac365f4 to your computer and use it in GitHub Desktop.
lovelive.coffee
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 | |
# A Hubot script for shoda script | |
# | |
# Configuration: | |
# None | |
# | |
# Commands: | |
# | |
# Author: | |
# tondol | |
module.exports = (robot) -> | |
robot.hear /ラブライブ/i, (msg) -> | |
imageMe msg, "ラブライブ", true, (url) -> | |
msg.send url | |
imageMe = (msg, query, animated, faces, cb) -> | |
cb = animated if typeof animated == 'function' | |
cb = faces if typeof faces == 'function' | |
q = v: '1.0', rsz: '8', q: query, safe: 'active' | |
q.imgtype = 'animated' if typeof animated is 'boolean' and animated is true | |
q.imgtype = 'face' if typeof faces is 'boolean' and faces is true | |
msg.http('http://ajax.googleapis.com/ajax/services/search/images') | |
.query(q) | |
.get() (err, res, body) -> | |
images = JSON.parse(body) | |
images = images.responseData?.results | |
if images?.length > 0 | |
image = msg.random images | |
cb "#{image.unescapedUrl}#.png" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment