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 // TTV Re-Active
// ================================== // ==================================
// TO-DO: Add Follower API // 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); console.log('DM | From:'.green, from, userstate, 'MSG:'.green, message);
client.say(channel, `/me [+1] Inbox | Received a new SEXT message from: @`+ from +`!`); 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"; import { rnguser } from "./rng.js";
rnguser(); rnguser();
import { ttvalerts } from "./alerts.js";
ttvalerts();
client.on('message', (channel, tags, message, self) => { client.on('message', (channel, tags, message, self) => {
if(self) return; if(self) return;

View File

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