Bots Home
|
Create an App
Her #1 Valentine - Fixed
Author:
smoker919_
Description
Source Code
Launch Bot
Current Users
Created by:
Smoker919_
// Her #1 Valentine V.1c // Cb settings // // loverTip : Minimum amount to become a lover - Default : 25. // tipMode : Choice "SINGLE" or "MULTI". // graphicOwner : Choice of graphic Heart for owner. // noticeTime : Number of minutes between BOT notifications - 1 to 10 Default : 3). // addNotice : Additional message to the standard notice // messColor : Choice of notices Color (Default : Cb Orange DC5500). // permanentString : Permanent Lovers // cb.settings_choices = [ {name: 'loverTip', label: 'Minimum to become a Lover ', type: 'int', minValue: 1, defaultValue: 25 }, {name: 'tipMode', label: 'Mode SINGLE - The user must Tip the minimum in one single Tip. Mode MULTI - All the Tips of the user count, like a Goal', type: 'choice', choice1: 'SINGLE', choice2: 'MULTI', defaultValue: 'SINGLE' }, {name: 'graphicOwner', label: 'Graphic in your messages ?', type: 'choice', choice1: 'No', choice2: '1 : Two lovely pink hearts', choice3: '2 : A little pink jumping heart', choice4: '3 : The Lover beating heart', defaultValue: 'No' }, {name: 'noticeTime', label: 'Minute(s) between Notices ', type: 'int', minValue: 1, maxValue: 10, defaultValue: 3 }, {name: 'messColor', label: 'Notices Color', type: 'choice', choice1: 'Orange', choice2: 'Blue', choice3: 'Pink', choice4: 'Brown', choice5: 'Black', defaultValue: 'Orange' }, {name: 'addNotice', label: 'Additional message to the standard notice', type: 'str', minLength: 0, maxLength: 10240, required: false }, {name: 'permanentString', label: 'Permanent Lovers, if any, separated by space', type: 'str', minLength: 0, maxLength: 10240, required: false }, ]; // Variables // // tipMode : Tip mode chosen by the broadcaster : 1 "SINGLE", 2 "MULTI" // messColor : Room Notices color. // actionIndic : To stop Bot notifications if no action (message or Tip) // loverList : List of Lovers of the day // tipperList : List of Tippers (in case of option Tipmode : MULTI ) // loverNb : Number of Lovers // tipperNb : Number of Tippers // permNb : Number of Permanent Lovers // permOwner : Broadcaster is in the string list of permanent 0/1 // botNotice : BOT Notification regularly sent to the room var tipMode = 0; var messColor = ''; var actionIndic = 0; var loverList = {}; var loverNb = 0; var tipperList = {}; var tipperNb=0; var permNb = 0; var permOwner = 0; var graphicOwner ="No"; var graphicJpg = " :v__jpgHeart "; var graphicAlt = " :v__altHeart "; var graphicBtg = " :v__btgHeart "; var graphicLov = " :v__lvrHeart "; var graphicStt = " :v__sttHeart "; var graphicThk = " :v__thkHeart "; var graphicShy = " :v__shyHeart "; var botNotice = ""; // // Init : // Initialize list of Lover and list of Permanent Lovers // Information to the Owner. // First call to the Bot notification function. // function init() { switch (cb.settings.graphicOwner) { case "No" : graphicOwner = ""; break; case "1 : Floating hearts" : graphicOwner = graphicAlt ; break; case "2 : Breaking heart" : graphicOwner = graphicJpg ; break; case "3 : The Lover beating heart" : graphicOwner = graphicBtg ; break; } switch (cb.settings.messColor) { case 'Orange' : messColor = "#DC5500"; break; case 'Blue' : messColor = "#9A2EFE"; break; case 'Pink' : messColor = "#F5A9A9"; break; case 'Brown' : messColor = "#8A4B08"; break; case 'Black' : messColor = "#000000"; break; } tipMode = cb.settings.tipMode == "SINGLE" ? 1 : 2 ; var addNotice = cb.settings.addNotice = '' ? "\n" : cb.settings.addNotice + "\n"; var inTotal = tipMode == 1 ? '' : " (in total) "; botNotice = "\n Tip " + cb.settings.loverTip + inTotal + " to become my Lover Of The Day, and make your heart " + graphicBtg + " beat for me. " + addNotice ; if (cb.settings.permanentString) { loverListPopulate(); } informationOwner(); timeBotNotice(); } // // On Enter : // Bot notification to the User // cb.onEnter(function(user) { var usr = user['user']; if (!isOwner(usr)) { var w = isLover(usr) ? "Welcome back my Lover " + graphicLov : botNotice ; cb.sendNotice(w, usr ,'',messColor, 'bolder'); } }); /* // TEST TEST TEST function onTest() { var usr = 'theo' var newTip = 10; onTip (usr, newTip); display(); var usr = 'jeanne' var newTip = 20; onTip (usr, newTip); display(); var usr = 'leon' var newTip = 33; onTip (usr, newTip); display(); var usr = 'jeanne' var newTip = 20; onTip (usr, newTip); display(); } function display() { cb.sendNotice(tipperNb); for (var i=0; i<tipperNb; i++) { cb.sendNotice(i + " " + tipperList[i][0] + " " + tipperList[i][1] ); } } function onTip(usr, newTip) { actionIndic = 0; var valueTip = (tipMode == 2 ? manageTipperList(usr, newTip) : newTip); if (!isLover(usr) && valueTip >= cb.settings.loverTip) { actionIndic += 1; makeLover(usr); cb.sendNotice(graphicThk + "Thank you so much " + usr + ". Your heart now beats for me" + graphicShy ,'','', messColor ,'bolder'); } } */ // END TEST // // On Tip : In MULTI mode, creation/update of the list of Tippers. // // If the Tipper is not a Lover yet, and the Tip matches // (depending on the Tip mode), make the tipper a lover, // notify it and inhib the next Bot notice. // cb.onTip(function (tip) { var usr = tip['from_user']; var newTip = parseInt(tip['amount']); actionIndic = 0; var valueTip = (tipMode == 2 ? manageTipperList(usr, newTip) : newTip); if (!isLover(usr) && valueTip >= cb.settings.loverTip) { actionIndic += 1; makeLover(usr); cb.sendNotice(graphicThk + "Thank you so much " + usr + ". Your heart now beats for me" + graphicShy ,'','', messColor ,'bolder'); } }); // // On Message : Add the appropriated graphic to user message. // cb.onMessage(function (msg) { var usr = msg['user']; actionIndic = 0; if (msg['m']=='') {return msg;} // Compatibility other Bots if (isOwner(usr)) { var graphic = graphicOwner; } else if (isLover(usr)) { var graphic = graphicLov; } else { var graphic =graphicStt; } msg['m'] = graphic + msg['m']; return msg; }); // // loverListPopulate : Initialize loverList with Permanent Lovers // Avoid the Owner and Multi-entering // function loverListPopulate() { var permArray = cb.settings.permanentString.toLowerCase().split((" ")); if (cbjs.arrayContains (permArray, cb.room_slug) ) { permArray = cbjs.arrayRemove (permArray , cb.room_slug); permOwner = 1; } for (var i = 0 ; i < permArray.length ; i++) { var perm = permArray[i].replace(/ /g, ""); if (perm && !isLover(perm)) { makePermanent(perm) ; } } } // // manageTipperList : Update 'usr' in the Tipper list if it exists, else creates it. // Return the sum tipped by usr. // function manageTipperList(usr, newTip) { for (var i=0 ; i<tipperNb; i++) { if (tipperList[i][0]==usr) { var sum = parseInt(tipperList[i][1]) + newTip ; tipperList[i][1] = sum ; return (sum) ; } } tipperList[tipperNb] = new Array ; tipperList[tipperNb][0] = usr; tipperList[tipperNb][1] = newTip; tipperNb+=1; return(newTip); } // Functions : // // isOwner : User is the broadcaster ? // makeLover : Add the user to the list of Lovers // isLover : User is in the list of Lovers ? // makePermanent : Add the user to the list of Lovers as Permanent // Information Owner // function isOwner(username) { return (username == cb.room_slug); } function makeLover(username) { loverList[loverNb] = new Array; loverList[loverNb][0] = username; loverList[loverNb][1] = 0 ; loverNb+=1; } function isLover(username) { for (var i = 0; i < loverNb; i++) { if (loverList[i][0] == username) { return (1); } } return(0); } function makePermanent(username) { makeLover(username); loverList[permNb][1] = 1; permNb+=1; } // // informationOwner : welcome and information to the Broadcaster // function informationOwner () { // Notice : Remind Tip amount and Mode : var m = tipMode == 1 ? ": one SINGLE Tip. " : "MULTI : all Tips count. "; sendTitle( "Hi " + cb.room_slug + graphicBtg + ", Lover Of The Day is running : "); sendNote("- Lover TIP : " + cb.settings.loverTip ); sendNote("- Mode " + m ); // List of Permanent Lovers : if (permNb == 0) { sendNote (" - No Permanent Lover" ); } else { sendTitle(" - Permanent Lovers : ") ; for (var p=0 ; p < permNb ; p++) { sendNote(p+1 + " : " +loverList[p][0] ) ; } } // Is the Owner is the Permanent List : if (permOwner) { sendNote ( "(You entered yourself in the list of Permanent Lovers. Rather choose your Heart graphic when lauching the Bot... )") ; } // NEW : choice of Owner Heart : sendTitle( "NEW : Did you see you can now choose a Heart Graphic in your own message ? Choices are : "); sendNote( "1 : Two lovely pink hearts : " + graphicAlt ); sendNote( "2 : A little pink jumping heart : " + graphicJpg ); sendNote( "3 : The Lover beating heart : " + graphicBtg ); sendNote( "" ); // Final Thanks : sendTitle("Thanks for using Lover Of The Day. Be loved" + graphicBtg) ; } // // sendTitle & sendNote : display functions. // function sendTitle(title) { var usr = cb.room_slug; var b = '' ; var c = '#000000' ; var f = 'bolder' ; cb.sendNotice( title , usr ,b,c, f); } function sendNote(note) { var usr = cb.room_slug; var b = '' ; var c = '#DC5500' ; var f = 'normal' ; cb.sendNotice( note , usr ,b,c, f); } // // BotNotice : Send Bot Notices at he interval defined by the owner. // Stops if no action in the room (no message, no Tip) // function timeBotNotice() { if (actionIndic < 1) { cb.sendNotice(botNotice,'','', messColor ,'bolder'); actionIndic += 1 ; } cb.setTimeout(timeBotNotice, cb.settings.noticeTime * 60000) ; } // // Init // init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.