Bots Home
|
Create an App
LittleBoo's Personal Bot
Author:
littleboobottester
Description
Source Code
Launch Bot
Current Users
Created by:
Littleboobottester
var tipperArray = new Array; var numTippers = 0; var currentKing = ""; var kingTip = 0; var kingMin = 100 var initialize = 0; var leaderArray = [['',0],['',0],['',0]]; var singleArray = [cb.settings.singleTipper,cb.settings.singleTip]; var leaderTimer = parseInt(cb.settings.leaderTimer); var leaderboardSpam = 0; var notifierSpamTGL = 0; var notifierRotate = 0; var crew = new Array(); var friendMembers = new Array(); var crewMembers = new Array(); var crew2 = new Array(); var crewMembers2 = new Array(); var tempStr2 = ""; var ghostMembers = new Array(); var tempStr = ""; var botVersion = "2.0"; // settings cb.settings_choices = [ {name: 'notifierTip', label: 'Would you like to display a message when a user tips?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'tipMessage', label: 'Enter the message you would like to display.', type: 'str', minLength: 1, maxLength: 1000, defaultValue: 'Thank you!'}, {name: 'tipMessageMin', label: 'Enter the minimum tip amount that you would like to trigger the message', type: 'int', minValue: 1, maxValue: 1000000, defaultValue: 10}, {name: 'singleTipper', label: 'Enter the name of the user who gave you your highest single tip:', type: 'str', minLength: '0', maxLength: '100', defaultValue: '', required: false}, {name: 'singleTip', label: 'Enter the value of your highest single tip:', type: 'int', minValue: 0, maxValue: 100000, defaultValue: 0, required: false}, {name: 'singleTitle', label: 'Enter the title you would like your highest single tipper to have. (Leave it blank for no title)', type: 'str', minLength: '0', maxLength: '100', defaultValue: 'Sugardaddy', required: false}, {name: 'singleGif', label: 'Enter the image you would like your highest single tipper to have. (Leave it blank for no image)', type: 'str', minLength: '0', maxLength: '100', defaultValue: '', required: false}, {name: 'firstTitle', label: 'Enter the title you would like your 1st place tipper to have (leaderboard). (Leave it blank for no title)', type: 'str', minLength: '0', maxLength: '100', defaultValue: '1st', required: false}, {name: 'firstGif', label: 'Enter the image you would like your 1st place tipper to have (leaderboard). (Leave it blank for no image)', type: 'str', minLength: '0', maxLength: '100', defaultValue: '', required: false}, {name: 'secondTitle', label: 'Enter the title you would like your 2nd place tipper to have. (Leave it blank for no title)', type: 'str', minLength: '0', maxLength: '100', defaultValue: '2nd', required: false}, {name: 'secondGif', label: 'Enter the image you would like your 2nd place tipper to have. (Leave it blank for no image)', type: 'str', minLength: '0', maxLength: '100', defaultValue: '', required: false}, {name: 'thirdTitle', label: 'Enter the title you would like your 3rd place tipper to have. (Leave it blank for no title)', type: 'str', minLength: '0', maxLength: '100', defaultValue: '3rd', required: false}, {name: 'thirdGif', label: 'Enter the image you would like your 3rd place tipper to have. (Leave it blank for no image)', type: 'str', minLength: '0', maxLength: '100', defaultValue: '', required: false}, {name: 'leaderBoard', label: 'Would you like to use the Leader Board feature?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'leaderBoardSpam', label: 'Do you want to periodically announce the top three tippers?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'leaderTimer', label: 'Change this value if you would like the Leaderboard announcement to happen at a different interval:', type: 'int', minValue: 1, maxValue: 60, defaultValue: 5}, {name: 'textBackground', label: 'Sets tip message back grounds:', type: 'str', minLength: 0, maxLength: 60, required: true, defaultValue: '#ffffff' }, { name: 'crewName', label: 'Name of Club 1?', type: 'str', minLength: 0, maxLength: 50, required: true, defaultValue: '[Boo Buddies]' }, { name: 'crewTag', label: 'Tag for Club 1?', type: 'str', minLength: 0, maxLength: 20, required: false, defaultValue: '[BooBuddy]' }, { name: 'crewList', label: 'List of Club 1 members, separated by space (their CB usernames exactly)', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'useCrewColor', type: 'choice', label: 'Change highlight color for Club 1?', choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, { name: 'crewColor', label: 'Highlight color to use for Club 1', type: 'str', minLength: 0, maxLength: 32, required: true, defaultValue: '#ffffff' }, { name: 'club1image', label: 'Image for club 1', type: 'str', minLength: 0, maxLength: 32, required: false, }, { name: 'tipamount', type: 'int', minValue: 1, defaultValue: 400, label: 'Minimum tokens required for club 1' }, { name: 'tipmsg', type: 'str', minLength: 8, maxLength: 128, label: "Tip thank you message for joining club 1", defaultValue: "Thank you for joining!" }, { name: 'crewName2', label: 'What the name of Club number 2?', type: 'str', minLength: 0, maxLength: 50, required: true, defaultValue: '[Club 2]' }, { name: 'crewTag2', label: 'Tag for club 2?', type: 'str', minLength: 0, maxLength: 20, required: false, defaultValue: '[Club2]' }, { name: 'crewList2', label: 'List of Club 2 members, separated by space (their CB usernames exactly)', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'club2image', label: 'Image for club 2', type: 'str', minLength: 0, maxLength: 32, required: false, }, ]; //color codes { var purple = cb.settings.textBackground; } //functions { /** Function ==> Purpose tipperArrayPopulate ==> adds tippers to the tipperArray findTipper ==> finds and returns the index of a user setTipTitles ==> called from onMessage. appends the user's tips to the beginning of the message leaderSpam ==> spams the leaderboard every 5 minutes leaderSpamTimer ==> the actual timer for leaderSpam showLeaderBoard ==> called when /leaderboard is used. shows the leaderboard notifierSpam ==> called from init, starts the timer for notifer spam notiferSpamTimer ==> the actual timer for notifierSpam **/ { function tipperArrayPopulate(user) { tipperArray[numTippers] = new Array; tipperArray[numTippers][0] = user; tipperArray[numTippers][1] = 0; tipperArray[numTippers][2] = 0; numTippers++; } function findTipper(user) { //find the index of the user for(var i = 0; i < tipperArray.length; i++) { if(tipperArray[i][0] == user) { break; } } //the user is not in the array. add him and call findTipper if(i == tipperArray.length) { tipperArrayPopulate(user); findTipper(user); } return i; } function setTipTitles(user, message) { if(user == singleArray[0]) { if(user == currentKing) { var m = cb.settings.singleTitle + ' ' + cb.settings.singleGif + ' |' + tipperArray[findTipper(user)][1] + '| ' + cb.settings.firstGif + ' : ' + message; } else { var m = cb.settings.singleTitle + ' ' + cb.settings.singleGif + ' |' + tipperArray[findTipper(user)][1] + '| ' + message; } } else if(user == currentKing) { var m = cb.settings.firstTitle + ' ' + cb.settings.firstGif + ' |' + tipperArray[findTipper(user)][1] + '| ' + message; } else if(user == leaderArray[1][0] && leaderArray[0][1] >= parseInt(cb.settings.kingMin)) { var m = cb.settings.secondTitle + ' ' + cb.settings.secondGif + ' |' + tipperArray[findTipper(user)][1] + '| ' + message; } else if(user == leaderArray[2][0] && leaderArray[0][1] >= parseInt(cb.settings.kingMin)) { var m = cb.settings.thirdTitle + ' ' + cb.settings.thirdGif + ' |' + tipperArray[findTipper(user)][1] + '| ' + message; } else if(tipperArray[findTipper(user)][2] == 1) { var m = cb.settings.bigTipTitle + ' ' + cb.settings.bigTipGif + ' |' + tipperArray[findTipper(user)][1] + '| ' + message; } else { var m = '|' + tipperArray[findTipper(user)][1] + '| ' + message; } return m; } } function leaderSpam() { cb.setTimeout(leaderSpamTimer,cb.settings.leaderTimer*60000); } function leaderSpamTimer() { if(leaderboardSpam == 1) { if(cb.settings.singleTipper.length > 1) { cb.sendNotice ( 'Highest Single Tip of All Time: ' + singleArray[0] + ' : ' + singleArray[1] ,'',purple); } cb.sendNotice('Leaderboard!','',purple); cb.sendNotice ( leaderArray[0][0] + ' : ' + leaderArray[0][1] + '\n' + leaderArray[1][0] + ' : ' + leaderArray[1][1] + '\n' + leaderArray[2][0] + ' : ' + leaderArray[2][1] ); cb.sendNotice ( '' ,'',purple); leaderSpam(); } } function showLeaderBoard(from) { if(cb.settings.leaderBoard == 'Yes') { if(cb.settings.singleTipper.length > 1) { cb.sendNotice ( 'Highest Single Tip of All Time: ' + singleArray[0] + ' : ' + singleArray[1] ,'',purple); } cb.sendNotice ( 'Today\'s Leaderboard!' ,from,purple ); cb.sendNotice ( leaderArray[0][0] + ' : ' + leaderArray[0][1] + '\n' + leaderArray[1][0] + ' : ' + leaderArray[1][1] + '\n' + leaderArray[2][0] + ' : ' + leaderArray[2][1] ,from); cb.sendNotice ( '' ,from,purple); } else { cb.sendNotice('The room host has decided not to use the Leaderboard feature.',from,purple); } } function checkTotal(user, tip) { //check the highest single tip if(tip > singleArray[1] && user != singleArray[0]) { cb.sendNotice ( 'We have a new all time highest single tip!\n' + user + ' has surpassed ' + singleArray[0] + ' with a tip of ' + tip + '!' ); singleArray[0] = user; singleArray[1] = tip; } else if(tip > singleArray[1] && user == singleArray[0]) { cb.sendNotice ( 'We have a new all time highest single tip!\n' + user + ' has surpassed his own record with a tip of ' + tip + '!' ); singleArray[1] = tip; } } function notifierSpam() { cb.setTimeout(notifierSpamTimer,cb.settings.spamTimer*60000); } function notifierSpamTimer() { if(notifierSpamTGL == 1) { switch(notifierRotate) { case 0: { cb.sendNotice(cb.settings.spamMessage1,'',purple); notifierRotate = 1; break; } case 1: { cb.sendNotice(cb.settings.spamMessage2,'',purple); notifierRotate = 2; break; } case 2: { cb.sendNotice(cb.settings.spamMessage3,'',purple); notifierRotate = 0; break; } } cb.sendNotice(cb.settings.bigTipMSG,'',purple); notifierSpam(); } } } //onMessage { cb.onMessage(function (msg) { //turn the message into an array var message = msg['m'].split(' '); if(msg['m'].charAt(0) == '/') { msg['X-Spam'] =true; var m = ""; var i; switch(message[0]) { case '/leaderboard': { showLeaderBoard(msg['user']); break; } } } //tip titles if(msg['m'].charAt(0) != '/' && msg['user'] != cb.room_slug) { msg['m'] = setTipTitles(msg['user'], msg['m']); } return msg; }); } //onTip { cb.onTip(function (tip) { tipperArray[findTipper(tip['from_user'])][1] += parseInt(tip['amount']); if(parseInt(tip['amount']) >= parseInt(cb.settings.bigTipMin) && tipperArray[findTipper(tip['from_user'])][2] == 0) { tipperArray[findTipper(tip['from_user'])][2] = 1; } if(tip['from_user'] != currentKing && parseInt(tipperArray[findTipper(tip['from_user'])][1]) > kingTip && parseInt(tipperArray[findTipper(tip['from_user'])][1]) >= parseInt(cb.settings.kingMin)) { if(currentKing != '') { cb.sendNotice('You have been dethroned by ' + tip['from_user'] + ', but revenge is sweet...', currentKing, purple); } cb.sendNotice('We have a new ' + cb.settings.firstTitle + '!\nAll hail ' + tip['from_user'] + '!','',purple); currentKing = tip['from_user']; kingTip = parseInt(tipperArray[findTipper(tip['from_user'])][1]); } else if(tip['from_user'] == currentKing) { kingTip = parseInt(tipperArray[findTipper(tip['from_user'])][1]); } if(cb.settings.leaderBoard == 'Yes') { //create an array of the names var nameArray = new Array; for(var i = 0; i < leaderArray.length; i++) { nameArray[i] = leaderArray[i][0]; } //the user is not currently in the top 3 if(!cbjs.arrayContains(nameArray,tip['from_user'])) { if(tipperArray[findTipper(tip['from_user'])][1] > leaderArray[0][1]) { leaderArray[2][0] = leaderArray[1][0]; leaderArray[2][1] = leaderArray[1][1]; leaderArray[1][0] = leaderArray[0][0]; leaderArray[1][1] = leaderArray[0][1]; leaderArray[0][0] = tip['from_user']; leaderArray[0][1] = tipperArray[findTipper(tip['from_user'])][1]; } else if(tipperArray[findTipper(tip['from_user'])][1] < leaderArray[0][1] && tipperArray[findTipper(tip['from_user'])][1] > leaderArray[1][1] || tipperArray[findTipper(tip['from_user'])][1] == leaderArray[0][1]) { leaderArray[2][0] = leaderArray[1][0]; leaderArray[2][1] = leaderArray[1][1]; leaderArray[1][0] = tip['from_user']; leaderArray[1][1] = tipperArray[findTipper(tip['from_user'])][1]; } else if(tipperArray[findTipper(tip['from_user'])][1] < leaderArray[1][1] && tipperArray[findTipper(tip['from_user'])][1] > leaderArray[2][1] || tipperArray[findTipper(tip['from_user'])][1] == leaderArray[1][1]) { leaderArray[2][0] = tip['from_user']; leaderArray[2][1] = tipperArray[findTipper(tip['from_user'])][1]; } } //the user is currently in the top 3 else { //the user is already #1 if(leaderArray[0][0] == tip['from_user']) { leaderArray[0][1] = tipperArray[findTipper(tip['from_user'])][1]; } //the user is #2 and is moving to #1 if(leaderArray[1][0] == tip['from_user'] && tipperArray[findTipper(tip['from_user'])][1] > parseInt(leaderArray[0][1])) { leaderArray[1][0] = leaderArray[0][0]; leaderArray[1][1] = leaderArray[0][1]; leaderArray[0][0] = tip['from_user']; leaderArray[0][1] = parseInt(tipperArray[findTipper(tip['from_user'])][1]); } //the user is #2 and is not moving to #1 else if(leaderArray[1][0] == tip['from_user'] && tipperArray[findTipper(tip['from_user'])][1] <= parseInt(leaderArray[0][1])) { leaderArray[1][1] = parseInt(tipperArray[findTipper(tip['from_user'])][1]); } //the user is #3 and is moving to #2 else if(leaderArray[2][0] == tip['from_user'] && tipperArray[findTipper(tip['from_user'])][1] > parseInt(leaderArray[1][1])) { leaderArray[2][0] = leaderArray[1][0]; leaderArray[2][1] = leaderArray[1][1]; leaderArray[1][0] = tip['from_user']; leaderArray[1][1] = parseInt(tipperArray[findTipper(tip['from_user'])][1]); } //the user is #3 and is moving to #1 else if(leaderArray[2][0] == tip['from_user'] && tipperArray[findTipper(tip['from_user'])][1] > parseInt(leaderArray[0][1])) { leaderArray[2][0] = leaderArray[1][0]; leaderArray[2][1] = leaderArray[1][1]; leaderArray[1][0] = leaderArray[0][0]; leaderArray[1][1] = leaderArray[0][1]; leaderArray[0][0] = tip['from_user']; leaderArray[0][1] = parseInt(tipperArray[findTipper(tip['from_user'])][1]); } //the user is #3 and is not moving else if(leaderArray[2][0] == tip['from_user'] && tipperArray[findTipper(tip['from_user'])][1] <= parseInt(leaderArray[1][1])) { leaderArray[2][1] = tipperArray[findTipper(tip['from_user'])][1]; } if(leaderArray[2][0] == leaderArray[1][0] || leaderArray[2][0] == leaderArray[0][0]) { leaderArray[2][0] = ''; leaderArray[2][1] = 0; } if(leaderArray[1][0] == leaderArray[0][0]) { leaderArray[1][0] = ''; leaderArray[1][1] = 0; } } } checkTotal(tip['from_user'], tip['amount']); if(cb.settings.notifierTip == 'Yes' && parseInt(tip['amount']) >= cb.settings.tipMessageMin) { cb.sendNotice(cb.settings.tipMessage,tip['from_user'],purple); } if(cb.settings.notifierTip == 'Yes' && parseInt(tip['amount']) >= cb.settings.tipamount) { newCrewtip= tip['from_user']; cb.sendNotice(cb.settings.tipmsg,'',purple); crewMembers.push(newCrewtip); return newCrewtip; } }); } //init { if(initialize == 0) { if(cb.settings.leaderBoardSpam == 'Yes') { leaderboardSpam = 1; leaderSpam(); } if(cb.settings.notifierSpam == 'Yes') { notifierSpamTGL = 1; notifierSpam(); } } } /* * handle messages from users */ cb.onMessage(function(message) { name = message['user']; msg = message['m']; commandProcessed = false; modelName = cb.room_slug; var isModel = (name == cb.room_slug); // handle commands from model and mods if ( isModel ) { if (msg.indexOf('/club1list') > -1) { message['background'] = '#FF4500'; message['c'] = '#000000'; message['m'] = "Let me fetch that list for ya " + name + "!"; showClub1Members(); } commandProcessed = true; if (msg.indexOf('/club2list') > -1) { message['background'] = '#FF4500'; message['c'] = '#000000'; message['m'] = "Let me fetch that list for ya " + name + "!"; showClub2Members(); } commandProcessed = true; if (msg.indexOf('/addclub1') > -1) { msg['X-Spam'] = true; newCrew = addCrew(msg); message['background'] = '#FF4500'; message['c'] = '#000000'; message['m'] = name + " just added " + newCrew + " to " + crewName +"!"; } commandProcessed = true; if (msg.indexOf('/addclub2') > -1) { msg['X-Spam'] = true; newCrew2 = addCrew2(msg); message['background'] = '#FF4500'; message['c'] = '#000000'; message['m'] = name + " just added " + newCrew2 + " to " + crewName2 +"!"; } commandProcessed = true; } if (!commandProcessed) { // color background/foreground and tag if crew member if ( isCrew(name) ) { if ( useCrewColor ) { message['background'] = cb.settings.crewColor; message['c'] = '#000000'; } message['m'] = crewTag + " " + message['m'] + cb.settings.club1image; } if ( isCrew2(name) ) { message['m'] = crewTag2 + " " + message['m'] + cb.settings.club2image; } } return message; }); /* * Is user in crew? return true || false */ function isCrew(un) { var yesCrew =0; if(crewMembers.length > 0) { for(i=0; i < crewMembers.length; i++) { if (crewMembers[i] == un) yesCrew = 1; } if (yesCrew == 1) { return true; } else { return false; } } } function isCrew2(un) { var yesCrew2 =0; if(crewMembers2.length > 0) { for(i=0; i < crewMembers2.length; i++) { if (crewMembers2[i] == un) yesCrew2 = 1; } if (yesCrew2 == 1) { return true; } else { return false; } } } /* * add to crew members */ function addCrew(msg) { var tempMsgArray = new Array(); var newCrew = ""; tempMsgArray = msg.split(' '); newCrew = tempMsgArray[1]; crewMembers.push(newCrew); return newCrew; } function addCrew2(msg) { var tempMsgArray = new Array(); var newCrew2 = ""; tempMsgArray = msg.split(' '); newCrew2 = tempMsgArray[1]; crewMembers2.push(newCrew2); return newCrew2; } /* * show list of crew members */ function showClub1Members() { var crewNames = ""; var divStr = ""; var divChr = "_"; var maxDivLen = 50; for (xx = 0; xx < crewMembers.length; xx++) { crewNames += crewMembers[xx] + ' '; } divStr = makeDiv('_', crewNames.length, maxDivLen); cb.chatNotice(divStr +'\n' + crewName + ' Members\n' + crewNames + '\n' + divStr); } function showClub2Members() { var crewNames2 = ""; var divStr2 = ""; var divChr2 = "_"; var maxDivLen2 = 50; for (xx = 0; xx < crewMembers2.length; xx++) { crewNames2 += crewMembers2[xx] + ' '; } divStr2 = makeDiv('_', crewNames2.length, maxDivLen2); cb.chatNotice(divStr2 +'\n' + crewName2 + ' Members\n' + crewNames2 + '\n' + divStr2); } /* * build notice divider */ function makeDiv(divChr, strLen, maxDivLen) { var divLen = 0; var divStr = ""; if (strLen > maxDivLen) { divLen = maxDivLen; } else { divLen = strLen; } while (divStr.length < divLen) { divStr = divChr + divStr; } return divStr; } /* * Load settings for crew list */ function loadSettings() { var divStr = ""; divStr = makeDiv('*', 20, 20); cb.log("loading config"); crewName = cb.settings.crewName; crewTag = cb.settings.crewTag; crewName2 = cb.settings.crewName2; crewTag2 = cb.settings.crewTag2; cb.log("loading club"); cb.chatNotice("Loading LittleBoo_'s personal room bot!"); cb.chatNotice('Loading ' + crewName + " and " + crewName2); if (cb.settings.crewList) { crewMembers = cb.settings.crewList.split(' '); cb.chatNotice('Club 1 Members: ' + crewMembers.length); } if (cb.settings.crewList2) { crewMembers2 = cb.settings.crewList2.split(' '); cb.chatNotice('Club 2 Members: ' + crewMembers2.length); } } // use colors for crew? if (cb.settings.useCrewColor == 'Yes') { useCrewColor = true; } else { useCrewColor = false; } cb.log("finished loading club"); loadSettings();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.