Bots Home
|
Create an App
dolly-bot
Author:
mscoot69
Description
Source Code
Launch Bot
Current Users
Created by:
Mscoot69
/* Dolly-Bot: Developed by Mscoot69. ( /09/2016 ) Made for Dolores Madness. This bot features two other existing bots Rotating Notifier Version: 1.1 (03/07/2015) Tip Menu Plus Version: 1.0.4 (09/08/2016) Both from Badbadbubba. (Badbadbubba time format mm/dd/yyyy) They are slightly modified, the bot also features some small miscellaneous features to fit Dolores Madness needs. */ //####################################################################################################################### // CB Settings inputs cb.settings_choices = [ {name: 'rotatingnotifier_enable', required: false,type: 'choice', choice1: 'Options below', defaultValue: 'Options below', label: "|| ================== Rotating Notifier ===================:"}, {name: 'msgonentry', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Display Message 1 privately on entry - set to no for busy rooms"}, {name:'msg1', type:'str', required: false, label:'Message 1',}, {name:'msg2', type:'str', required: false, label:'Message 2',}, {name:'msg3', type:'str', required: false, label:'Message 3',}, {name:'msg4', type:'str', required: false, label:'Message 4',}, {name:'msg5', type:'str', required: false, label:'Message 5',}, {name:'msg6', type:'str', required: false, label:'Message 6',}, {name:'msg7', type:'str', required: false, label:'Message 7',}, {name:'msg8', type:'str', required: false, label:'Message 8',}, {name:'msg9', type:'str', required: false, label:'Message 9',}, {name:'msg10', type:'str', required: false, label:'Message 10',}, {name:'rotatingNotifier_msgcolor', type:'str', label:'Notice color (default color : #d0a9f5)', defaultValue: '#d0a9f5'}, {name: 'rotatingNotifier_chat_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 2, label: 'Delay in minutes between notices being displayed (minimum 1)'}, {name: 'tipmenu_enable', required: false, type: 'choice', choice1: 'Enable', choice2: 'Disable', defaultValue: 'Enable', label: "|| ====================== Tip Menu ======================"}, {name: 'sepchar', type: 'choice', choice1: 'Vertical Bar', choice2: 'Hearts', choice3:'Glitter',choice4:'Flowers',choice5:'Bow',choice6:'Hearts2',choice7:'Smiley',choice8:'Text Heart', choice9:'Text Diamond', choice10:'Text Star', defaultValue: 'Vertical Bar', label: "Separator character"}, {name:'item1', type:'str', required: false, label:'Item 1 (eg: 10--flash tits)',}, {name:'item2', type:'str', required: false, label:'Item 2',}, {name:'item3', type:'str', required: false, label:'Item 3',}, {name:'item4', type:'str', required: false, label:'Item 4',}, {name:'item5', type:'str', required: false, label:'Item 5',}, {name:'item6', type:'str', required: false, label:'Item 6',}, {name:'item7', type:'str', required: false, label:'Item 7',}, {name:'item8', type:'str', required: false, label:'Item 8',}, {name:'item9', type:'str', required: false, label:'Item 9',}, {name:'item10', type:'str', required: false, label:'Item 10',}, {name:'tipMenu_noticecolor', type:'str', label:'Notice color (default color : #d0a9f5)', defaultValue: '#d0a9f5'}, {name: 'tipMenu_chat_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 1, label: 'Delay in minutes between notice being displayed (minimum 1)'}, ]; //####################################################################################################################### // Class Utility ( with miscelaneos stuff) var utility = { superUser : "mscoot69", milis : { oneSec : 1000, oneMinute : 60 * ( 1000 ), oneHour : 60 * ( 60 * 1000 ), }, isValidColor : function ( str ) { if ( str != undefined ) { str = str.toUpperCase(); return str.match(/^#[A-Z0-9]{6}$/i) !== null; } else return false; }, }; //####################################################################################################################### // Cass Caller ( is used to invoke function of one object inside it self witout messing with the key word "this" ) var caller = { rotatingNotifier : { chatAd : function () { rotatingNotifier.chatAd(); }, }, tipMenu : { chatAd : function () { tipMenu.chatAd(); }, startDelayed : function () { tipMenu.startDelayed(); }, }, }; //####################################################################################################################### // Class Dolly ( main class ) var dollyBot = { init : function () { tipMenu.start(); rotatingNotifier.start(); cb.setTimeout( function () { cb.sendNotice(':tinyflower2 Dolly-Bot has started :tinyflower2', '', '', '#d0a9f5', 'bold'); } , ( 2 * utility.milis.oneSec + 500) ); /* times ( seconds ) 1 - tip menu error messages 2 - rotating notifier disabled warning 2.1 - tip menu disabled warning 2.5 - dolly-bot startup message 5 - tip menu starts notifying 10 - rotating notifier stars notifying */ } }; //####################################################################################################################### // Class TipMenu var tipMenu = { enable : false, msg: 'Tip Menu: ', MAXITEMS : 10, tipmenuprice : [], tipmenuitem : [], separators : [ {label:'Hearts',shortcut:':heart2'}, {label:'Glitter',shortcut:':pixelglitter'}, {label:'Flowers',shortcut:':tinyflower2'}, {label:'Bow',shortcut:':bluebow'}, {label:'Hearts2',shortcut:':pixelheart'}, {label:'Smiley',shortcut:':smile'}, {label:'Text Heart',shortcut: '\u2665' }, // ♥ {label:'Text Diamond',shortcut: '\u2666' }, // ♦ {label:'Text Star',shortcut: '\u2605' }, // ★ ], forecolor : '#d0a9f5', start : function () { var active = cb.settings['tipmenu_enable'] == 'Enable'; if (! active ) { this.enable = false; return; } cb.setTimeout( function () { caller.tipMenu.startDelayed(); } , utility.milis.oneSec ) ; // to display well the error messages of the tip menu items }, startDelayed : function () { var j = 0; var separator_char = "| "; this.enable = true; for (i = 0; i <= this.separators.length - 1; i++) { if (cb.settings['sepchar'] == this.separators[i].label) { separator_char = this.separators[i].shortcut + ' '; } } for (i = 1; i <= this.MAXITEMS; i++) { var tmp; tmp=cb.settings['item' + i]; if (tmp) { var arr= tmp.split('--'); var amt=parseInt(arr[0]); //cb.log(arr.length); if (arr[1] == undefined) { cb.sendNotice('ERROR : Item ' + i + ' - You need two dashes to separate the tip amount and menu item..', cb.room_slug,'','#ff0000','bold'); } else if( isNaN( amt ) ) { cb.sendNotice('ERROR : Item ' + i + ' - The tip amount is not a number.', cb.room_slug,'','#ff0000','bold'); } else if( arr[1] == '' ) { cb.sendNotice('ERROR : Item ' + i + ' - You need to set a prize.', cb.room_slug,'','#ff0000','bold'); } else if( amt <= 0 ) { cb.sendNotice('ERROR : Item ' + i + ' - The tip amount has to be greater than 0.', cb.room_slug,'','#ff0000','bold'); } else //if (amt > 0 && arr[1] != '' ) { this.tipmenuprice[i]=amt; this.tipmenuitem[i]=arr[1]; // cb.log(tipMenu.tipmenuprice[i]); // cb.log( tipMenu.tipmenuitem[i] + '\n'); if ( j >= 1 ) { this.msg += separator_char; } this.msg += arr[1] + '(' + amt + ') '; j++; } } } // Check color var color = cb.settings['tipMenu_noticecolor']; if ( utility.isValidColor( color ) ) this.forecolor = color; if ( j == 0 ) this.disable(); else cb.setTimeout(caller.tipMenu.chatAd, ( 5 * utility.milis.oneSec )); //cb.log("tm " + this.enable); }, chatAd : function() { cb.sendNotice(this.msg, '', '', this.forecolor, 'bold'); cb.setTimeout(caller.tipMenu.chatAd, ( cb.settings['tipMenu_chat_ad'] * utility.milis.oneMinute ) ); /* 10000*/ }, onTip : function ( tip ) { if ( ! this.enable ) return; tip_amt = parseInt(tip['amount']); for (var i = 1; i <= this.MAXITEMS; i++) { if (tip_amt == this.tipmenuprice[i]) { cb.sendNotice(tip['from_user'] + ' tipped for ' + this.tipmenuitem[i], '', '', this.forecolor, 'bold'); } } }, disable : function () { this.enable = false; // Tip Menu var aux = ''; if ( ! tipMenu.enable && cb.settings['tipmenu_enable'] == 'Enable' ) aux = 'Tip Menu is not activated probably due to unfilled fields.'; if ( cb.settings['tipmenu_enable'] == 'Disable' ) aux = 'Tip Menu was disabled by you.'; if ( aux != '' ) cb.setTimeout( function () { cb.sendNotice(tipmenuStr, cb.room_slug , '', '#000080', 'bold'); } , ( utility.milis.oneSec + 100 )); } }; //####################################################################################################################### // Class RotatingNotifier var rotatingNotifier = { enable : false, x : 0, MAXITEMS : 10, forecolor : '#d0a9f5', start : function () { var v = true; this.enable = true; for ( var i = 0; i < this.MAXITEMS; i++ ) { if ( cb.settings['msg' + (this.x + 1)] == 0 ) { v = false; break; } } // Checking color var color = cb.settings['rotatingNotifier_msgcolor']; if ( utility.isValidColor( color ) ) this.forecolor = color; if ( ! v ) this.disable(); else cb.setTimeout(caller.rotatingNotifier.chatAd, ( 10 * utility.milis.oneSec )); //cb.log("rn " + this.enable); }, chatAd : function () { var msg = ''; while (cb.settings['msg' + (this.x + 1)] == 0){ //skip empty messages this.x++; this.x %= this.MAXITEMS; } msg = cb.settings['msg' + (this.x + 1)]; this.x++; this.x %= this.MAXITEMS; cb.sendNotice(msg, '', '', this.forecolor, 'bold'); cb.setTimeout(caller.rotatingNotifier.chatAd, ( cb.settings['rotatingNotifier_chat_ad'] * utility.milis.oneMinute )); /* 5000 */ }, onEntry : function ( user ) { if ( this.enable && cb.settings['msgonentry'] == 'yes' && cb.settings['msg1'] ) { cb.sendNotice('Welcome ' + user['user'] + ' !\n' + cb.settings['msg1'], user['user'], '', this.forecolor, 'bold'); } }, disable : function () { this.enable = false; // Rotating Notifier if ( ! rotatingNotifier.enable ) cb.setTimeout( function () { cb.sendNotice('Rotating Notifier is not activated probably due to unfilled/incorrect fields.', cb.room_slug, '', '#000080', 'bold'); } , ( 2 * utility.milis.oneSec )); } }; //####################################################################################################################### // Class mod var mod = { silencedList : [], mostrar : true, sil : function( str, user ) { var v = true; for( var i = 0; i < this.silencedList.length; i++ ) // verifica se o utilizador ja foi introduzido { if ( this.silencedList[i] == str ) { v = false; cb.setTimeout(function () {cb.sendNotice("Utilizador ja existente", user, '', '#ff0000');} , utility.milis.oneSec); break; } } if ( v ) { this.silencedList.push( str ); cb.setTimeout(function () {cb.sendNotice("User " + str + " was silenced.", '', '', '#494949');} , utility.milis.oneSec); } /* for( var i = 0; i < this.silencedList.length; i++ ) { cb.log( i + " : " + this.silencedList[i] ); } */ }, unsil : function( str, user ) { for( var i = 0; i < this.silencedList.length; i++ ) { if ( this.silencedList[i] == str ) { this.silencedList.splice(i, 1); cb.setTimeout(function () {cb.sendNotice("User " + str + " was unsilenced.", '', '', '#494949');} , utility.milis.oneSec); break; } } /* for( var i = 0; i < this.silencedList.length; i++ ) { cb.log( i + " : " + this.silencedList[i] ); } */ }, check : function( msg ) { for( var i = 0; i < this.silencedList.length; i++ ) { if ( this.silencedList[i] == msg['user'] ) { msg['X-Spam'] = true; break; } } return msg; }, pm : function( str, user ) { cb.setTimeout(function () {cb.sendNotice(user + ": " + str, cb.room_slug, '#D4DDED', '#000080', 'bolder');} , utility.milis.oneSec); cb.setTimeout(function () {cb.sendNotice(user + ": " + str, user, '#D4DDED', '#000080', 'bolder');} , utility.milis.oneSec); // backgrond :# AEEEEE }, showMoves : function(user , move) { if ( this.mostrar ) { if ( user['user'] == cb.room_slug || user['user'] == utility.superUser || user['in_fanclub'] || user['is_mod'] || ! user['has_tokens']) return; if (move == "entrada") cb.sendNotice(user['user'] + " has joined the room.", utility.superUser, '', '#03b913', 'bolder'); else if (move == "saida") cb.sendNotice(user['user'] + " has left the room.", utility.superUser, '', '#ca0202', 'bolder'); } /* mscoot692 has joined the room. mscoot692 has left the room. */ }, changeShowMoves : function(user) { if ( this.mostrar ) { cb.setTimeout(function () { cb.sendNotice("Mostrar movimentos : Desligado!", user, '', '#000080', 'bolder'); }, utility.milis.oneSec); this.mostrar = false; } else { cb.setTimeout(function () { cb.sendNotice("Mostrar movimentos : Ligado!", user, '', '#000080', 'bolder'); }, utility.milis.oneSec); this.mostrar = true; } //cb.log(this.mostrar); }, }; //####################################################################################################################### // Class Cmd var cmd = { checkCmd : function ( msg ) { var extra = msg['user'] == utility.superUser; if( msg['m'].startsWith("/lovers") ) // Command /lovers { msg['X-Spam'] = true; if (msg['user'] == cb.room_slug || extra) // || msg['is_mod'] { if (msg['m'].length == 7) this.lovers( msg['user'] ); else { cb.setTimeout(function () { cb.sendNotice("Sintaxe error.\nSintaxe exemple : /lovers", msg['user'], '', '#ff0000'); } , utility.milis.oneSec); } } else { cb.setTimeout(function () { cb.sendNotice("ERROR : You don't have premission to execute this comand !", msg['user'], '', '#ff0000', 'bolder'); } , utility.milis.oneSec); } } else if ( msg['m'].startsWith("/sil ") ) // Command /sil { msg['X-Spam'] = true; if ( msg['user'] == cb.room_slug || extra ) { if ( msg['m'].length >= 6 ) // check if the cmd is correct { this.sil( msg['m'].substring(5).replace(/ /g,'') , msg['user']); } } } else if ( msg['m'].startsWith("/unsil ") ) // Command /unsil { msg['X-Spam'] = true; if ( msg['user'] == cb.room_slug || extra ) { if ( msg['m'].length >= 8 ) { this.unsil( msg['m'].substring(7).replace(/ /g,'') , msg['user'] ); } } } else if ( msg['m'].startsWith("/pm ") ) // Command /pm { msg['X-Spam'] = true; if ( extra ) { if ( msg['m'].length >= 5 ) { this.pm( msg['m'].substring(4), msg['user'] ); } } } else if ( msg['m'].startsWith("/mostrar") ) // Command /pm { msg['X-Spam'] = true; if ( extra ) { if ( msg['m'].length == 8 ) { this.mostrar( msg['user'] ); } } } return msg; }, lovers : function( user ) { cb.setTimeout(function () { loverBot.showAllLovers( user ); } , utility.milis.oneSec); }, sil : function( str, user ) { mod.sil( str, user ); }, unsil : function( str, user ) { mod.unsil( str, user ); }, pm : function( str , user) { mod.pm( str, user ); }, mostrar : function( user ) { mod.changeShowMoves( user ); }, }; //####################################################################################################################### // CB functions cb.onEnter(function(user) { rotatingNotifier.onEntry( user ); mod.showMoves( user, 'entrada' ); }); cb.onLeave(function(user) { mod.showMoves( user, 'saida' ); }); cb.onTip(function (tip) { tipMenu.onTip( tip ); }); cb.onMessage(function (msg) { msg = cmd.checkCmd(msg); msg = mod.check( msg ); return msg; }); // Initial function dollyBot.init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.