diff --git a/config_dist.json b/config_dist.json index 0c68639..345b2ea 100644 --- a/config_dist.json +++ b/config_dist.json @@ -3,6 +3,7 @@ "Password": "", "PNSLToken": "", "IgnorePNSL": false, + "UseParallelUniverse": true, "Users": [], "Prefix": "!!", "MaxConnections": 30, diff --git a/index.js b/index.js index e6e34d2..8e9d257 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ const { extend: createGotClient } = require('got'); -const { ConnectionError, SayError, TimeoutError, UserBanError, ChatClient } = require('dank-twitch-irc'); +const { ConnectionError, SayError, JoinError, TimeoutError, UserBanError, ChatClient } = require('dank-twitch-irc'); const chalk = require('chalk'); const WS = require('ws'); const Config = require('./config.json'); @@ -80,12 +80,17 @@ const runList = async (listData, listID, channel) => { continue; } [, user, ...reason] = entry.split(' '); - promises.push(getConnection().ban(channel, user, reason.join(' '))); + if (Config.UseParallelUniverse === true) { + const rawBanCommand = `PRIVMSG ${channel} :.ban ${user} ${reason.join(' ')}`; + promises.push(getConnection().sendRaw(rawBanCommand)); + } else { + promises.push(getConnection().ban(channel, user, reason.join(' '))); + } } await Promise.allSettled(promises); - say(Config.Username, `Chunk ${currentChunk}/${chunkCount} of ${listID} executed successfully on channel ${channel}`); + say(Config.Username, `${Config.UseParallelUniverse === true ? '[PU]' : ''} Chunk ${currentChunk}/${chunkCount} of ${listID} executed successfully on channel ${channel}`); if (currentChunk === chunkCount) { break; @@ -103,7 +108,12 @@ const runList = async (listData, listID, channel) => { continue; } [, user, ...reason] = entry.split(' '); - promises.push(getConnection().ban(channel, user, reason.join(' '))); + if (Config.UseParallelUniverse === true) { + const rawBanCommand = `PRIVMSG ${channel} :.ban ${user} ${reason.join(' ')}`; + promises.push(getConnection().sendRaw(rawBanCommand)); + } else { + promises.push(getConnection().ban(channel, user, reason.join(' '))); + } } await Promise.allSettled(promises); @@ -168,6 +178,9 @@ if (!Config.IgnorePNSL) { if (error instanceof SayError) { return; } + if (error instanceof JoinError) { + return; + } if (error instanceof UserBanError) { return console.warn(`Failed to ban user ${error.username} from ${error.channelName}`); } @@ -233,7 +246,7 @@ if (!Config.IgnorePNSL) { const data = await fetchUrlList(listID); await runList(data, listID, channel || channelName); } - say(Config.Username, `List ${listID} executed successfully on channel ${channel || channelName}`); + say(Config.Username, `${Config.UseParallelUniverse === true ? '[PU]' : ''} List ${listID} executed successfully on channel ${channel || channelName}`); } catch (e) { console.error(e); return say(Config.Username, `Error Occurred! ${e.message}`);