Bots Home
|
Create an App
NanakoTho
Author:
nanakotho
Description
Source Code
Launch Bot
Current Users
Created by:
Nanakotho
//Set Title Variables var userTitles = [{user: '', title: ''}]; var usersWithTitles = ['']; //Set Spam Variables var spamStrings = ['']; //Good Grey Array var goodGreys = ['']; //Initalize function Init() { //Initial Notice cb.onEnter(setInitialNotice); //Check Message cb.onMessage(OnMessage); }; //Initial Notice function setInitialNotice(user) { //User Has Tokens if (user.has_tokens ) { //YES } else { //No tokens, no talking //Display Notice To Greys cb.chatNotice('Hi ' + user.user + '! Make Nanako hot! If you want to tell me all the things you want to do to me, please buy some tokens for me! ^_^', user.user, 'gold','red', 'bold'); }; //end of IF [User Has Tokens] }; //On Message function OnMessage(msg) { //Is this a command with a title? if (msg.m.startsWith('[') && msg.m.indexOf('/') > -1 ) { //YES //Remove Custom Title msg.m = msg.m.substring(msg.m.indexOf(']') + 1, msg.m.length).trim(); } else { //NO }; //end of IF [Is this a command with a title?] //Is this a command with an emoji? if (msg.m.trim().startsWith(':') && msg.m.indexOf('/') > -1 ) { //YES //Remove Emoji msg.m = msg.m.trim().substring(msg.m.indexOf('/') - 1, msg.m.length).trim(); } else { //NO }; //end of IF [Is this a command with an emoji?] //Handle Good Grey addGoodGrey(msg); //Handle Spam handleSpam(msg); //Handle Title titles(msg); //Handle Babies handleBabies(msg); //Handle PMs handlePMs(msg); //If is broadcaster if (msg.user == cb.room_slug ) { //YES } else { //NO //Is there a good grey? if (cbjs.arrayContains(goodGreys, msg.user) ) { //YES } else { //NO //Handle Greys handleGreys(msg); }; //end of IF [Is there a good grey?] }; //end of IF [If is broadcaster] }; //Handle Spam function handleSpam(msg) { //If user is mod or broadcaster if ((msg.is_mod && msg.m.startsWith('/spam')) || ((msg.user == cb.room_slug) && msg.m.startsWith('/spam')) ) { //YES //Hide the command from users msg['X-Spam'] = true; //Split the string into a function and property var functProp = msg.m.split(' '); //Initialize Spam var spamArray = ['']; //Combine title for (var i=1;i<functProp.length;i++ ) { //Push it spamArray.push(functProp[i]); }; //end of FOR [Combine title] //Join title together var spam = spamArray.join(' ').trim(); //Add the message to the smapStrings array spamStrings.push(spam); } else { //NO //Check Each Spam String for (var i=0;i<spamStrings.length;i++ ) { //If the message matches a spam string if (msg.m == spamStrings[i] ) { //YES //Mark the message as spam and hide it msg['X-Spam'] = true; //Exit when done break; } else { //NO }; //end of IF [If the message matches a spam string] }; //end of FOR [Check Each Spam String] }; //end of IF [If user is mod or broadcaster] }; //Handle Titles function titles(msg) { //Check broadcaster commands if (((msg.user == cb.room_slug) && msg.m.startsWith('/title')) || ((msg.is_mod == true) && msg.m.startsWith('/title')) ) { //YES //Hide the command from users msg['X-Spam'] = true; //Split the string into a function and property var functProp = msg.m.split(' '); //Get Username var userName = functProp[1]; //Initialize Title var userTitleArray = ['']; //Combine title for (var i=2;i<functProp.length;i++ ) { //Push it userTitleArray.push(functProp[i]); }; //end of FOR [Combine title] //Join title together var userTitle = userTitleArray.join(' ').trim(); //If the user already has a title if (cbjs.arrayContains(usersWithTitles, userName) ) { //YES //Change Existing User Title userTitles[usersWithTitles.indexOf(userName)].title = userTitle; } else { //NO //Create addable object var customTitle = {user: userName, title: userTitle}; //Add to titles userTitles.push(customTitle); usersWithTitles.push(userName); }; //end of IF [If the user already has a title] } else { //NO }; //end of IF [Check broadcaster commands] //Loop through custom title users for (var i=0;i<userTitles.length;i++ ) { //See if they need a custom title if (msg.user == userTitles[i].user ) { //Add title to message //Add Title msg.m = '[' + userTitles[i].title + '] ' + msg.m; //Exit when done break; } else { //NO }; //end of IF [See if they need a custom title] }; //end of FOR [Loop through custom title users] }; //MehBabies function handleBabies(msg) { //List Nanako's Names var names = ['Nanako','Nani']; //Get a Random Name var name = names[Math.floor(Math.random() * names.length)]; //List the Babies var babies = []; //Check each baby type for (var i=0;i<babies.length;i++ ) { //Check for babies if (msg.m.indexOf(babies[i]) > -1 ) { //Found a baby //Get rid of babies msg.m = msg.m.replace(babies[i], name); //Inform User Not To Use Babies cb.sendNotice('This is a CB notice about bb.', msg.user); //Exit when done break; } else { //NO }; //end of IF [Check for babies] }; //end of FOR [Check each baby type] }; //Handle Greys function handleGreys(msg) { //User Has Tokens? if (msg.has_tokens && msg.user != cb.room_slug ) { //YES } else { //NO //DEBUG - See the real message cb.log(msg.m); //Split message into array var msgArray = msg.m.split(" "); //nanako storage array var nanako = ['']; //For each word in the message array for (var i=0;i<msgArray.length;i++ ) { //Add nanakos nanako.push('Nanako :o'); }; //end of FOR [For each word in the message array] //Change message to nanakos msg.m = nanako.join(' ').trim(); }; //end of IF [User Has Tokens?] }; //Handle PMs function handlePMs(msg) { //Set up the PM strings var pmstr = ['PM ', 'pm ', ' PM', ' pm', 'PM?', 'pm?']; //Check for both PM and pm for (var i=0;i<pmstr.length;i++ ) { //Someone must be asking about a PM if (msg.m.indexOf(pmstr[i]) > -1 ) { //YES //Hide the PM request msg['X-Spam'] = true; //Inform the user how much a single PM costs cb.sendNotice('A single PM with one reply costs 10 tokens. Put "PM me please," in the tipnote. Thank you.', msg.user); //Exit the loop if found break; } else { //NO }; //end of IF [Someone must be asking about a PM] }; //end of FOR [Check for both PM and pm] }; //Add Grey Exception function addGoodGrey(msg) { //If user is mod or broadcaster if ((msg.is_mod && msg.m.startsWith('/addgrey')) || ((msg.user == cb.room_slug) && msg.m.startsWith('/addgrey')) ) { //YES //Hide the command from users msg['X-Spam'] = true; //Split the string into a function and property var functProp = msg.m.split(' '); //Initialize Spam goodGreys.push(functProp[1]); //Announce the Good Grey cb.chatNotice( functProp[1] + ' has been inducted to the Good Grey program and can now talk.', '', 'gold','red', 'bold'); } else { //NO //Check Each Spam String for (var i=0;i<spamStrings.length;i++ ) { //If the message matches a spam string if (msg.m == spamStrings[i] ) { //YES //Mark the message as spam and hide it msg['X-Spam'] = true; //Exit when done break; } else { //NO }; //end of IF [If the message matches a spam string] }; //end of FOR [Check Each Spam String] }; //end of IF [If user is mod or broadcaster] }; //Start NanakoTho Init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.