-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.js
More file actions
74 lines (57 loc) · 1.86 KB
/
plugin.js
File metadata and controls
74 lines (57 loc) · 1.86 KB
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
var path = require("path");
const _getNotice = function(message) {
return {
'intent': 'notice',
'query': true,
'message': message
};
};
var TennuDBBan = {
configDefaults: {
"dbban": {
}
},
requiresRoles: ['ban', 'dbcore', 'admin'],
init: function(client, imports) {
var banConfig = client.config('dbban');
const knex = imports.dbcore.knex;
const ban = imports.ban;
var dbBanPromise = knex.migrate.latest({
tableName: 'tennu_dbban_knex_migrations',
directory: path.join(__dirname, 'migrations')
}).then(function() {
return require('./lib/dbban')(ban, knex);
});
function respondRouter() {
return function(IRCMessage) {
return imports.admin.requiresAdmin(router)(IRCMessage);
function router(privmsg) {
// TODO
// '!tempban !tban'
// '!unban !uban'
// '!listbans !lban'
// '!clearbans'
switch (privmsg.args[0]) {
case 'add':
return addBan(privmsg);
default:
return _getNotice('Subcommand for respond not found. See !help respond and check your PMs.')
}
}
}
}
function addBan(privmsg) {
return dbBanPromise.then(function(dbban) {
return dbban.addBans(privmsg.args[1]);
});
}
return {
handlers: {
'!ban': respondRouter(),
},
help: require('./help.json'),
commands: ['ban', 'tempban', 'unban', 'listbans', 'clearbans']
}
}
};
module.exports = TennuDBBan;