Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit c58345c

Browse files
author
Tom Bell
committed
Merge pull request #881 from ajacksified/trolololo
return one of many alternative trollfaces when trolling is mentioned
2 parents 0125946 + daba621 commit c58345c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/scripts/trolololo.coffee

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Description:
2+
# None
3+
#
4+
# Dependencies:
5+
# None
6+
#
7+
# Configuration:
8+
# HUBOT_IMGUR_CLIENT_ID
9+
#
10+
# Commands:
11+
# trol.* - returns one of many alternative trollfaces when trolling is
12+
# mentioned (troll, trolling, trolololololo...)
13+
#
14+
# Author:
15+
# ajacksified
16+
17+
18+
https = require('https')
19+
20+
options =
21+
hostname: 'api.imgur.com'
22+
path: '/3/album/pTXm0'
23+
headers:
24+
'Authorization': "Client-ID #{process.env.HUBOT_IMGUR_CLIENT_ID}"
25+
26+
module.exports = (robot) ->
27+
robot.hear /\btrol\w+?\b/i, (msg) ->
28+
data = []
29+
30+
https.get(options, (res) ->
31+
if res.statusCode == 200
32+
res.on 'data', (chunk) ->
33+
data.push(chunk)
34+
35+
res.on 'end', () ->
36+
parsedData = JSON.parse(data.join(''))
37+
images = parsedData.data.images
38+
image = images[parseInt(Math.random() * images.length)]
39+
40+
msg.send(image.link)
41+
)
42+

0 commit comments

Comments
 (0)