-
Notifications
You must be signed in to change notification settings - Fork 1
/
annoying-song.coffee
79 lines (74 loc) · 2.63 KB
/
annoying-song.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
73
74
75
76
77
78
# Description:
# Sing an annoying song. I'd suggest only using this for debug purposes.
#
# Commands:
# sing <song> - sing the song specified
# sing - sing a random song
# stop - makes the singing stop
#
# Author:
# Andrew Lucas <andrewl@resin.io> <sqweelygig@gmail.com>
module.exports = (robot) ->
interval = null
song = null
line = 0
songs = {
'badger': [
'badger, badger, badger, badger, badger',
'badger, badger, badger, badger, badger',
'mushroom, mushroom',
'badger, badger, badger, badger, badger',
'badger, badger, badger, badger, badger',
'mushroom, mushroom',
'badger, badger, badger, badger, badger',
'badger, badger, badger, badger, badger',
'mushroom, mushroom'
'badger, badger, badger, badger, badger',
'badger, badger, badger, badger, badger',
'argh! Snake, a snake!',
'snaaake! A snaaaake, oooh its a snake!',
"it's a badger, badger, badger, badger, badger",
'badger, badger, badger, badger, badger',
'mushroom, mushroom'
],
'llama': [
"Here's a llama, there's a llama, and another little llama",
'Fuzzy llama, funny llama, llama, llama, duck',
'Llama, llama, cheesecake, llama, tablet, brick, potato, llama',
'Llama, llama, mushroom, llama, llama, llama, duck',
'I was once a tree house, I lived in a cake',
'But I never saw the way, the orange slayed the rake',
'I was only three years dead, but it told a tale',
'And now listen little child, To the safety rail',
'Did you ever see a llama kiss a llama on the llama?',
"Llama's llama, tastes of llama. Llama llama duck",
'Half a llama, twice a llama, not a llama',
'Farmer llama, llama in a car, alarm a llama, llama, duck',
"Is that how it's told now? Is it all so old?",
'Is it made of lemon juice? Doorknob, ankle, cold',
"Now my song is getting thin, I've run out of luck",
'Time for me to retire now, and become a duck'
],
'short': [
"I will sing you a song that's not very long"
]
}
robot.hear /^(sing)\b/i, (res) ->
clearInterval interval
line = 0
potential_songs = []
for word in res.message.text.split /\W+/
if songs.hasOwnProperty word
potential_songs.push word
if potential_songs.length is 0
potential_songs = Object.keys songs
song = res.random potential_songs
res.send 'singing the ' + song + ' song!'
interval = setInterval ->
res.send songs[song][line]
line++
if line >= songs[song].length
clearInterval interval
, 2000
robot.hear /stop/i, (res) ->
clearInterval(interval)