This repository has been archived by the owner on Jan 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (55 loc) · 2.09 KB
/
index.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const { VK } = require('vk-io');
const users = require('./users.json');
const fs = require('fs');
const checkRole = require('./utils/checkRole');
const warnUser = require('./utils/warnUser');
const unwarnUser = require('./utils/unwarnUser');
const kickUser = require('./utils/kickUser');
const howWarnsUser = require('./utils/howWarnsUser');
const vk = new VK({ token: '' }); //token группы
const idGroup = -1 //id группы
setInterval(async () => {
fs.writeFileSync("./users.json", JSON.stringify(users, null, "\t"))
}, 500);
vk.updates.on('message', (next, context) => {
const user = users.filter(x => x.id === next.senderId)[0]
if(user) return context()
users.push({
id: next.senderId,
warns: 0,
role: 1,
ban: false
})
return context()
})
vk.updates.on([ 'chat_invite_user', 'chat_invite_user_by_link' ], async (context) => {
if ((context.eventMemberId || context.senderId) === idGroup) {
await context.send(`Всем привет я новенький.`)
}
})
vk.updates.on('message_new', (context) => {
if (context.text !== undefined) {
if (context.text.toLowerCase() === 'пред') {
if (checkRole(context, 2, users, true)) return console.log(`${context.senderId} - лох`)
warnUser(context, vk.api, users)
}
if (context.text.toLowerCase() === 'снять пред') {
if (checkRole(context, 2, users, true)) return console.log(`${context.senderId} - лох`)
unwarnUser(context, users)
}
if (context.text.toLowerCase() === 'кик') {
if (checkRole(context, 3, users, true)) return console.log(`${context.senderId} - лох`)
kickUser(context, vk.api)
}
if (context.text.toLowerCase() === 'че там') {
if (checkRole(context, 3, users, true)) return console.log(`${context.senderId} - лох`)
howWarnsUser(context, users)
}
if (context.text.toLowerCase() === 'бот') {
if (checkRole(context, 3, users)) return console.log(`${context.senderId} - лох`)
context.send('Работаю!')
}
}
})
console.log("Работаю!");
vk.updates.start().catch(console.error);