Move limit configs to config.json

This commit is contained in:
Leppunen 2020-12-15 15:36:38 +02:00
parent 8f77650b0d
commit 6c1479a8fb
2 changed files with 8 additions and 8 deletions

View file

@ -2,5 +2,8 @@
"Username": "",
"Password": "",
"PNSLToken": "",
"AdminID": ""
"AdminID": "",
"MaxConnections": 30,
"MaxChunkSize": 2000,
"DelayPerChunk": 30e3
}

View file

@ -6,9 +6,6 @@ const Config = require('./config.json');
const clients = [];
let banChunks = [];
let lastIndex = 0;
const maxClients = 30;
const maxChunkSize = 5000;
const delayPerChunk = 30e3;
const uuidRegex = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
const pnslClient = createGotClient({
@ -42,7 +39,7 @@ const getConnection = () => {
};
(() => {
[...Array(maxClients)].map((_, i) => {
[...Array(Config.MaxConnections)].map((_, i) => {
clients[i] = createTwitchClient();
clients[i].connect();
clients[i].on('ready', async () => {
@ -76,16 +73,16 @@ const getConnection = () => {
const banArr = body.split('\n');
if (banArr.length > maxChunkSize) {
if (banArr.length > Config.MaxChunkSize) {
while (banArr.length > 0) {
banChunks.push(banArr.splice(0, maxChunkSize));
banChunks.push(banArr.splice(0, Config.MaxChunkSize));
}
for (const chunk of banChunks) {
for (const entry of chunk) {
getConnection().privmsg(channel || msg.channelName, entry);
}
await sleep(delayPerChunk);
await sleep(Config.DelayPerChunk);
}
banChunks = [];
} else {