Accept full links as lists and fix timeout check

This commit is contained in:
Leppunen 2020-12-22 10:04:26 +02:00
parent 39c12f7d58
commit 9f37b43861

View file

@ -1,14 +1,14 @@
const {extend: createGotClient} = require('got');
const {ConnectionError, SayError, PingTimeoutError, ChatClient} = require('dank-twitch-irc');
const {ConnectionError, SayError, TimeoutError, ChatClient} = require('dank-twitch-irc');
const chalk = require('chalk');
const WS = require('ws');
const Config = require('./config.json');
const clients = [];
const banChunks = [];
const pingInterval = 60e3;
const pingInterval = 120e3;
let lastIndex = 0;
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 msgRegex = /[\u034f\u2800\u{E0000}\u180e\ufeff\u2000-\u200d\u206D]/gu;
const pnslClient = createGotClient({
@ -19,8 +19,9 @@ const pnslClient = createGotClient({
},
});
const fetchList = async (listID) => {
if (!uuidRegex.test(listID)) {
const fetchList = async (list) => {
const listID = uuidRegex.exec(list)?.[0];
if (!listID) {
throw new Error('Invalid List ID!');
}
@ -145,9 +146,9 @@ pnslWebSocket.on('message', async (data) => {
clients[i].connect();
return console.error(`Error in client ${i} -> ${error.name} || ${error.message}`);
}
if (error instanceof PingTimeoutError) {
if (error instanceof TimeoutError) {
clients[i].connect();
return console.error(`Ping Error in client ${i} -> ${error.name} || ${error.message}`);
return console.error(`Timeout in client ${i} -> ${error.name} || ${error.message} | Trying to reconnect`);
}
console.error(error);
});