Boto/node/boto.js

398 lines
16 KiB
JavaScript
Raw Normal View History

2022-02-11 08:03:21 +00:00
// B O T O
2022-02-12 05:05:56 +00:00
2022-02-09 06:55:26 +00:00
require('dotenv').config();
2022-02-11 10:44:16 +00:00
const tmi = require('tmi.js');
2022-02-09 06:55:26 +00:00
console.log(process.env.API_HOST);
const client = new tmi.Client({
options: { debug: true },
connection: {
secure: true,
reconnect: true
},
identity: {
username: process.env.TTV_BOT_USERNAME,
password: process.env.TTV_BOT_OAUTH
},
channels: [ process.env.TTV_CHANNELS ]
});
client.connect();
2022-02-12 22:28:55 +00:00
const rp = require('request-promise');
function getChatters(channelName, _attemptCount = 0) {
return rp({
2022-02-12 22:32:41 +00:00
uri: `https://tmi.twitch.tv/group/user/${channelName}/chatters`,
2022-02-12 22:28:55 +00:00
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);
}
throw err;
})
}
function getRandomChatter(channelName, opts = {}) {
let {
onlyViewers = false,
noBroadcaster = false,
skipList = []
} = opts;
return getChatters(channelName)
.then(data => {
let chatters = data
.filter(({ name, type }) =>
!(
(onlyViewers && type !== 'viewers') ||
(noBroadcaster && type === 'broadcaster') ||
skipList.includes(name)
)
);
return chatters.length === 0 ?
null :
chatters[Math.floor(Math.random() * chatters.length)];
});
}
2022-02-12 05:08:18 +00:00
// SCAN MSG | START
client.on('message', (channel, tags, message, self) => {
if(self) return;
const badges = tags.badges || {}; // Scan Badges
const isBroadcaster = badges.broadcaster; // Define Streamer
const isMod = badges.moderator; // Define Mod
const isModUp = isBroadcaster || isMod; // Permission Merge = Mod+Streamer
const isSub = badges.subscriber || badges.founder; // Define Subs
const botUserState = client.userstate[channel]; // MOD Status Check
const amMod = botUserState !== undefined && botUserState.mod === true; // Define Mod Status
2022-02-11 11:06:26 +00:00
2022-02-12 05:08:18 +00:00
if(self || !message.startsWith('!')) return; // Command Parser
const args = message.slice(1).split(' ');
const command = args.shift().toLowerCase(); // !COMMAND => command
2022-02-12 05:26:12 +00:00
2022-02-12 21:32:34 +00:00
// CMD | CHAT COMMANDS | Start
2022-02-12 22:28:55 +00:00
if(command === 'randomuser') {
// Get a random user but skip the user requesting a random user
2022-02-12 22:33:37 +00:00
getRandomChatter(channel, { skipList: [ userstate.username ] })
2022-02-12 22:28:55 +00:00
.then(user => {
if(user === null) {
2022-02-12 22:32:41 +00:00
client.send(channel, `${userstate.username}, there was no one to choose.`);
2022-02-12 22:28:55 +00:00
}
else {
let { name, type } = user;
2022-02-12 22:32:41 +00:00
client.send(channel, `${userstate.username}, I chose "${name}" with type ${type}!`);
2022-02-12 22:28:55 +00:00
}
})
.catch(err => console.log('[ERR]', err));
}
2022-02-12 21:32:34 +00:00
// CMD | Color
2022-02-12 19:05:49 +00:00
if(command === 'color') {
2022-02-12 19:26:39 +00:00
// Change your username color. Color must be in hex (#000000) or one of the following: Blue, BlueViolet, CadetBlue, Chocolate, Coral, DodgerBlue, Firebrick, GoldenRod, Green, HotPink, OrangeRed, Red, SeaGreen, SpringGreen, YellowGreen.
2022-02-12 19:05:49 +00:00
client.say(channel, `/color ${args.join(' ')}`);
2022-02-12 22:10:53 +00:00
client.say(channel, `/me @${tags.username} has changed my color to ${args.join(' ')}`);
2022-02-12 19:26:39 +00:00
client.say(channel, `/me Out of the entire hex (#000000) spectrum or the preset color names: Blue, BlueViolet, CadetBlue, Chocolate, Coral, DodgerBlue, Firebrick, GoldenRod, Green, HotPink, OrangeRed, Red, SeaGreen, SpringGreen, YellowGreen you choose ${args.join(' ')}... Welp, alright!`);
2022-02-12 19:05:49 +00:00
}
2022-02-12 22:10:53 +00:00
// CMD | Code
if(command === 'code' ||
command === 'git' ||
command === 'repo' ||
command === 'dev') {
client.say(channel, `/me The CODE | Open-Source code available at: https://cord.sarimoko.com/`);
2022-02-12 21:00:12 +00:00
}
2022-02-12 21:32:34 +00:00
// CMD | Dice Roll
2022-02-12 18:33:43 +00:00
if(command === 'dice' ||
command === 'roll') {
const result = Math.floor(Math.random() * 6) + 1;
2022-02-12 21:20:10 +00:00
client.say(channel, `/me Bleep-Bloop! @${tags.username} has rolled a ${result}! Praise RNGesus!`);
}
2022-02-12 22:10:53 +00:00
// CMD | Dojo
2022-02-12 21:51:22 +00:00
if(command === 'dojo' ||
command === 'guide') {
2022-02-12 22:10:53 +00:00
client.say(channel, `/me The Dojo | DIY's & 1on1's available at: https://cord.sarimoko.com/`);
2022-02-12 21:51:22 +00:00
}
2022-02-12 22:10:53 +00:00
// CMD | Lurk
2022-02-12 21:20:10 +00:00
if(command === 'lurk' ||
command === 'lurkin' ||
command === 'lurking') {
client.say(channel, `/me Bleep-Bloop! Thanks for lurking, your viewership & support is much appriciated!`);
client.say(channel, `!kappagen sarimoLURKbrb sarimoKO sarimoLURKbrb sarimoKO sarimoLURKbrb sarimoKO `);
}
2022-02-12 22:10:53 +00:00
// CMD | Raid
2022-02-12 21:20:10 +00:00
if(command === 'raid' ||
command === 'raidcall' ||
command === 'spam' ||
command === 'spamwars') {
client.say(channel, `!kappagen sarimoRAID sarimoFREEDOM sarimoRAID sarimoFREEDOM sarimoRAID sarimoFREEDOM`);
client.say(channel, `/me Thanks everyone for watching!!! PREPARE TO SPAM!`);
client.say(channel, `/me Copy'n'Paste the following: (Yes, even if you don't have a sub... We know your a sub at PrideHeartL PrideHeartR LuvHearts`);
client.say(channel, `sarimoRAID sarimoFREEDOM You may take us viewers, but you'll NEVER take our FREEDOM!`);
2022-02-12 18:33:43 +00:00
}
2022-02-12 22:10:53 +00:00
// CMD | Rule
2022-02-12 21:02:13 +00:00
if(command === 'rule' ||
command === 'rules') {
2022-02-12 21:20:10 +00:00
client.say(channel, `/me Bleep-Bloop! Reminder of the Chat Rules`);
client.say(channel, `1. Do NOT feed the Trolls!`);
client.say(channel, `2. Do NOT be a Troll!`);
client.say(channel, `3. Do NOT be another brick in the wall!`);
}
2022-02-12 22:10:53 +00:00
// CMD | Sale
2022-02-12 21:20:10 +00:00
if(command === 'sale' ||
command === 'buygames' ||
command === 'humble' ||
command === 'bundle' ||
command === 'humblebundle') {
client.say(channel, `/me Bleep-Bloop! Get sales & give to charity! Win + win, right?! Check out HumbleBundle, use this affiliated link to support the stream: https://www.humblebundle.com/?partner=rusttv`);
2022-02-12 21:02:13 +00:00
}
2022-02-12 22:10:53 +00:00
// CMD | Time
2022-02-12 21:11:26 +00:00
if(command === 'time' ||
command === 'pst' ||
command === 'pac') {
client.say(channel, `/me Bleep-Bloop! PST | 2-Pac Standard Time`);
}
2022-02-12 22:10:53 +00:00
// CMD | Trip
2022-02-12 21:11:26 +00:00
if(command === 'trip' ||
command === 'trippin' ||
command === 'tripping') {
client.say(channel, `BLEEP! BLOOP! I'm trippin dragon ballz! Did @trip_228 spike my bios?!`);
client.say(channel, `!kappagen sarimoTRIP sarimoTRIP sarimoTRIP`);
client.say(channel, `Stay calm... Just remember your name & ip address... @Sarimoko 127.0.0.1... @Sarimoko 127.0.0.1...`);
}
2022-02-12 22:10:53 +00:00
// CMD | Tune
2022-02-12 21:11:26 +00:00
if(command === 'tune' ||
command === 'lyrics' ||
command === 'midi' ||
command === 'tabs') {
client.say(channel, `/me The Tune | Lyrics, MIDI, Tabs, & more hosted on Git written in Markdown available at: https://dojo.sarimoko.com/`);
}
2022-02-12 22:19:50 +00:00
// CMD | Weed
if(command === 'weed' ||
command === 'pot' ||
command === 'dab' ||
command === 'dab30' ||
command === 'roach' ||
command === 'roach30' ||
command === 'bong' ||
command === 'joint' ||
command === 'bongs' ||
command === 'pipe') {
client.say(channel, `/me The Sarimoko Show is an adults only channel based in California where we've passed Prop 64: Adult Use of Marijuana Act. Marijuana and Cannabis is not for everyone, please seek a professional for further guidance on THC and CBD.`);
}
2022-02-12 22:10:53 +00:00
// CMD | Whom
2022-02-12 21:15:14 +00:00
if(command === 'whom' ||
command === 'who' ||
command === 'cv' ||
command === 'resume' ||
command === 'portfolio') {
client.say(channel, `/me First off, thank you ${tags.username} for even considering contributing directly! Amazon Wishlists have been split into sub-categories and are available at: https://wish.sarimoko.com/ `);
}
2022-02-12 22:10:53 +00:00
// CMD | Wish
2022-02-12 21:11:26 +00:00
if(command === 'wish' ||
command === 'wishlist' ||
command === 'amazon' ||
command === 'gift') {
client.say(channel, `/me First off, thank you ${tags.username} for even considering contributing directly! Amazon Wishlists have been split into sub-categories and are available at: https://wish.sarimoko.com/ `);
}
2022-02-12 22:10:53 +00:00
// CMD | SOCIAL PLATFORMS
// CMD | Cord
if(command === 'cord' ||
command === 'discord') {
client.say(channel, `/me The Cord | The official Discod to join & share at: https://cord.sarimoko.com/`);
}
if(command === 'fb' ||
2022-02-12 22:12:53 +00:00
command === 'facebook' ||
2022-02-12 22:10:53 +00:00
command === '') {
client.say(channel, `/me Facebook | https://facebook.com/sarimoko.o `);
}
if(command === 'insta' ||
command === 'ig' ||
command === 'instagram') {
client.say(channel, `/me Instagram | https://instagram.com/sari.moko `);
}
if(command === 'reddit' ||
command === 'subreddit') {
client.say(channel, `/me Reddit | https://reddit.com/r/sarimoko_o `);
}
// CMD | Social
if(command === 'social' ||
command === 'socials' ||
command === 'linktree') {
client.say(channel, `/me YouTube | https://youtube.com/c/sarimoko `);
client.say(channel, `/me Instagram | https://instagram.com/sari.moko `);
client.say(channel, `/me Facebook | https://facebook.com/sarimoko.o `);
client.say(channel, `/me Reddit | https://reddit.com/r/sarimoko_o `);
client.say(channel, `/me TikTok | https://twitter.com/@sarimoko `);
client.say(channel, `/me Twitter | https://twitter.com/sarimoko_o `);
}
if(command === 'tiktok' ||
command === 'tik' ||
command === 'tok') {
client.say(channel, `/me TikTok | https://twitter.com/@sarimoko `);
}
if(command === 'twitter' ||
command === 'tweet') {
client.say(channel, `/me Twitter | https://twitter.com/sarimoko_o `);
}
2022-02-12 20:53:52 +00:00
// TODO:
// Uptime
// Viewers
// Followage
// Followers
2022-02-12 18:33:43 +00:00
// CHAT COMMANDS | End
2022-02-12 07:21:15 +00:00
if(isSub) { // SUB | Start
2022-02-12 21:32:34 +00:00
// FX | K A P P A G E N S
2022-02-12 21:35:51 +00:00
if(command === 'bg' ||
command === 'notgg') {
2022-02-12 21:51:22 +00:00
client.say(channel, `!kappagen sarimoDEAD sarimoGAME Bleep-Bloop!`);
2022-02-12 21:35:51 +00:00
}
2022-02-12 21:40:02 +00:00
if(command === 'clap' ||
command === 'claps') {
2022-02-12 21:51:22 +00:00
client.say(channel, `!kappagen sarimoDEAD sarimoGAME Bleep-Bloop!`);
2022-02-12 21:40:02 +00:00
}
if(command === 'hair' ||
command === 'hairflip') {
2022-02-12 21:51:22 +00:00
client.say(channel, `!kappagen sarimoHAIR sarimoBANG Bleep-Bloop!`);
2022-02-12 21:40:02 +00:00
}
if(command === 'hi' ||
command === 'hello') {
2022-02-12 21:51:22 +00:00
client.say(channel, `!kappagen sarimoKO sarimoNERD Bleep-Bloop!`);
2022-02-12 21:40:02 +00:00
}
if(command === 'hype' ||
command === 'train') {
2022-02-12 21:51:22 +00:00
client.say(channel, `!kappagen sarimoHYPE sarimoBITS Bleep-Bloop!`);
2022-02-12 21:40:02 +00:00
}
if(command === 'salt' ||
command === 'shoutout') {
2022-02-12 21:51:22 +00:00
client.say(channel, `!kappagen sarimoSALT sarimoRAGE Bleep-Bloop!`);
2022-02-12 21:40:02 +00:00
}
if(command === 'soup' ||
command === 'sup') {
client.say(channel, `!kappagen sarimoSOUP sarimoTRIP `);
2022-02-12 21:51:22 +00:00
client.say(channel, `/me Yo @${tags.username}, how goes it? Bleep-Bloop!`);
2022-02-12 21:40:02 +00:00
}
2022-02-12 21:32:34 +00:00
2022-02-12 07:21:15 +00:00
} // SUB | END
if(isModUp) { // MOD Start
// Shoutout
2022-02-12 05:30:23 +00:00
if(command === 'so' ||
command === 'shoutout') {
2022-02-12 21:51:22 +00:00
client.say(channel, `/me Roll the clip! Smash @${args.join(' ')}'s follow button at: https://twitch.tv/${args.join(' ')} Bleep-Bloop!`);
2022-02-12 05:30:23 +00:00
}
2022-02-12 21:11:26 +00:00
if(command === 'default' ||
command === 'sariboto') {
client.say(channel, `/color BlueViolet`);
2022-02-12 21:51:22 +00:00
client.say(channel, `/me I've reconfigured myself to @Sarimoko's preferences! Bleep-Bloop!`);
client.say(channel, `/emoteonlyoff `);
client.say(channel, `/followersoff `);
client.say(channel, `/slowoff `);
client.say(channel, `/subscribersoff `);
2022-02-12 21:11:26 +00:00
}
2022-02-12 21:51:22 +00:00
if(command === 'mute' ||
command === 'slap' ||
command === 'timeout' ||
command === 'warn') {
client.say(channel, `/timeout ${args.join(' ')} 33`);
client.say(channel, `/me Mods cast a 33sec Timeout Curse on @${args.join(' ')}, resistence to Bans is decreased!`);
client.say(channel, `!kappagen sarimoRAGE sarimoNERD`);
}
2022-02-12 07:21:15 +00:00
2022-02-12 20:27:34 +00:00
// MOD TOOLS
// CHAT MODES
// Emotes
// Slow
// Subs
// Normalizer
// uniquechat / uniquechatoff
// endpoll deletepoll maybe poll? idk how the bot would edit it
2022-02-12 18:33:43 +00:00
2022-02-12 19:55:28 +00:00
// Run Ads | TODO Fix Permissions...
2022-02-12 22:19:50 +00:00
//if(command === 'ad' ||
//command === 'ads' ||
//command === 'dab30' ||
//command === 'intermission') {
// client.say(channel, `/me @Sarimoko lets have a secret 30 second conversation with only our loyal subs while the ads run! Enjoy the commercials followering no subbing plebs! Wait @sarimoko makes money off ads too... Well this is awkward thank you peasants for not using adblocker! Wait I'm making it worse... Bleep-Bloop!`);
// client.say(channel, `!kappagen sarimoKO sarimoBANG`);
// client.commercial("channel", 30)
// .then((data) => {
// // data returns [channel, seconds]
// }).catch((err) => {
// //
// });
//}
2022-02-12 19:55:28 +00:00
// Block
2022-02-12 07:21:15 +00:00
} // MOD | END
2022-02-12 05:37:45 +00:00
}); // SCAN MSG | END
// TTV Re-Active
// ==================================
2022-02-12 19:26:39 +00:00
// TO-DO: Add Follower API
2022-02-12 19:55:28 +00:00
// https://api.twitch.tv/kraken/channels/MY_ID/follows?api_version=5&client_id=MY_CLIENT_ID&limit=1
2022-02-12 05:37:45 +00:00
client.on("anongiftpaidupgrade", (channel, username, userstate) => {
client.whisper(username, `BLEEP! BLOOP! Anon-Sub upgraded!!!`);
});
client.on("ban", (channel, username, reason, userstate) => {
2022-02-12 22:10:53 +00:00
client.say(channel, `/me BYE FELICIA!!! Critical hit from the MODs Ban-Hammer attack!`);
2022-02-12 05:37:45 +00:00
client.say(channel, `!kappagen BOP BOP BOP `);
});
client.on("cheer", (channel, userstate, message) => {
client.say(channel, `/me BLEEP! BLOOP! O'SNAP! Bit hype!!! sarimoBANG`);
client.say(channel, `!kappagen sarimoHYPE sarimoBITS`);
});
client.on("clearchat", (channel) => {
client.say(channel, `Chat Rule Reminder`);
client.say(channel, `/me 1. Do NOT feed the Trolls!`);
client.say(channel, `/me 2. Do NOT be a Troll!`);
client.say(channel, `/me 3. Do NOT be another brick in the wall!`);
});
client.on("giftpaidupgrade", (channel, username, sender, userstate) => {
// Huh? Tier 1 => Tier2
});
client.on("hosting", (channel, target, viewers) => {
2022-02-12 06:10:15 +00:00
client.say(channel, `/me BLEEP! BLOOP! @Sarimoko is auto-hosting various streamers! For more info: https://cord.sarimoko.com`);
2022-02-12 05:37:45 +00:00
});
client.on("join", (channel, username, self) => {
2022-02-12 06:23:09 +00:00
console.log('+1 IRC Chatter: ');
2022-02-12 05:37:45 +00:00
});
client.on("part", (channel, username, self) => {
2022-02-12 06:12:26 +00:00
console.log('-1 IRC Chatter');
2022-02-12 05:37:45 +00:00
// client.say(channel, `/me -1 Chatter! Where's my bounty hunters? Essemble the *air-qoutes* search-party *air-qoutes*`);
});
client.on("raided", (channel, username, viewers) => {
client.say(channel, `/me Welcome raiders!!! We may take your viewership, but we'll never take your FREEDOM!!!`);
client.say(channel, `!kappagen sarimoRAID sarimoFREEDOM sarimoRAID sarimoFREEDOM sarimoRAID sarimoFREEDOM`);
});
client.on("subgift", (channel, username, streakMonths, recipient, methods, userstate) => {
let senderCount = ~~userstate["msg-param-sender-count"]; // IDK
client.say(channel, `/me Thank you for supporting The Sarimoko Show with Gift-Subs!`);
});
client.on("submysterygift", (channel, username, numbOfSubs, methods, userstate) => {
let senderCount = ~~userstate["msg-param-sender-count"]; // IDK
client.say(channel, `/me BLEEP! BLOOP! Am I getting hacked? Anon just Gift-Subbed! If I get erased... I love you all!`);
});
client.on("resub", function (channel, username, months, message, userstate, methods) {
2022-02-12 06:25:06 +00:00
client.say(channel, `/me BLEEP! BLOOP! Legend re-sub! Thanks for your continued support!`);
2022-02-12 06:20:01 +00:00
client.say(channel, `!kappagen sarimoHYPE sarimoKO`);
2022-02-12 05:37:45 +00:00
});
client.on("subscription", function (channel, username, method, message, userstate) {
client.say(channel, `/me BLEEP! BLOOP! New subscriber! Spam your new emotes!!! Let's see you're fav!`);
client.say(channel, `!kappagen sarimoKO sarimoNERD`);
});
client.on("whisper", (from, userstate, message, self) => {
if (self) return;
client.say(channel, `/me Bleep! Bloop! Sariboto's Inbox (+1): SEXT Message Recieved!`);
});