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:
parent
4c55097019
commit
9db006c293
2 changed files with 17 additions and 6 deletions
|
@ -4,8 +4,11 @@
|
||||||
"PNSLToken": "",
|
"PNSLToken": "",
|
||||||
"IgnorePNSL": false,
|
"IgnorePNSL": false,
|
||||||
"UseParallelUniverse": true,
|
"UseParallelUniverse": true,
|
||||||
|
"DefaultChannel": "",
|
||||||
|
"Blacklisted" : [],
|
||||||
"Users": [],
|
"Users": [],
|
||||||
"Channels": [],
|
"Channels": [],
|
||||||
|
"SendMeme": false,
|
||||||
"Prefix": "!!",
|
"Prefix": "!!",
|
||||||
"MaxConnections": 30,
|
"MaxConnections": 30,
|
||||||
"MaxChunkSize": 2000,
|
"MaxChunkSize": 2000,
|
||||||
|
|
20
index.js
20
index.js
|
@ -89,6 +89,7 @@ const runList = async (listData, listID, channel, sourceChannel) => {
|
||||||
await Promise.allSettled(promises);
|
await Promise.allSettled(promises);
|
||||||
|
|
||||||
say(sourceChannel, `${Config.UseParallelUniverse === true ? '[PU]' : ''} Chunk ${currentChunk}/${chunkCount} of ${listID} executed successfully on channel ${targetChannel}`);
|
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) {
|
if (currentChunk === chunkCount) {
|
||||||
break;
|
break;
|
||||||
|
@ -193,8 +194,6 @@ if (!Config.IgnorePNSL) {
|
||||||
listenClient = createTwitchClient();
|
listenClient = createTwitchClient();
|
||||||
listenClient.connect();
|
listenClient.connect();
|
||||||
listenClient.on('ready', async () => {
|
listenClient.on('ready', async () => {
|
||||||
await listenClient.join(`#${Config.Username}`);
|
|
||||||
|
|
||||||
if (Config.Channels.length !== 0) {
|
if (Config.Channels.length !== 0) {
|
||||||
await listenClient.joinAll(Config.Channels);
|
await listenClient.joinAll(Config.Channels);
|
||||||
}
|
}
|
||||||
|
@ -218,7 +217,7 @@ if (!Config.IgnorePNSL) {
|
||||||
const args = content.slice(1);
|
const args = content.slice(1);
|
||||||
|
|
||||||
if (command === 'ping') {
|
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`);
|
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) {
|
if (!listID) {
|
||||||
return say(channelName, 'No list ID provided!');
|
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 {
|
try {
|
||||||
if (channel) {
|
if (channel != channelName) {
|
||||||
const mods = await listenClient.getMods(`#${channel}`);
|
const mods = await listenClient.getMods(`#${channel}`);
|
||||||
if (!mods.includes(Config.Username)) {
|
if (!mods.includes(Config.Username)) {
|
||||||
return say(channelName, `I am not a moderator in channel ${channel}!`);
|
return say(channelName, `I am not a moderator in channel ${channel}!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Config.IgnorePNSL) {
|
if (!Config.IgnorePNSL) {
|
||||||
const data = await fetchList(listID);
|
const data = await fetchList(listID);
|
||||||
await runList(data.listData, listID, channel || channelName, channelName);
|
await runList(data.listData, listID, channel, channelName);
|
||||||
} else {
|
} else {
|
||||||
const data = await fetchUrlList(listID);
|
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}`);
|
say(channelName, `${Config.UseParallelUniverse === true ? '[PU]' : ''} List ${listID} executed successfully on channel ${channel || channelName}`);
|
||||||
|
if (Config.SendMeme) say(channel, 'FeelsGoodMan');
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
return say(channelName, `Error Occurred! ${e.message}`);
|
return say(channelName, `Error Occurred! ${e.message}`);
|
||||||
|
|
Loading…
Reference in a new issue