This repository has been archived by the owner on Jun 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
foass.coffee
72 lines (65 loc) · 1.54 KB
/
foass.coffee
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Description:
# Basic interface for FOAAS.com
#
# Commands
# fu <object> - tells <object> to f off with random response from FOASS
# fu - express displeasure with random response from FOASS
#
# Dependencies:
# None
#
# Author:
# zacechola
module.exports = (robot) ->
robot.hear /^fu(?:\s)(?=([\w ]+))/i, (msg) ->
options = [
'off',
'you',
'donut',
'shakespeare',
'linus',
'king',
'chainsaw',
'outside',
'madison',
'nugget',
'yoda'
]
from = msg.message.user.name
to = msg.match[1]
if to
options.push(to)
random_fu = msg.random options
if random_fu is to
# if our random fu matched to, call /to/from
url = "http://foaas.com/#{random_fu}/#{from}/"
else
# else use default /option/to/from
url = "http://foaas.com/#{random_fu}/#{to}/#{from}/"
else
# or if we have no parameter for to, use these options
options = [
'this',
'that',
'everything',
'everyone',
'pink',
'life',
'thanks',
'flying',
'fascinating',
'cool',
'what',
'because'
]
random_fu = msg.random options
# call /option/to
url = "http://foaas.com/#{random_fu}/#{from}/"
msg.http(url)
.headers(Accept: 'application/json')
.get() (err, res, body) ->
try
json = JSON.parse body
msg.send "#{json.message}\n#{json.subtitle}"
catch error
msg.send "Fuck this error!"