Move limit configs to config.json
This commit is contained in:
parent
8f77650b0d
commit
6c1479a8fb
2 changed files with 8 additions and 8 deletions
|
@ -2,5 +2,8 @@
|
||||||
"Username": "",
|
"Username": "",
|
||||||
"Password": "",
|
"Password": "",
|
||||||
"PNSLToken": "",
|
"PNSLToken": "",
|
||||||
"AdminID": ""
|
"AdminID": "",
|
||||||
|
"MaxConnections": 30,
|
||||||
|
"MaxChunkSize": 2000,
|
||||||
|
"DelayPerChunk": 30e3
|
||||||
}
|
}
|
11
index.js
11
index.js
|
@ -6,9 +6,6 @@ const Config = require('./config.json');
|
||||||
const clients = [];
|
const clients = [];
|
||||||
let banChunks = [];
|
let banChunks = [];
|
||||||
let lastIndex = 0;
|
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 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({
|
const pnslClient = createGotClient({
|
||||||
|
@ -42,7 +39,7 @@ const getConnection = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
[...Array(maxClients)].map((_, i) => {
|
[...Array(Config.MaxConnections)].map((_, i) => {
|
||||||
clients[i] = createTwitchClient();
|
clients[i] = createTwitchClient();
|
||||||
clients[i].connect();
|
clients[i].connect();
|
||||||
clients[i].on('ready', async () => {
|
clients[i].on('ready', async () => {
|
||||||
|
@ -76,16 +73,16 @@ const getConnection = () => {
|
||||||
|
|
||||||
const banArr = body.split('\n');
|
const banArr = body.split('\n');
|
||||||
|
|
||||||
if (banArr.length > maxChunkSize) {
|
if (banArr.length > Config.MaxChunkSize) {
|
||||||
while (banArr.length > 0) {
|
while (banArr.length > 0) {
|
||||||
banChunks.push(banArr.splice(0, maxChunkSize));
|
banChunks.push(banArr.splice(0, Config.MaxChunkSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const chunk of banChunks) {
|
for (const chunk of banChunks) {
|
||||||
for (const entry of chunk) {
|
for (const entry of chunk) {
|
||||||
getConnection().privmsg(channel || msg.channelName, entry);
|
getConnection().privmsg(channel || msg.channelName, entry);
|
||||||
}
|
}
|
||||||
await sleep(delayPerChunk);
|
await sleep(Config.DelayPerChunk);
|
||||||
}
|
}
|
||||||
banChunks = [];
|
banChunks = [];
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue