-
Notifications
You must be signed in to change notification settings - Fork 1
/
motivate.js
36 lines (34 loc) · 900 Bytes
/
motivate.js
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
var ZenIRCBot = require('zenircbot-api').ZenIRCBot
var zen = new ZenIRCBot()
zen.register_commands(
"motivate.js",
[{
name: "!m <target>",
description: "Motivates the target."
}, {
name: "!dm <target>",
description: "Demotivates the target."
}]
)
var filtered = zen.filter({version: 1, type: 'directed_privmsg'})
filtered.on('data', function(msg){
var motivate = /^m( .*|$)/i.exec(msg.data.message)
var demotivate = /^dm( .*|$)/i.exec(msg.data.message)
var validOne = (motivate || demotivate)
if (validOne) {
var target = validOne[1].trim() || msg.data.channel
if (motivate) {
zen.send_privmsg(
msg.data.channel,
"You're doing great work, " +
target + "!"
);
} else if (demotivate) {
zen.send_privmsg(
msg.data.channel,
"You're doing horrible work, " +
target + "!"
);
}
}
})