Bots Home
|
Create an App
rr
Author:
roger344
Description
Source Code
Launch Bot
Current Users
Created by:
Roger344
/*********************************************************************** Title: RUB - Roger's Ultra Bot Author: roger344 Version: 1.0 (2017-01-10) This bot implements many functions: * Custom Welcome Message * Convert all caps messages * User Tip Total - displays total tip before user's message like "[25] Show boobs! " * Auto Tip Thank You - display automatic custom message when a user tip * King Tipper - display small crown before king user's message; displays notice to inform what amount to tip to become the new king * Identify User Gender - add gender icon before user's message in chat * Room rules - displays multilines room rules to every new entering user * Notice list - displays multilines notices list * Tip Menu - displays vertical or horizontal tip menu Based on : # Auto Tip Thank You 1.0 - Kmoore # Ultra Bot 1.06 - britney_and_justin # Room Rules 1.12.1 - Zingknaat # Cleopatra Harem 1.0 - Osumba # Tip Menu Single Notice 1.0.0b - badbadbubba /*********************************************************************** Global Variables ***********************************************************************/ cb.settings_choices = [ // Custom Welcome Message { name: 'welcome_msg', type: 'str', minLength: 8, maxLength: 255, label: '***** WELCOME MESSAGE ***** Welcome message, [user] = user\'s name', defaultValue: 'Welcome to my room [user].' }, { name: 'welcome_bg_color', label: 'Welcome message Background highlight (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: 'FFFFFF'}, { name: 'welcome_text_color', label: 'Welcome message text color (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: 'd35400'}, // Convert All Caps Messages { name: 'convert_all_caps_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: '***** CONVERT UPPERCASE ***** Convert all uppercase message to lowercase message ?' }, // User Tip Total { name: 'user_tip_total_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: '***** USER TOTAL TIP ***** Show users\' tip total in chat ?' }, { name: 'user_tip_total_bracket', type: 'choice', choice1: '|25|',choice2: '[25]', choice3: '(25)', choice4: '{25}', defaultValue: '[25]', label: 'Select which tip total bracket to use ?' }, // Auto Tip Thank You { name: 'auto_tip_thank_you_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: '***** AUTO TIP THANK YOU MESSAGE ***** Show auto tip thank you ?' }, { name: 'tip_min', type: 'int', minValue: 1, defaultValue: 10, label: 'Minimum tokens required for a thank you message' }, { name: 'tip_msg', type: 'str', minLength: 8, maxLength: 128, defaultValue: 'Thank you [tipper] for your tip!', label: 'Tip thank you message, [tipper] = tipper\'s name' }, { name: 'auto_ty_bg_color', label: 'Thank you notice Background highlight (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: 'FFFFFF'}, { name: 'auto_ty_text_color', label: 'Thank you notice text color (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: 'd35400'}, //King tipper { name: 'king_tipper', label: '***** KING TIPPER ***** Do you want to use the "King Tipper" feature?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, { name: 'king_icon', label: 'Choose king icon', type: 'choice', choice1: ':rogerscrown', choice2: ':rogerscrown1', choice3: ':rogerscrown2', choice4: ':rogerscrown3', defaultValue: ':rogerscrown'}, { name: 'kingTipperSpam', label: 'Display notice to announce how many token required to become the king?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, { name: 'kingSpam_timer', type:'int', minValue: 1, maxValue: 999, defaultValue: 5, label: 'Delay in minutes between King notice being displayed (minimum 1)' }, { name: 'kingSpam_bg_color', label: 'King notice Background highlight (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: 'ecf0f1'}, { name: 'kingSpam_text_color', label: 'King notice text color (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: '34495e'}, // User Gender { name: 'gender_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: '***** USER GENDER ***** Show users gender in chat ?' }, { name: 'gender_f', type: 'str', minLength: 1, maxLength: 25, label: 'Female Gender Label', defaultValue: ':avatar_gen_female' }, { name: 'gender_m', type: 'str', minLength: 1, maxLength: 25, label: 'Male Gender Label', defaultValue: ':avatar_gen_male' }, { name: 'gender_t', type: 'str', minLength: 1, maxLength: 25, label: 'Transsexual Gender Label', defaultValue: ':avatar_gen_trans' }, { name: 'gender_c', type: 'str', minLength: 1, maxLength: 25, label: 'Couple Gender Label', defaultValue: ':avatar_gen_couple' }, // Room Rules { name: 'room_rules_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: '***** ROOM RULES ***** Show room rules ?' }, { name: 'rules_bg_color', label: 'Room rules background highlight (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: 'ecf0f1'}, { name: 'rules_text_color', label: 'Room rules text color (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: '8e44ad'}, { name: 'rule1', type: 'str', minLength: 6, maxLength: 255, label: 'Rule #1' }, { name: 'rule2', type: 'str', minLength: 6, maxLength: 255, label: 'Rule #2', required: false}, { name: 'rule3', type: 'str', minLength: 6, maxLength: 255, label: 'Rule #3', required: false}, { name: 'rule4', type: 'str', minLength: 6, maxLength: 255, label: 'Rule #4', required: false}, { name: 'rule5', type: 'str', minLength: 6, maxLength: 255, label: 'Rule #5', required: false}, { name: 'rule6', type: 'str', minLength: 6, maxLength: 255, label: 'Rule #6', required: false}, { name: 'rule7', type: 'str', minLength: 6, maxLength: 255, label: 'Rule #7', required: false}, { name: 'rule8', type: 'str', minLength: 6, maxLength: 255, label: 'Rule #8', required: false}, { name: 'rule9', type: 'str', minLength: 6, maxLength: 255, label: 'Rule #9', required: false}, { name: 'rule10', type: 'str', minLength: 6, maxLength: 255, label: 'Rule #10', required: false}, // Notice list { name: 'notice_list_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: '***** NOTICE LIST ***** Show notice list ?' }, { name: 'notice_list_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 10, label: 'Delay in minutes between notice being displayed (minimum 1)' }, { name: 'notice_bg_color', label: 'Notice list background highlight (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: 'ecf0f1'}, { name: 'notice_text_color', label: 'Notice list text color (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: '446CB3'}, { name: 'notice1', type: 'str', minLength: 6, maxLength: 255, label: 'Notice #1' }, { name: 'notice2', type: 'str', minLength: 6, maxLength: 255, label: 'Notice #2', required: false}, { name: 'notice3', type: 'str', minLength: 6, maxLength: 255, label: 'Notice #3', required: false}, { name: 'notice4', type: 'str', minLength: 6, maxLength: 255, label: 'Notice #4', required: false}, { name: 'notice5', type: 'str', minLength: 6, maxLength: 255, label: 'Notice #5', required: false}, { name: 'notice6', type: 'str', minLength: 6, maxLength: 255, label: 'Notice #6', required: false}, { name: 'notice7', type: 'str', minLength: 6, maxLength: 255, label: 'Notice #7', required: false}, { name: 'notice8', type: 'str', minLength: 6, maxLength: 255, label: 'Notice #8', required: false}, { name: 'notice9', type: 'str', minLength: 6, maxLength: 255, label: 'Notice #9', required: false}, { name: 'notice10', type: 'str', minLength: 6, maxLength: 255, label: 'Notice #10', required: false}, // Tip Menu { name: 'tip_menu_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: '***** TIP MENU ***** Show tip menu ?' }, { name: 'tip_menu_design', type: 'choice', choice1: 'Horizontal', choice2: 'Vertical', defaultValue: 'Horizontal', label: 'Type', required: false }, { name: 'tip_menu_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 15, label: 'Delay in minutes between notice being displayed (minimum 1)' }, { name: 'tipmenu_bg_color', label: 'Tip menu background highlight (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: 'FFFFFF'}, { name: 'tipmenu_text_color', label: 'Tip menu text color (6 digits hex color).', type: 'str', minLength: 6, maxLength: 6, defaultValue: 'c0392b'}, { name: 'menuItem1', type: 'str', minLength: 6, maxLength: 60, label: 'Menu Item #1' }, { name: 'menuPrice1', type: 'int', minValue: 1, label: 'Menu Item #1 Price' }, { name: 'menuItem2', type: 'str', minLength: 6, maxLength: 60, label: 'Menu Item #2', required: false }, { name: 'menuPrice2', type: 'int', minValue: 1, label: 'Menu Item #2 Price', required: false }, { name: 'menuItem3', type: 'str', minLength: 6, maxLength: 60, label: 'Menu Item #3', required: false }, { name: 'menuPrice3', type: 'int', minValue: 1, label: 'Menu Item #3 Price', required: false }, { name: 'menuItem4', type: 'str', minLength: 6, maxLength: 60, label: 'Menu Item #4', required: false }, { name: 'menuPrice4', type: 'int', minValue: 1, label: 'Menu Item #4 Price', required: false }, { name: 'menuItem5', type: 'str', minLength: 6, maxLength: 60, label: 'Menu Item #5', required: false }, { name: 'menuPrice5', type: 'int', minValue: 1, label: 'Menu Item #5 Price', required: false }, { name: 'menuItem6', type: 'str', minLength: 6, maxLength: 60, label: 'Menu Item #6', required: false }, { name: 'menuPrice6', type: 'int', minValue: 1, label: 'Menu Item #6 Price', required: false }, { name: 'menuItem7', type: 'str', minLength: 6, maxLength: 60, label: 'Menu Item #7', required: false }, { name: 'menuPrice7', type: 'int', minValue: 1, label: 'Menu Item #7 Price', required: false }, { name: 'menuItem8', type: 'str', minLength: 6, maxLength: 60, label: 'Menu Item #8', required: false }, { name: 'menuPrice8', type: 'int', minValue: 1, label: 'Menu Item #8 Price', required: false }, { name: 'menuItem9', type: 'str', minLength: 6, maxLength: 60, label: 'Menu Item #9', required: false }, { name: 'menuPrice9', type: 'int', minValue: 1, label: 'Menu Item #9 Price', required: false }, { name: 'menuItem10', type: 'str', minLength: 6, maxLength: 60, label: 'Menu Item #10', required: false }, { name: 'menuPrice10', type: 'int', minValue: 1, label: 'Menu Item #10 Price', required: false } ] //Colors var notice_txt_color = '#990099'; var notice_bg_color = '#FFFFFF'; var rules_bg_color = '#' + cb.settings.rules_bg_color; var rules_text_color = '#' + cb.settings.rules_text_color; var notice_list_bg_color = '#' + cb.settings.notice_bg_color; var notice_list_text_color = '#' + cb.settings.notice_text_color; var tipmenu_bg_color = '#' + cb.settings.tipmenu_bg_color; var tipmenu_text_color = '#' + cb.settings.tipmenu_text_color; var kingSpam_bg_color = '#' + cb.settings.kingSpam_bg_color; var kingSpam_text_color = '#' + cb.settings.kingSpam_text_color; var auto_ty_bg_color = '#' + cb.settings.auto_ty_bg_color; var auto_ty_text_color = '#' + cb.settings.auto_ty_text_color; var welcome_bg_color = '#' + cb.settings.welcome_bg_color; var welcome_text_color = '#' + cb.settings.welcome_text_color; var cmds_bg_color = '#FFFFFF'; var cmds_text_color = '#8bb3da'; /** * tipperArray => table containing all tippers. Each element of this table contains 2 elements : [0] is the tipper's name; [1] is the tipper's total tip * listTippers => table with sorted tippers * num_of_tippers => will contains the total number of tippers * kingTip => contains the amount of tip of the King * currentKing => contains the king user's name * kingTipper => contains 'Yes' or 'No' to enable or disable king tipper option * kingTimer => contains the duration (in minutes) chose by the broadcaster while setting the bot, between two king notice. * kingIcon = > contains 'Yes' or 'No' to enable or disable king icon option * autothank => contains 'Yes' or 'No' to enable or disable auto thank you message option * notices_list => contains 'Yes' or 'No' to enable or disable notices list option * tip_menu => contains 'Yes' or 'No' to enable or disable tip menu feature * timerNotices => contains the duration of appearance of notices list * timerTipMenu => contains the duration of appearance of tip menu */ var tipperArray = new Array; var listTippers = new Array; var num_of_tippers = 0; var kingTip = 0; var currentKing = ''; var kingTipper = cb.settings.king_tipper; var kingTimer = cb.settings.kingSpam_timer; var kingIcon = cb.settings.king_icon; var autothank = cb.settings.auto_tip_thank_you_allowed; var notices_list = cb.settings.notice_list_allowed; var tip_menu = cb.settings.tip_menu_allowed; var timerNotices = cb.settings.notice_list_ad; var timerTipMenu = cb.settings.tip_menu_ad /*********************************************************************** Functions ***********************************************************************/ function tipperArrayPopulate(user) { // adds tipper to the tipperArray tipperArray[num_of_tippers] = new Array(); tipperArray[num_of_tippers][0] = user; tipperArray[num_of_tippers][1] = 0; num_of_tippers++; } function findTipper(user) { // find the index of the tipper for (var i = 0; i < tipperArray.length; i++) { if (tipperArray[i][0] == user) { break; } } // the tipper is not in the array. add him and call findTipper if (i == tipperArray.length) { tipperArrayPopulate(user); findTipper(user); } return i; } function sortTippers(){ listTippers = tipperArray; for(var i = 0; i < tipperArray.length; i++){ for(var j = 0; j < tipperArray.length; j++){ if(listTippers[j][1] < listTippers[i][1]){ var temp_tip,temp_name; temp_name = listTippers[i][0]; temp_tip = listTippers[i][1]; listTippers[i][0] = listTippers[j][0]; listTippers[i][1] = listTippers[j][1]; listTippers[j][0] = temp_name; listTippers[j][1] = temp_tip; } } } } function setTipTitles(user, message) { var bracket_open = ''; var bracket_close = ''; switch (cb.settings.user_tip_total_bracket) { case '|25|': bracket_open = '|'; bracket_close = '|'; break; case '[25]': bracket_open = '['; bracket_close = ']'; break; case '(25)': bracket_open = '('; bracket_close = ')'; break; case '{25}': bracket_open = '{'; bracket_close = '}'; break; default: bracket_open = ''; bracket_close = ''; break; } var m = bracket_open + tipperArray[findTipper(user)][1] + bracket_close + ' ' + message; return m; } function setKingTitle(message){ message = kingIcon + ' ' + message; return message; } // Rules function displayRules(user) { var username = ''; if (user) username = user['user']; var notices = '###### ROOM RULES ######'; for (var i = 1; i <= 10; i++) { if (cb.settings['rule' + i]) notices += '\nRule #'+ i +': ' + cb.settings['rule'+i]; } notices += '\n######################'; cb.sendNotice(notices, username, rules_bg_color, rules_text_color, 'bold'); } function displayNotices() { if(notices_list == 'Yes'){ var notices = '---- ROOM INFOS ----'; for (var i = 1; i <= 10; i++) { if (cb.settings['notice' + i]) notices += '\n' + cb.settings['notice'+i]; } notices += '\n--------------------------' cb.sendNotice(notices, null, notice_list_bg_color, notice_list_text_color, 'bold'); cb.setTimeout(displayNotices, (timerNotices * 60000)); } } // Tip Menu function showTipMenu() { if(tip_menu == 'Yes'){ if(cb.settings.tip_menu_design == 'Horizontal'){ var msg = 'TIP MENU : '; for (i = 1; i <= 10; i++) { if (parseInt(cb.settings['menuPrice' + i]) > 0) { if(i == 1){ msg += cb.settings['menuItem' + i] + ' (' + parseInt(cb.settings['menuPrice' + i]) + ' tokens)'; }else{ msg += ' | ' + cb.settings['menuItem' + i] + ' (' + parseInt(cb.settings['menuPrice' + i]) + ' tokens)'; } } } }else if(cb.settings.tip_menu_design == 'Vertical'){ var msg = '---- Tip Menu ----\n'; for (i = 1; i <= 10; i++) { if (parseInt(cb.settings['menuPrice' + i]) > 0) { msg += cb.settings['menuItem' + i] + ' (' + parseInt(cb.settings['menuPrice' + i]) + ' tokens)\n'; } } msg += '-------------------'; } cb.sendNotice(msg, null, tipmenu_bg_color, tipmenu_text_color, 'bold'); cb.setTimeout(showTipMenu, (timerTipMenu * 60000)); } } function kingSpamTimer() { if(kingTipper == 'Yes' && cb.settings.kingTipperSpam == 'Yes'){ var supplant = kingTip + 1; cb.sendNotice(kingIcon + ' Tip ' + supplant + ' to become the new King ' + kingIcon, null,kingSpam_bg_color,kingSpam_text_color,'bold'); cb.setTimeout(kingSpamTimer, kingTimer * 60000); } } //Display all available commands function displayCmds(user){ var message = '' + '------ KING TIPPER ------\n' + ' /startking : enable king tipper feature\n' + ' /stopking : desable king tipper feature\n' + ' /timerking : set king notice spam timer (in minutes) - example : /timerking 3 (for spamming every 3 minutes)\n' + '------ AUTO THANK YOU ------\n' + ' /startthank : enable auto thank you message\n' + ' /stopthank : disable auto thank you message\n' + '------ NOTICES LIST ------\n' + ' /startnotices : enable notices list feature\n' + ' /stopnotices : disable notices list feature\n' + ' /timernotices : set notices list spam timer (in minutes) - example : /timernotices 3 (for spamming every 3 minutes)\n' + '------ TIP MENU ------\n' + ' /starttipmenu : enable tip menu feature\n' + ' /stoptipmenu : disable tip menu feature\n' + ' /timertipmenu : set tip menu spam timer (in minutes) - example : /timertipmenu 3 (for spamming every 3 minutes)\n' + '------ MISCELLANEOUS ------\n' + ' /state : display the state of each controlled feature\n' + ' /tippers : display all tippers, ordered by the highest first'; cb.sendNotice(message,user,cmds_bg_color,cmds_text_color,'bold'); } /*********************************************************************** Event Handling ***********************************************************************/ cb.onMessage(function(msg) { var message = msg['m'].split(' '); //invalid command = 0; valid command = 1 var cmd = 0; //check if the message is a command line if(message[0].charAt(0) == '/'){ //don't print this message to chat msg['X-Spam'] = true; switch(message[0]){ case '/rogercmds':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { displayCmds(msg['user']); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/startking':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { kingTipper = 'Yes'; cb.sendNotice('King tipper feature is now enabled',msg['user'],'#FFFFFF','#000000'); cb.setTimeout(kingSpamTimer, kingTimer * 60000); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/stopking':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { kingTipper = 'No'; cb.sendNotice('King tipper feature is now disabled',msg['user'],'#FFFFFF','#000000'); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/timerking':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { var time = parseInt(message[1]); if(time >= 1 && time <= 999){ kingTimer = message[1]; cb.sendNotice('King reminder will be spammed every ' + time + ' minute',msg['user'],'#FFFFFF','#000000'); }else{ cb.sendNotice('Incorrect value, you have to specify a value between 1 and 999',msg['user'],'#FFFFFF','#000000'); } } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/startthank':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { autothank = 'Yes'; cb.sendNotice('Auto Thank you feature is now enabled',msg['user'],'#FFFFFF','#000000'); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/stopthank':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { autothank = 'No'; cb.sendNotice('Auto Thank you feature is now disabled',msg['user'],'#FFFFFF','#000000'); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/startnotices':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { notices_list = 'Yes'; cb.sendNotice('Notices list feature is now enabled',msg['user'],'#FFFFFF','#000000'); cb.setTimeout(displayNotices, (timerNotices * 60000)); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/stopnotices':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { notices_list = 'No'; cb.sendNotice('Notices list feature is now disabled',msg['user'],'#FFFFFF','#000000'); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/timernotices':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { var time = parseInt(message[1]); if(time >= 1 && time <= 999){ timerNotices = message[1]; cb.sendNotice('Notices list will be spammed every ' + time + ' minute',msg['user'],'#FFFFFF','#000000'); }else{ cb.sendNotice('Incorrect value, you have to specify a value between 1 and 999',msg['user'],'#FFFFFF','#000000'); } } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/starttipmenu':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { tip_menu = 'Yes'; cb.sendNotice('Tip Menu feature is now enabled',msg['user'],'#FFFFFF','#000000'); cb.setTimeout(showTipMenu, (timerTipMenu * 60000)); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/stoptipmenu':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { tip_menu = 'No'; cb.sendNotice('Tip Menu feature is now disabled',msg['user'],'#FFFFFF','#000000'); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/timertipmenu':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { var time = parseInt(message[1]); if(time >= 1 && time <= 999){ timerTipMenu = message[1]; cb.sendNotice('Tip Menu will be spammed every ' + time + ' minute',msg['user'],'#FFFFFF','#000000'); }else{ cb.sendNotice('Incorrect value, you have to specify a value between 1 and 999',msg['user'],'#FFFFFF','#000000'); } } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/state':{ cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { var state = '' + ' - King tipper is ' + ((kingTipper == 'Yes') ? 'ON' : 'OFF') + ' and the timer is set at ' + kingTimer + ' minutes.\n' + ' - Auto thank you is ' + ((autothank == 'Yes') ? 'ON' : 'OFF') + '.\n' + ' - Notices list is ' + ((notices_list == 'Yes') ? 'ON' : 'OFF') + ' and the timer is set at ' + timerNotices + ' minutes.\n' + ' - Tip menu is ' + ((tip_menu == 'Yes') ? 'ON' : 'OFF') + ' and the timer is set at ' + timerTipMenu + ' minutes.'; cb.sendNotice(state,msg['user'],cmds_bg_color,cmds_text_color,'bold') } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } case '/tippers':{ cmd = 1; var tip = 0; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug) { sortTippers(); var tipperList = '##### Tippers list #####\n'; for(var i = 0;i < tipperArray.length;i++){ if(listTippers[i][1] != 0){ tip += listTippers[i][1]; tipperList += listTippers[i][0] + ' -> ' + listTippers[i][1] + ' tokens\n'; } }; if(tip == 0){ tipperList += 'Nobody has tipped for now!\n'; } tipperList += '##################'; cb.sendNotice(tipperList,msg['user'],cmds_bg_color,cmds_text_color,'bold'); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.',msg['user'],'#FFFFFF','#000000'); } break; } } //the user entered an invalid command if(cmd == 0) { cb.sendNotice(message[0] + ' is not a command.\nType /rogercmds to see a full list of the available commands.',msg['user'],'#FFFFFF','#000000'); } } // Convert all caps message if (cb.settings.convert_all_caps_allowed == 'Yes') { if (msg['m'] == msg['m'].toUpperCase() && !msg['is_mod'] && msg['user'] != cb.room_slug ) { // Convert to lower case msg['m'] = msg['m'].toLowerCase(); // Send notice to user cb.sendNotice('Uppercase messages are not allowed by the broadcaster. Your message has been converted to lowercase.', msg['user'], notice_bg_color, notice_txt_color, 'bold'); } } //Display total tip next to the user's name if (cb.settings.user_tip_total_allowed == 'Yes' && parseInt(tipperArray[findTipper(msg['user'])][1]) > 0 && msg['m'].charAt(0) != "/") { msg['m'] = setTipTitles(msg['user'], msg['m']); } //Display king icon if the user is the current king if(kingTipper == 'Yes' && msg['user'] == currentKing && msg['m'].charAt(0) != "/"){ msg['m'] = setKingTitle(msg['m']); } // User Gender if (cb.settings.gender_allowed == 'Yes' && msg['user'] != cb.room_slug && msg['m'].charAt(0)!="/") { var gender = msg['gender']; var genderStr = ""; switch (gender) { case 'm': genderStr = cb.settings.gender_m; break; case 'f': genderStr = cb.settings.gender_f; break; case 's': genderStr = cb.settings.gender_t; break; case 'c': genderStr = cb.settings.gender_c; break; default: genderStr = ''; break; } msg['m'] = genderStr + ' ' + msg['m']; } msg['f'] = 'default'; return msg; }); cb.onTip(function (tip) { //We add a tipper with his amount in a table tipperArray[findTipper(tip['from_user'])][1] += parseInt(tip['amount']); if(kingTipper == 'Yes') { if(tip['from_user'] != currentKing && parseInt(tipperArray[findTipper(tip['from_user'])][1]) > kingTip) { if(currentKing != '') { cb.sendNotice('You have been dethroned by ' + tip['from_user'] + ', but revenge is sweet...', currentKing, '#C287C2'); } cb.sendNotice(tip['from_user'] + ' is our new King!','',kingSpam_bg_color,kingSpam_text_color,'bold'); 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]); } } // Auto Tip Thank You if (autothank == 'Yes') { var tipper = ""; var tip_msg = ""; if (parseInt(tip['amount']) >= cb.settings.tip_min) { tipper = tip['from_user']; tip_msg = cb.settings.tip_msg; tip_msg = tip_msg.replace("[tipper]", tipper); cb.sendNotice(tip_msg, tipper, auto_ty_bg_color, auto_ty_text_color, 'bold'); } } // Tip Menu if (tip_menu == 'Yes') { for (var i = 1; i <= 10; i++) { if (tip['amount'] == parseInt(cb.settings['menuPrice' + i])) { cb.sendNotice(tip['from_user'] + ' tipped for : ' + cb.settings['menuItem' + i], null, '#FFFFFF', tipmenu_text_color, 'bold'); } } } }); cb.onEnter(function(user) { // Custom Welcome Message welcome_user = user['user']; welcome_msg = cb.settings['welcome_msg']; welcome_msg = welcome_msg.replace("[user]", welcome_user); cb.sendNotice(welcome_msg, user['user'], welcome_bg_color, welcome_text_color, 'bold'); // Room Rules if (cb.settings.room_rules_allowed == 'Yes') { cb.sendNotice('Please take a moment to read my room rules before chatting. Thank you!', user['user'], rules_bg_color, rules_text_color, 'bold'); displayRules(user); } }); /*********************************************************************** Initialization ***********************************************************************/ // Tip Menu if (tip_menu == 'Yes') { cb.setTimeout(showTipMenu, (timerTipMenu * 60000)); } //Notice list if (notices_list == 'Yes') { cb.setTimeout(displayNotices, (timerNotices * 60000)); } //king if(kingTipper == 'Yes' && cb.settings.kingTipperSpam == 'Yes'){ cb.setTimeout(kingSpamTimer, kingTimer * 60000); } function init() { } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.