-
Notifications
You must be signed in to change notification settings - Fork 2
/
commands.js
49 lines (40 loc) · 1.13 KB
/
commands.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
37
38
39
40
41
42
43
44
45
46
47
48
49
const config = require('config')
const client = require('./client.js')
const activeChannel = config.get('channel')
let state = null;
let clear = () => {
if (!checkModeratorPermission()) return
client.clear(config.get('channel'))
}
let timeOutUser = (args) => {
if (!checkModeratorPermission()) return
let targetUser = args[0]
let timeOutDuration = args[1]
client.timeout(activeChannel, targetUser, timeOutDuration)
client.action(activeChannel, targetUser + ' now u have timeout mode! Duration: ' + timeOutDuration)
}
const callCommand = (command, messageInfo) => {
state = messageInfo;
switch (command.command) {
case 'to':
timeOutUser(command.args)
break
case 'clear':
clear();
break
case 'fb':
client.action(activeChannel, config.get('social.facebook'))
break
case 'twt':
client.action(activeChannel, config.get('social.twitter'))
break
default:
break
}
}
const checkModeratorPermission = () => state.user.mod || state.user.username === activeChannel
module.exports = {
call: (command, messageInfo) => {
callCommand(command, messageInfo)
}
}