// B O T O require('dotenv').config(); const tmi = require('tmi.js'); 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(); // RNG User const rp = require('request-promise'); 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); } 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)]; }); } // RNG END // 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 if(self || !message.startsWith('!')) return; // Command Parser const args = message.slice(1).split(' '); const command = args.shift().toLowerCase(); // !COMMAND => command // CMD | CHAT COMMANDS | Start if(command === 'rnguser') { // Get a random user but skip the user requesting a random user getRandomChatter(channel, { skipList: [ tags.username ] }) .then(user => { if(user === null) { client.say(channel, `Sorry ${tags.username}, this is embarrassing... There was no one to choose from! #smallstreamerproblems Bleep-Bloop!`); } else { let { name, type } = user; client.say(channel, `${tags.username} exluded, at random I choose "${name}" cuz they're such an amazing ${type}!`); } }) .catch(err => console.log('[ERR]', err)); } // CMD | Color if(command === 'color') { // 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. client.say(channel, `/color ${args.join(' ')}`); client.say(channel, `/me @${tags.username} has changed my color to ${args.join(' ')}`); 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!`); } // 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/`); } // CMD | Dice Roll if(command === 'dice' || command === 'roll') { const result = Math.floor(Math.random() * 6) + 1; client.say(channel, `/me RNGesus has rolled @${tags.username} a ${result}!`); } // CMD | Dojo if(command === 'dojo' || command === 'guide') { client.say(channel, `/me The Dojo | DIY's & 1on1's available at: https://cord.sarimoko.com/`); } // CMD | Lurk 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 `); } // CMD | Raid 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!`); } // CMD | Rule if(command === 'rule' || command === 'rules') { 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!`); } // CMD | Sale 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`); } // CMD | Time if(command === 'time' || command === 'pst' || command === 'pac') { client.say(channel, `/me Bleep-Bloop! PST | 2-Pac Standard Time`); } // CMD | Trip 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...`); } // CMD | Tune 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/`); } // 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.`); } // CMD | Whom if(command === 'whom' || command === 'who' || command === 'cv' || command === 'resume' || command === 'portfolio') { client.say(channel, `/me Who's asking? ${tags.username} if you're a cop you HAVE to tell me, right?! CV/Portfolio/Resume is available at: https://whom.sarimoko.com/ `); } // CMD | Wish 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/ `); } // 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' || command === 'facebook' || 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 `); } if(command === 'twitter' || command === 'tweet') { client.say(channel, `/me Twitter | https://twitter.com/sarimoko_o `); } // MINI GAME // TODO: // Uptime // Viewers // Followage // Followers // CHAT COMMANDS | End if(isSub) { // SUB | Start // FX | K A P P A G E N S if(command === 'bg' || command === 'notgg') { client.say(channel, `!kappagen sarimoDEAD sarimoGAME Bleep-Bloop!`); } if(command === 'clap' || command === 'claps') { client.say(channel, `!kappagen sarimoDEAD sarimoGAME Bleep-Bloop!`); } if(command === 'hair' || command === 'hairflip') { client.say(channel, `!kappagen sarimoHAIR sarimoBANG Bleep-Bloop!`); } if(command === 'hi' || command === 'hello') { client.say(channel, `!kappagen sarimoKO sarimoNERD Bleep-Bloop!`); } if(command === 'hype' || command === 'train') { client.say(channel, `!kappagen sarimoHYPE sarimoBITS Bleep-Bloop!`); } if(command === 'salt' || command === 'shoutout') { client.say(channel, `!kappagen sarimoSALT sarimoRAGE Bleep-Bloop!`); } if(command === 'soup' || command === 'sup') { client.say(channel, `!kappagen sarimoSOUP sarimoTRIP `); client.say(channel, `/me Yo @${tags.username}, how goes it? Bleep-Bloop!`); } } // SUB | END if(isModUp) { // MOD Start // Shoutout if(command === 'so' || command === 'shoutout') { client.say(channel, `/me Roll the clip! Smash @${args.join(' ')}'s follow button at: https://twitch.tv/${args.join(' ')} Bleep-Bloop!`); } if(command === 'default' || command === 'sariboto') { client.say(channel, `/color BlueViolet`); 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 `); } 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`); } // MOD TOOLS // CHAT MODES // Emotes // Slow // Subs // Normalizer // uniquechat / uniquechatoff // endpoll deletepoll maybe poll? idk how the bot would edit it // Run Ads | TODO Fix Permissions... //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) => { // // // }); //} // Block } // MOD | END }); // SCAN MSG | END // TTV Re-Active // ================================== // TO-DO: Add Follower API // https://api.twitch.tv/kraken/channels/MY_ID/follows?api_version=5&client_id=MY_CLIENT_ID&limit=1 client.on("action", (channel, userstate, message, self) => { // Don't listen to my own messages.. if (self) return; // Do your stuff. }); client.on("anongiftpaidupgrade", (channel, username, userstate) => { client.whisper(username, `BLEEP! BLOOP! Anon-Sub upgraded!!!`); }); client.on("ban", (channel, username, reason, userstate) => { client.say(channel, `/me BYE FELICIA!!! Critical hit from the MODs Ban-Hammer attack!`); client.say(channel, `!kappagen BOP BOP BOP `); }); client.on("chat", (channel, userstate, message, self) => { // Don't listen to my own messages.. if (self) return; // Do your stuff. }); 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("connected", (address, port) => { // Do your stuff. console.log('Connected '); }); client.on("connecting", (address, port) => { // Do your stuff. console.log('Connecting '); }); client.on("disconnected", (reason) => { // Do your stuff. console.log('Dis-Connected '); }); client.on("emoteonly", (channel, enabled) => { // Chatmode console.log('CHAT MODE: Emotes Only '); }); client.on("emotesets", (sets, obj) => { // Here are the emotes I can use: console.log('Emote Sets: IDK WHAT TO DO WITH THESE '); console.log(obj); }); client.on("followersonly", (channel, enabled, length) => { // Do your stuff. }); client.on("giftpaidupgrade", (channel, username, sender, userstate) => { // Huh? Tier 1 => Tier2 }); client.on("hosted", (channel, username, viewers, autohost) => { // Do your stuff. }); client.on("hosting", (channel, target, viewers) => { client.say(channel, `/me BLEEP! BLOOP! @Sarimoko is auto-hosting various streamers! For more info: https://cord.sarimoko.com`); }); client.on("join", (channel, username, self) => { console.log('+1 IRC Chatter: '); }); client.on("logon", () => { // Do your stuff. console.log('Logon '); }); client.on("message", (channel, userstate, message, self) => { // Don't listen to my own messages.. if (self) return; // Handle different message types.. switch(userstate["message-type"]) { case "action": // This is an action message.. break; case "chat": // This is a chat message.. break; case "whisper": // This is a whisper.. break; default: // Something else ? break; } }); client.on("messagedeleted", (channel, username, deletedMessage, userstate) => { // Do your stuff. }); client.on("mod", (channel, username) => { // Modded. }); client.on("mods", (channel, mods) => { // List }); client.on("notice", (channel, msgid, message) => { // Do your stuff. }); client.on("part", (channel, username, self) => { console.log('-1 IRC Chatter'); // client.say(channel, `/me -1 Chatter! Where's my bounty hunters? Essemble the *air-qoutes* search-party *air-qoutes*`); }); //client.on("ping", () => {}); //client.on("pong", (latency) => {}); client.on("r9kbeta", (channel, enabled) => { // Do your stuff. }); 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("raw_message", (messageCloned, message) => { console.log(message.raw); }); client.on("reconnect", () => { // Do your stuff. console.log('Re-Connecting '); }); client.on("resub", function (channel, username, months, message, userstate, methods) { client.say(channel, `/me BLEEP! BLOOP! Legend re-sub! Thanks for your continued support!`); client.say(channel, `!kappagen sarimoHYPE sarimoKO`); }); client.on("roomstate", (channel, state) => { // Do your stuff. console.log('Roomstate '); }); client.on("serverchange", (channel) => { // Do your stuff. console.log('Server Change '); }); client.on("slowmode", (channel, enabled, length) => { // Do your stuff. console.log('CHAT MODE: Slow Mode enabled! '); }); client.on("subgift", (channel, username, streakMonths, recipient, methods, userstate) => { let senderCount = ~~userstate["msg-param-sender-count"]; // IDK client.say(channel, (username) `gifted` (recipient) `a Gift-Sub! Thank for the support & sharing the emote spam!`); client.say(channel, `!kappagen sarimoKO sarimoNERD`); }); client.on("submysterygift", (channel, username, numbOfSubs, methods, userstate) => { let senderCount = ~~userstate["msg-param-sender-count"]; // IDK client.say(channel, `Anon Gift-Sub gifted!`); client.say(channel, `/me Wait, what?! Am I getting hacked? If I get erased... I love you all! Bleep-Bloop!`); }); client.on("subscribers", (channel, enabled) => { // Chatmode client.say(channel, `CHAT MODE: Subscribers only!`); }); 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("timeout", (channel, username, reason, duration, userstate) => { client.say(channel, `I know this only frustrates you more, but please take this time to cooldown.`); }); client.on("unhost", (channel, viewers) => { client.say(channel, `/me @Sarimoko has turned if hosting, please standby for further instruction!`); }); client.on("unmod", (channel, username) => { client.say(channel, `Oof, modship`); }); client.on("vips", (channel, vips) => { client.say(channel, `@Sarimoko is fortunate to have many great viewers but these VIPs are a few specifically to thank!`); }); client.on("whisper", (from, userstate, message, self) => { if (self) return; client.say(channel, `/me Bleep! Bloop! Sariboto's Inbox (+1): SEXT Message Recieved!`); });