Add several options and minor changes

* Add DefaultChannel option to make channel argument for the run
  command optional
* Add Blacklist option for channels to ignore and not execute lists in
* Only listen in channel of user if explicitly added to channel list
* Add option to send an emote when finished with current list xd
This commit is contained in:
Manuel 2021-09-26 06:03:24 +02:00
parent 4c55097019
commit 9db006c293
Signed by: Manuel
GPG key ID: 4085037435E1F07A
2 changed files with 17 additions and 6 deletions

View file

@ -4,8 +4,11 @@
"PNSLToken": "",
"IgnorePNSL": false,
"UseParallelUniverse": true,
"DefaultChannel": "",
"Blacklisted" : [],
"Users": [],
"Channels": [],
"SendMeme": false,
"Prefix": "!!",
"MaxConnections": 30,
"MaxChunkSize": 2000,

View file

@ -89,6 +89,7 @@ const runList = async (listData, listID, channel, sourceChannel) => {
await Promise.allSettled(promises);
say(sourceChannel, `${Config.UseParallelUniverse === true ? '[PU]' : ''} Chunk ${currentChunk}/${chunkCount} of ${listID} executed successfully on channel ${targetChannel}`);
say(channel, `Chunk ${currentChunk}/${chunkCount} executed successfully`);
if (currentChunk === chunkCount) {
break;
@ -193,8 +194,6 @@ if (!Config.IgnorePNSL) {
listenClient = createTwitchClient();
listenClient.connect();
listenClient.on('ready', async () => {
await listenClient.join(`#${Config.Username}`);
if (Config.Channels.length !== 0) {
await listenClient.joinAll(Config.Channels);
}
@ -218,7 +217,7 @@ if (!Config.IgnorePNSL) {
const args = content.slice(1);
if (command === 'ping') {
const channel = args[0];
let channel = args[0];
return say(channel || channelName, `${clients.filter((i) => i.ready).length} Clients from total of ${clients.length} are operational`);
}
@ -233,22 +232,31 @@ if (!Config.IgnorePNSL) {
if (!listID) {
return say(channelName, 'No list ID provided!');
}
if (!channel) {
channel = Config.DefaultChannel || channelName;
}
if (Config.Blacklisted.includes(channel)) {
return say(channelName, `I am not allowed to execute lists in channel ${channel}!`);
}
try {
if (channel) {
if (channel != channelName) {
const mods = await listenClient.getMods(`#${channel}`);
if (!mods.includes(Config.Username)) {
return say(channelName, `I am not a moderator in channel ${channel}!`);
}
}
if (!Config.IgnorePNSL) {
const data = await fetchList(listID);
await runList(data.listData, listID, channel || channelName, channelName);
await runList(data.listData, listID, channel, channelName);
} else {
const data = await fetchUrlList(listID);
await runList(data, listID, channel || channelName, channelName);
await runList(data, listID, channel, channelName);
}
say(channelName, `${Config.UseParallelUniverse === true ? '[PU]' : ''} List ${listID} executed successfully on channel ${channel || channelName}`);
if (Config.SendMeme) say(channel, 'FeelsGoodMan');
} catch (e) {
console.error(e);
return say(channelName, `Error Occurred! ${e.message}`);