-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlolface.coffee
More file actions
38 lines (30 loc) · 974 Bytes
/
lolface.coffee
File metadata and controls
38 lines (30 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#
# This script picks a random LOLFACE image when you say LOL
#
module.exports = (robot) ->
robot.hear /(LOL)/, (msg) ->
imageMe msg, "LOLFACE", (url) ->
msg.send url
robot.hear /(ROFL)/, (msg) ->
imageMe msg, "ROFL", (url) ->
msg.send url
robot.hear /(LMAO)/, (msg) ->
imageMe msg, "LMAO", (url) ->
msg.send url
robot.hear /\b(meh)\b/i, (msg) ->
imageMe msg, 'meh lolcat', (url) ->
msg.send url
robot.hear /(ohai)/i, (msg) ->
imageMe msg, 'ohai lolcat', (url) ->
msg.send url
pages = [1,2,3,4,5,6,7,8]
imageMe = (msg, query, cb) ->
page = msg.random pages
msg.http('http://ajax.googleapis.com/ajax/services/search/images')
.query(v: "1.0", start: page, rsz: '8', q: query, safe: 'active')
.get() (err, res, body) ->
images = JSON.parse(body)
images = images.responseData.results
if images.length > 0
image = msg.random images
cb "#{image.unescapedUrl}#.png"