-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (43 loc) · 1.9 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
var config = require("./config.json");
var cache = require("./cache.js");
process.on("unhandledRejection", console.log);
var roblox = require("./roblox");
var runningScan = 0;
async function scan(methods) {
if (runningScan == 1) return;
runningScan = 1;
var ban_role_id = await methods.getRoleById(config.group, config.ban_rank);
if (ban_role_id == undefined) return;
if (cache.cache.wall == undefined) cache.cache.wall = {};
await methods.fetchNewWall(config.group, cache.cache.wall[config.group] || 0, 100).then(async function(data) {
if (data == undefined) return;
var alreadyBanned = {};
if (data[0] != undefined) { cache.cache.wall[config.group] = data[0].id; }
for (let i in data) {
if (data[i] != undefined && data[i].body != undefined && data[i].poster != undefined) {
let content = data[i].body.toUpperCase();
let level = 0;
for (let word of config.banned_words) {
if (content.indexOf(word.toUpperCase()) != -1) {
level++;
}
}
if (level >= config.target_level && alreadyBanned[data[i].poster.user.userId] == undefined && data[i].poster.role.rank < config.op_ranks) {
console.log(data[i].poster.user.username + " is being banned.");
alreadyBanned[data[i].poster.user.userId] = 1;
await methods.deleteUserPosts(config.group, data[i].poster.user.userId);
await methods.setRank(config.group, data[i].poster.user.userId, ban_role_id.id);
await methods.follow(data[i].poster.user.userId);
await methods.sendMessage(data[i].poster.user.userId, config.ban_message.subject, config.ban_message.body);
}
}
}
});
cache.save();
runningScan = 0;
}
roblox(config.login_type, config.login, config.password).then(async function(methods) {
console.log("Bot has been ran!");
scan(methods);
setInterval(function() { scan(methods); }, config.scan_delay);
});