import export setup

This commit is contained in:
Sarimoko 2022-02-14 03:29:53 -08:00
parent 8053eb44d9
commit 1666ba3b6b
3 changed files with 19 additions and 15 deletions

View File

@ -1,3 +1,4 @@
export function ttvalerts() {
// TTV Re-Active
// ==================================
// TO-DO: Add Follower API
@ -192,3 +193,4 @@ client.on("whisper", (from, userstate, message, self) => {
console.log('DM | From:'.green, from, userstate, 'MSG:'.green, message);
client.say(channel, `/me [+1] Inbox | Received a new SEXT message from: @`+ from +`!`);
});
}

View File

@ -24,6 +24,8 @@ client.connect();
import { rnguser } from "./rng.js";
rnguser();
import { ttvalerts } from "./alerts.js";
ttvalerts();
client.on('message', (channel, tags, message, self) => {
if(self) return;

View File

@ -1,24 +1,24 @@
export function rnguser() {
// RNG User
function getChatters(channelName, _attemptCount = 0) {
return rp({
uri: `https://tmi.twitch.tv/group/user/sarimoko/chatters`,
json: true
})
.then(data => {
return Object.entries(data.chatters)
function getChatters(channelName, _attemptCount = 0) {
return rp({
uri: `https://tmi.twitch.tv/group/user/sarimoko/chatters`,
json: true
})
.then(data => {
return Object.entries(data.chatters)
.reduce((p, [ type, list ]) => p.concat(list.map(name => {
if(name === channelName) type = 'broadcaster';
return { name, type };
})), []);
})
.catch(err => {
if(_attemptCount < 3) {
return getChatters(channelName, _attemptCount + 1);
}
})
.catch(err => {
if(_attemptCount < 3) {
return getChatters(channelName, _attemptCount + 1);
}
throw err;
})
}
})
}
function getRandomChatter(channelName, opts = {}) {
let {