Bots Home
|
Create an App
MegaBot by BeautyanTheDick
Author:
beautyanthedick
Description
Source Code
Launch Bot
Current Users
Created by:
Beautyanthedick
/** * MegaBot by BeautyanTheDick * Version: 1.0 * Author: BeautyanTheDick * Date: 7/17/2019 * Based on work by: Brucebrucebagosh, Osumba, badbadbubba, Zingknaat, britney_and_justin, Kmoore, Mariuz7 */ /*********************************************************************** Global Variables ***********************************************************************/ var notice_txt_color = '#990099'; var notice_bg_color = '#FFCCFF'; var notice_fan_color = '#349900'; var notice_fan_bg_color = '#d8fbc6'; var alert_txt_color = '#B40431'; var alert_bg_color = '#F6CED8'; cb.settings_choices = [ // Custom Welcome Message { name: 'welcome_msg', type: 'str', minLength: 8, maxLength: 255, label: 'Welcome message, [user] = user\'s name', defaultValue: 'Welcome to my room [user].' }, // User Tip Total { name: 'user_tip_total_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: '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 ?' }, // Convert Token { name: 'convert_token_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Show converted tokens in dollars (broadcaster only) ?' }, // Convert All Caps Messages { name: 'convert_all_caps_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Convert all uppercase message to lowercase message ?' }, // Match message color to username colors { name: 'match_color_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Match message color to username color ?' }, // Random message colours { name: 'random_color_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: 'Random message color ?' }, // Fan Club Highlight { name: 'fanclub_highlight', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: 'Highlight Fan Club chat ?' }, // Auto Tip Thank You { name: 'auto_tip_thank_you_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: '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' }, // User Gender { name: 'gender_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: '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' }, { name: 'gender_fan', type: 'str', minLength: 1, maxLength: 25, label: 'Fan Club Label', defaultValue: ':avatar_brookesynnfanpool' }, // Broadcaster Avatar { name: 'broadcaster_avatar', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: 'Give broadcaster an avatar in chat ?' }, { name: 'broadcaster_a', type: 'str', minLength: 1, maxLength: 25, label: 'Broadcaster Avatar', defaultValue: ':avatar_brookepool' }, // Room Rules { name: 'room_rules_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Show room rules ?' }, { 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}, // Tip Menu { name: 'tip_menu_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Show tip menu ?' }, { name: 'tip_menu_horizontal', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: 'Show tip menu horizontally ?' }, { name: 'tip_menu_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 15, label: 'Delay in minutes between notice being displayed (minimum 1)' }, { name: 'fan_tip_menu_icon', type: 'str', minLengthL: 1, maxLength: 25, label: 'Fan Club Tip Menu Icon', defaultValue: ':avatar_brookesynnfanicon' }, { name: 'menuItem1', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #1' }, { name: 'menuPrice1', type: 'int', minValue: 1, label: 'Menu Item #1 Price' }, { name: 'fanMenuPrice1', type: 'int', minValue: 0, label: 'Fan Menu Item #1 Price' }, { name: 'menuItem2', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #2', required: false }, { name: 'menuPrice2', type: 'int', minValue: 1, label: 'Menu Item #2 Price', required: false }, { name: 'fanMenuPrice2', type: 'int', minValue: 0, label: 'Fan Menu Item #2 Price', required: false }, { name: 'menuItem3', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #3', required: false }, { name: 'menuPrice3', type: 'int', minValue: 1, label: 'Menu Item #3 Price', required: false }, { name: 'fanMenuPrice3', type: 'int', minValue: 0, label: 'Fan Menu Item #3 Price', required: false }, { name: 'menuItem4', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #4', required: false }, { name: 'menuPrice4', type: 'int', minValue: 1, label: 'Menu Item #4 Price', required: false }, { name: 'fanMenuPrice4', type: 'int', minValue: 0, label: 'Fan Menu Item #4 Price', required: false }, { name: 'menuItem5', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #5', required: false }, { name: 'menuPrice5', type: 'int', minValue: 1, label: 'Menu Item #5 Price', required: false }, { name: 'fanMenuPrice5', type: 'int', minValue: 0, label: 'Fan Menu Item #5 Price', required: false }, { name: 'menuItem6', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #6', required: false }, { name: 'menuPrice6', type: 'int', minValue: 1, label: 'Menu Item #6 Price', required: false }, { name: 'fanMenuPrice6', type: 'int', minValue: 0, label: 'Fan Menu Item #6 Price', required: false }, { name: 'menuItem7', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #7', required: false }, { name: 'menuPrice7', type: 'int', minValue: 1, label: 'Menu Item #7 Price', required: false }, { name: 'fanMenuPrice7', type: 'int', minValue: 0, label: 'Fan Menu Item #7 Price', required: false }, { name: 'menuItem8', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #8', required: false }, { name: 'menuPrice8', type: 'int', minValue: 1, label: 'Menu Item #8 Price', required: false }, { name: 'fanMenuPrice8', type: 'int', minValue: 0, label: 'Fan Menu Item #8 Price', required: false }, { name: 'menuItem9', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #9', required: false }, { name: 'menuPrice9', type: 'int', minValue: 1, label: 'Menu Item #9 Price', required: false }, { name: 'fanMenuPrice9', type: 'int', minValue: 0, label: 'Fan Menu Item #9 Price', required: false }, { name: 'menuItem10', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #10', required: false }, { name: 'menuPrice10', type: 'int', minValue: 1, label: 'Menu Item #10 Price', required: false }, { name: 'fanMenuPrice10', type: 'int', minValue: 0, label: 'Fan Menu Item #10 Price', required: false }, { name: 'menuItem11', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #11', required: false }, { name: 'menuPrice11', type: 'int', minValue: 1, label: 'Menu Item #11 Price', required: false }, { name: 'fanMenuPrice11', type: 'int', minValue: 0, label: 'Fan Menu Item #11 Price', required: false }, { name: 'menuItem12', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #12', required: false }, { name: 'menuPrice12', type: 'int', minValue: 1, label: 'Menu Item #12 Price', required: false }, { name: 'fanMenuPrice12', type: 'int', minValue: 0, label: 'Fan Menu Item #12 Price', required: false }, { name: 'menuItem13', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #13', required: false }, { name: 'menuPrice13', type: 'int', minValue: 1, label: 'Menu Item #13 Price', required: false }, { name: 'fanMenuPrice13', type: 'int', minValue: 0, label: 'Fan Menu Item #13 Price', required: false }, { name: 'menuItem14', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #14', required: false }, { name: 'menuPrice14', type: 'int', minValue: 1, label: 'Menu Item #14 Price', required: false }, { name: 'fanMenuPrice14', type: 'int', minValue: 0, label: 'Fan Menu Item #14 Price', required: false }, { name: 'menuItem15', type: 'str', minLength: 4, maxLength: 60, label: 'Menu Item #15', required: false }, { name: 'menuPrice15', type: 'int', minValue: 1, label: 'Menu Item #15 Price', required: false }, { name: 'fanMenuPrice15', type: 'int', minValue: 0, label: 'Fan Menu Item #15 Price', required: false }, { name: 'menuItem16', type: 'str', minLength: 4, maxLength: 60, label: 'Unlisted Menu Item #1', required: false }, { name: 'menuPrice16', type: 'int', minValue: 1, label: 'Unlisted Menu Item #1 Price', required: false }, { name: 'fanMenuPrice16', type: 'int', minValue: 0, label: 'Unlisted Fan Menu Item #1 Price', required: false }, { name: 'menuItem17', type: 'str', minLength: 4, maxLength: 60, label: 'Unlisted Menu Item #2', required: false }, { name: 'menuPrice17', type: 'int', minValue: 1, label: 'Unlisted Menu Item #2 Price', required: false }, { name: 'fanMenuPrice17', type: 'int', minValue: 0, label: 'Unlisted Fan Menu Item #2 Price', required: false }, { name: 'menuItem18', type: 'str', minLength: 4, maxLength: 60, label: 'Unlisted Menu Item #3', required: false }, { name: 'menuPrice18', type: 'int', minValue: 1, label: 'Unlisted Menu Item #3 Price', required: false }, { name: 'fanMenuPrice18', type: 'int', minValue: 0, label: 'Unlisted Fan Menu Item #3 Price', required: false }, { name: 'menuItem19', type: 'str', minLength: 4, maxLength: 60, label: 'Unlisted Menu Item #4', required: false }, { name: 'menuPrice19', type: 'int', minValue: 1, label: 'Unlisted Menu Item #4 Price', required: false }, { name: 'fanMenuPrice19', type: 'int', minValue: 0, label: 'Unlisted Fan Menu Item #4 Price', required: false }, { name: 'menuItem20', type: 'str', minLength: 4, maxLength: 60, label: 'Unlisted Menu Item #5', required: false }, { name: 'menuPrice20', type: 'int', minValue: 1, label: 'Unlisted Menu Item #5 Price', required: false }, { name: 'fanMenuPrice20', type: 'int', minValue: 0, label: 'Unlisted Fan Menu Item #5 Price', required: false }, // Tip Menu Theme { name: 'tip_menu_theme', type: 'choice', choice1: 'default', choice2: 'Birthday', choice3: 'Halloween', choice4: 'Christmas', defaultValue: 'default', label: 'Select which tip menu theme to use ?' }, // Specific Tip Notice { name: 'specific_tip_notice', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: "Send a specific notice on a specific tip ?" }, { name: 'specific_notice_1', type: 'str', minLength: 0, maxLength: 60, label: 'Specific Notice #1', defaultValue: ':brookesnaprules', required: false }, { name: 'specific_tip_1', type: 'int', minValue: 0, label: 'Specific Tip #1', defaultValue: 333, required: false }, { name: 'specific_fantip_1', type: 'int', minValue: 0, label: 'Specific Fan Tip #1', defaultValue: 250, required: false }, { name: 'specific_notice_2', type: 'str', minLength: 0, maxLength: 60, label: 'Specific Notice #2', defaultValue: ':brookesnaprules', required: false }, { name: 'specific_tip_2', type: 'int', minValue: 0, label: 'Specific Tip #2', defaultValue: 616, required: false }, { name: 'specific_fantip_2', type: 'int', minValue: 0, label: 'Specific Fan Tip #2', defaultValue: 462, required: false }, // Specific Tip Counter { name: 'specific_tip_counter', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: "Counter for number of 23's tipped ?" }, // King Tipper Counter and Avatar { name: 'king_tipper_counter', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: 'Enable simple King Tipper ?' }, { name: 'king_tipper_a', type: 'str', minLength: 1, maxLength: 26, label: 'King Tipper Avatar/Label', defaultValue: ':avatar_brookeKingTipThumb' }, // King Tipper Achievement { name: 'king_tipper_achieve', type: 'str', minLength: 0, maxLength: 26, label: 'King Tipper Achievement (Leave blank for none)', defaultValue: ':brookekingtipperachieve', required: false }, // Rotating Notifier { name: 'rotnotice', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: "Enable rotating notices ?"}, { name:'msg1', type:'str', required: false, label:'Notice 1, [hightipper] = king tipper\'s name, [highamount] = high tip ammount', defaultValue: ':avatar_brookeKingTipThumb [hightipper] is currently the king tipper with [highamount] tokens!',}, { name:'msg2', type:'str', required: false, label:'Notice 2',}, { name:'msg3', type:'str', required: false, label:'Notice 3',}, { name:'msg4', type:'str', required: false, label:'Notice 4',}, { name:'msg5', type:'str', required: false, label:'Notice 5',}, { name:'msg6', type:'str', required: false, label:'Notice 6',}, { name:'msg7', type:'str', required: false, label:'Notice 7',}, { name:'msgcolor', type:'str', label:'Notice color (html code default purple #6900CC)', defaultValue: '#6900CC'}, { name:'msgbackground', type:'str', required: false, label:'Notice background color (default: #EEE5FF | leave blank for none)', defaultValue: '#EEE5FF'}, { name: 'notice_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 3, label: 'Delay in minutes between notices being displayed (minimum 1)'} ] // User Tip Total var tipper_array = new Array; var num_of_tippers = 0; // Covert token to $$$ var token_value = 5; var total_tip = 0; // Counter for specific tip var numcount = 0; // Counter for achievement played var achievecount = 0; // Counter for king tipper var high_tip_username = 'No one'; var high_tip_amount = 0; // Variables for rotating notifier var ni=0; var MAXITEMS=7; // Tip Menu Theme Variables var tipmenu_theme = ''; var tipmenu_bg = ''; var tipmenu_txt = ''; switch (cb.settings.tip_menu_theme) { case 'default': tipmenu_theme = ':heart2'; themenotice_top = '------------------------------------------------------------'; themenotice_bottom = '------------------------------------------------------------'; themenotice_tm = '------------------BROADCASTER------------------------'; tipmenu_notice = ':heart7 :heart7 '; tipmenu_bg = '#FFCCFF'; tipmenu_txt = '#990099'; break; case 'Birthday': tipmenu_theme = ':bdaypixel'; themenotice_top = '------------------------------------------------------------'; themenotice_bottom = '------------------------------------------------------------'; themenotice_tm = '------------------BROADCASTER------------------------'; tipmenu_notice = ':bdaypixel :bdaypixel '; tipmenu_bg = '#00E5EE'; tipmenu_txt = '#00868B'; break; case 'Halloween': tipmenu_theme = ':brookepumpkin'; themenotice_top = '------------------------------------------------------------'; themenotice_bottom = '------------------------------------------------------------'; themenotice_tm = '------------------BROADCASTER------------------------'; tipmenu_notice = ':brookepumpkin :brookepumpkin '; tipmenu_bg = '#FE8000'; tipmenu_txt = '#191919'; break; case 'Christmas': tipmenu_theme = ':brookexmasgift'; themenotice_top = ':brookemistletoetl :xmasbrookelightsup :brookemistletoetr '; themenotice_bottom = ':brookemistletoebl :xmasbrookelightsdown :brookemistletoebr '; themenotice_tm = ':brookemistletoetl -----------------BROADCASTER----------------------- :brookemistletoetr '; tipmenu_notice = ':brookemistletoec :brookemistletoec '; tipmenu_bg = '#03DC38'; tipmenu_txt = '#C70411'; break; default: tipmenu_theme = ''; themenotice_top = '------------------------------------------------------------'; themenotice_bottom = '------------------------------------------------------------'; themenotice_tm = '------------------BROADCASTER------------------------'; tipmenu_notice = ':heart7 :heart7 '; tipmenu_bg = ''; tipmenu_txt = ''; break; } /*********************************************************************** Event Handling ***********************************************************************/ cb.onTip(function (tip) { // Auto Tip Thank You if (cb.settings.auto_tip_thank_you_allowed == '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, notice_bg_color, notice_txt_color, 'bold'); } } // Convert Token to $$$ if (cb.settings.convert_token_allowed == 'Yes') { total_tip += tip['amount']; var dollar_msg = 'Last tip received: ' + tip['amount'] + ' tokens = ' + convertToken(tip['amount']) + '$\nTotal tokens received: ' + total_tip + ' tokens = ' + convertToken(total_tip) + '$'; //cb.sendNotice(dollar_msg, tipper, '#FFFF33', '#000000', 'bold'); cb.sendNotice(dollar_msg, cb.room_slug, '#FFFF33', '#000000', 'bold'); } // User Tip Total if (cb.settings.user_tip_total_allowed == 'Yes') { tipper_array[findTipper(tip['from_user'])][1] += parseInt(tip['amount']); } // King Tipper Total and Name if (cb.settings.king_tipper_counter == 'Yes') { if (tip['from_user'] == high_tip_username) { high_tip_amount = tipper_array[findTipper(tip['from_user'])][1] } else { if (tipper_array[findTipper(tip['from_user'])][1] > high_tip_amount) { var kingachStr = ""; kingachStr = cb.settings.king_tipper_achieve; high_tip_amount = tipper_array[findTipper(tip['from_user'])][1] high_tip_username = tip['from_user'] cb.sendNotice(kingachStr, null, null, alert_txt_color, 'bold'); cb.sendNotice(tip['from_user'] + ' is now the king tipper!', null, alert_bg_color, alert_txt_color, 'bold'); } } } // Tip Menu if (tip['from_user_in_fanclub'] == false){ if (cb.settings.tip_menu_allowed == 'Yes') { for (var i = 1; i <= 20; i++) { if (tip['amount'] == parseInt(cb.settings['menuPrice' + i])) { cb.sendNotice(tipmenu_notice + tip['from_user'] + ' tipped for : ' + cb.settings['menuItem' + i], null, alert_bg_color, alert_txt_color, 'bold'); } } } } // Fan Tip Menu if (tip['from_user_in_fanclub'] == true){ if (cb.settings.tip_menu_allowed == 'Yes') { for (var i = 1; i <= 20; i++) { if (tip['amount'] == parseInt(cb.settings['fanMenuPrice' + i])) { cb.sendNotice(':fanclubiconbutton ' + tip['from_user'] + ' tipped for : ' + cb.settings['menuItem' + i], null, alert_bg_color, alert_txt_color, 'bold'); } } } } // Specific Tip Notice if (tip['from_user_in_fanclub'] == false){ if (cb.settings.specific_tip_notice == 'Yes') { for (var stn = 1; stn <= 2; stn++) { if (tip['amount'] == parseInt(cb.settings['specific_tip_' + stn])) { cb.sendNotice(cb.settings['specific_notice_' + stn], null); } } } } // Specific Fan Tip Notice if (tip['from_user_in_fanclub'] == true){ if (cb.settings.specific_tip_notice == 'Yes') { for (var stn = 1; stn <= 2; stn++) { if (tip['amount'] == parseInt(cb.settings['specific_fantip_' + stn])) { cb.sendNotice(cb.settings['specific_notice_' + stn], null); } } } } // Specific Tip Counter if (cb.settings.specific_tip_counter == 'Yes') { if (tip['amount'] == 23) { numcount++; cb.sendNotice("I've been loved " + numcount + ' times so far!', null, '#40e0d0', null, 'bold'); } } // Tip Counter Milestones if (cb.settings.specific_tip_counter == 'Yes') { if (numcount == 50) { if (achievecount == 0) { achievecount++; cb.sendNotice(':synn50aniachievement', null); } else { null}; } } if (cb.settings.specific_tip_counter == 'Yes') { if (numcount == 100) { if (achievecount == 1) { achievecount++; cb.sendNotice(':chefaniachievesynn', null); } else { null}; } } if (cb.settings.specific_tip_counter == 'Yes') { if (numcount == 150) { if (achievecount == 2) { achievecount++; cb.sendNotice(':pandasynnaniachieve', null); } else { null}; } } if (cb.settings.specific_tip_counter == 'Yes') { if (numcount == 200) { if (achievecount == 3) { achievecount++; cb.sendNotice(':aniachieveunisynn', null); } else { null}; } } if (cb.settings.specific_tip_counter == 'Yes') { if (numcount == 250) { if (achievecount == 4) { achievecount++; cb.sendNotice(':tonsloveforbs', null); } else { null}; } } if (cb.settings.specific_tip_counter == 'Yes') { if (numcount == 300) { if (achievecount == 5) { achievecount++; cb.sendNotice(':abundanceloveforbs', null); } else { null}; } } if (cb.settings.specific_tip_counter == 'Yes') { if (numcount == 350) { if (achievecount == 6) { achievecount++; cb.sendNotice(':mathematicalloveforbs', null); } else { null}; } } if (cb.settings.specific_tip_counter == 'Yes') { if (numcount == 400) { if (achievecount == 7) { achievecount++; cb.sendNotice(':ani400loveforbs', null); } else { null}; } } if (cb.settings.specific_tip_counter == 'Yes') { if (numcount == 5000) { if (achievecount == 8) { achievecount++; cb.sendNotice(':5000loveforbs', null); } else { null}; } } }); cb.onMessage(function(msg) { var message = msg['m']; if (cb.settings.fanclub_highlight == 'Yes' && msg['in_fanclub'] == true) { msg['background'] = '#EAFFE0' } // bc, tm, cnd, cnh, tipmenu, kingtip, lovetip Commands if (msg['is_mod'] == true && message.charAt(0)=="/" && message.charAt(1)=="b" && message.charAt(2)=="c") { message = message.replace("/bc",""); cb.sendNotice(themenotice_top + '\n \u2022 ' + msg['user'].toUpperCase() + ": " + message + '\n' + themenotice_bottom, cb.room_slug, '#FFFFBF', '#D80A00', 'bold'); cb.sendNotice(themenotice_top + '\n \u2022 ' + msg['user'].toUpperCase() + ": " + message + '\n' + themenotice_bottom, msg['user'], '#FFFFBF', '#D80A00', 'bold'); msg['X-Spam'] = true; // Suppress command } if (msg['user'] == cb.room_slug && message.charAt(0)=="/" && message.charAt(1)=="t" && message.charAt(2)=="m") { message = message.replace("/tm",""); cb.sendNotice(themenotice_tm + '\n \u2022 ' + message + '\n' + themenotice_bottom, cb.room_slug, '#E0EEFF', '#12447A', 'bold'); cb.sendNotice(themenotice_tm + '\n \u2022 ' + message + '\n' + themenotice_bottom,'', '#E0EEFF', '#12447A', 'bold', 'red'); msg['X-Spam'] = true; // Suppress command } if (msg['is_mod'] == true || msg['user'] == cb.room_slug) { if (message.charAt(0)=="/" && message.charAt(1)=="c" && message.charAt(2)=="n" && message.charAt(3)=="d") { message = message.replace("/cnd",""); cb.sendNotice(themenotice_top + '\n \u2022 ' + message + '\n' + themenotice_bottom,'','', '#6900CC', 'bold'); msg['X-Spam'] = true; // Suppress command }} if (msg['is_mod'] == true || msg['user'] == cb.room_slug) { if (message.charAt(0)=="/" && message.charAt(1)=="c" && message.charAt(2)=="n" && message.charAt(3)=="h") { message = message.replace("/cnh",""); cb.sendNotice(themenotice_top + '\n \u2022 ' + message + '\n' + themenotice_bottom,'', cb.settings['msgbackground'], cb.settings['msgcolor'], 'bold'); msg['X-Spam'] = true; // Suppress command }} if (msg['is_mod'] == true || msg['user'] == cb.room_slug) { if (message == "/tipmenu") { cmdTipMenu() msg['X-Spam'] = true; // Suppress command }} if (msg['is_mod'] == true || msg['user'] == cb.room_slug) { if (message == "/kingtip") { cb.sendNotice(cb.settings.king_tipper_a + ' ' + high_tip_username + ' is currently the king tipper with ' + high_tip_amount + ' tokens!', null, alert_bg_color, alert_txt_color, 'bold'); msg['X-Spam'] = true; // Suppress command }} if (msg['is_mod'] == true || msg['user'] == cb.room_slug) { if (message == "/lovetip") { cb.sendNotice('There has been ' + numcount + ' tips of love so far tonight!', null, '#40e0d0', null, 'bold'); msg['X-Spam'] = true; // Suppress command }} // Convert all caps message if (cb.settings.convert_all_caps_allowed == 'Yes') { if (message == message.toUpperCase() && !msg['is_mod'] && msg['user'] != cb.room_slug ) { // Convert to lower case message = message.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'); } } // User Gender if (msg['in_fanclub'] == false) { if (cb.settings.gender_allowed == 'Yes' && msg['user'] != cb.room_slug && message.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; } message = genderStr + ' ' + message; } } // Fanclub Gender if (msg['in_fanclub'] == true) { if (cb.settings.gender_allowed == 'Yes' && msg['user'] != cb.room_slug && message.charAt(0)!="/") { var fanclubStr = ""; fanclubStr = cb.settings.gender_fan; message = fanclubStr + ' ' + message; } } // Broadcaster Avatar if (msg['user'] == cb.room_slug) { if (cb.settings.broadcaster_avatar == 'Yes' && msg['user'] == cb.room_slug && message.charAt(0)!="/") { var broadcasterStr = ""; broadcasterStr = cb.settings.broadcaster_a; message = broadcasterStr + ' ' + message; } } // King Tipper Avatar if (msg['user'] == high_tip_username) { if (cb.settings.king_tipper_counter == 'Yes' && msg['user'] != cb.room_slug && message.charAt(0)!="/") { var kingStr = ""; kingStr = cb.settings.king_tipper_a; message = kingStr + ' ' + message; } } // User tip total if (cb.settings.user_tip_total_allowed == 'Yes' && msg['user'] != cb.room_slug && parseInt(tipper_array[findTipper(msg['user'])][1]) >= 0 && message.charAt(0) != "/") { message = setTipTitles(msg['user'], message); } // Match message color to user color if (cb.settings.match_color_allowed == 'Yes') { var strColor = ""; if (msg['has_tokens'] == false) { //msg['c'] = '#666666'; // Grey User : have no token msg['c'] = '#757575'; // Grey User : have no token } else { //msg['c'] = '#6699AA'; // Light Blue : own or have purchased tokens msg['c'] = '#0066FF'; // Light Blue : own or have purchased tokens } if (msg['is_mod'] == true) { msg['c'] = '#FF0000'; // Red : Moderators } if (msg['is_fanclub'] == true) { msg['c'] = '#009900'; // Green : Fan Club Members } if (msg['tipped_recently'] == true) { msg['c'] = '#000099'; // Dark Blue : Tipped at least 50 tkn. } if (msg['tipped_alot_recently'] == true) { //msg['c'] = '#BE6AFF'; // Purple : Tipped at least 250 tkn. msg['c'] = '#D633AD'; // Purple : Tipped at least 250 tkn. } if (msg['tipped_tons_recently'] == true) { //msg['c'] = '#924BAA'; // Dark Purple : Tipped at least 1000 tkn. msg['c'] = '#8F006B'; // Dark Purple : Tipped at least 1000 tkn. } if (msg['user'] == cb.room_slug) { msg['c'] = '#DC5500'; // Orange : The Broadcaster } } // Random message colour if (cb.settings.random_color_allowed == 'Yes') { var colors = []; var broadcaster = cb.room_slug; var min_level = 0.5; var gamma = 0.1; var preset_colors = { '/red': '#FF0000', '/green': '#009900', '/lightblue': '#0066FF', '/darkblue': '#000099', '/pink': '#FF00FF', '/yellow': '#AAAA00', '/cyan': '#008888', '/purple': '#D633AD' } function to_hex(value){ var str = value.toString(16); if (str.length == 1){ str = '0' + str; } return str; } function html_color(r, g, b){ return '#' + to_hex(r) + to_hex(g) + to_hex(b); } function hue_strength(hue){ return Math.pow(0.5 * (1 + Math.cos(2 * Math.PI * hue / 120.)), gamma); } function pick_color(){ var t = Math.random() * 360; var ti = Math.floor(t/60); var v = 255 * (min_level + (1.0-min_level) * Math.random() * hue_strength(t)) - 15; var f = t/60 - ti; var m = Math.floor(v * (1 - f)); var n = Math.floor(v * f); v = Math.floor(v); var r = 0; var g = 0; var b = 0; if (ti == 0){ r = v; g = n; b = 0; } else if (ti == 1){ r = m; g = v; b = 0; } else if (ti == 2){ r = 0; g = v; b = n; } else if (ti == 3){ r = 0; g = m; b = v; } else if (ti == 4){ r = n; g = 0; b = v; } else if (ti == 5){ r = v; g = 0; b = m; } return html_color(r, g, b); } function get_user_color(user){ if (typeof(colors[user]) == 'undefined'){ set_user_color(user); } return colors[user]; } function set_user_color(user){ colors[user] = pick_color(); } } if (cb.settings.random_color_allowed == 'Yes') { var user = msg["user"]; if ( ( (user in colors) || (msg["c"] == "#494949") ) ){ msg["c"] = get_user_color(user); } if (msg["m"] == "/color"){ set_user_color(user); msg["c"] = get_user_color(user); msg["X-Spam"] = true; } else if (msg["m"][0] = "/"){ for (var color in preset_colors){ if (msg.m == color) { colors[msg.user] = preset_colors[color]; msg.c = get_user_color(user); msg["X-Spam"] = true; } } } msg['f'] = 'default'; msg['m'] = message; return msg;} if (cb.settings.random_color_allowed == 'No') { msg['f'] = 'default'; msg['m'] = message; return msg;} }); 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'], notice_bg_color, notice_txt_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'], notice_bg_color, notice_txt_color, 'bold'); displayRules(user); } }); /*********************************************************************** Functions ***********************************************************************/ function tipperArrayPopulate(user) { // adds tippers to the tipper_array tipper_array[num_of_tippers] = new Array; tipper_array[num_of_tippers][0] = user; tipper_array[num_of_tippers][1] = 0; num_of_tippers++; } function findTipper(user) { // find the index of the tipper for (var i = 0; i < tipper_array.length; i++) { if (tipper_array[i][0] == user) { break; } } // the tipper is not in the array. add him and call findTipper if (i == tipper_array.length) { tipperArrayPopulate(user); findTipper(user); } return i; } 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 + tipper_array[findTipper(user)][1] + bracket_close + ' ' + message; return m; } function convertToken(token) { var dollar = Number(token) * token_value; return (dollar/100).toFixed(2); } // 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, notice_bg_color, notice_txt_color, 'bold'); } // Tip Menu function showTipMenu() { var msg = 'Tip Menu:\n'; if (cb.settings.tip_menu_horizontal == 'Yes') { for (i = 1; i <= 15; i++) { if (parseInt(cb.settings['menuPrice' + i]) > 0) { msg += tipmenu_theme + ' ' + cb.settings['menuItem' + i] + ' (' + parseInt(cb.settings['menuPrice' + i]) + ' tokens) '; } } cb.sendNotice(msg, null, tipmenu_bg, tipmenu_txt, 'bold'); cb.setTimeout(showTipMenu, (cb.settings.tip_menu_ad * 60000)); } else { for (i = 1; i <= 15; i++) { if (parseInt(cb.settings['menuPrice' + i]) > 0) { msg += tipmenu_theme + ' ' + cb.settings['menuItem' + i] + ' (' + parseInt(cb.settings['menuPrice' + i]) + ' tokens)\n'; } } cb.sendNotice(msg, null, tipmenu_bg, tipmenu_txt, 'bold'); cb.setTimeout(showTipMenu, (cb.settings.tip_menu_ad * 60000)); } } // Fan Tip Menu function showFanTipMenu() { var msg = 'Fan Club Tip Menu:\n'; if (cb.settings.tip_menu_horizontal == 'Yes') { for (i = 1; i <= 15; i++) { if (parseInt(cb.settings['fanMenuPrice' + i]) > 0) { msg += cb.settings['fan_tip_menu_icon'] + ' ' + cb.settings['menuItem' + i] + ' (' + parseInt(cb.settings['fanMenuPrice' + i]) + ' tokens) '; } } cb.sendNotice(msg, null, notice_fan_bg_color, notice_fan_color, 'bold', 'green'); cb.setTimeout(showFanTipMenu, (cb.settings.tip_menu_ad * 60000)); } else { for (i = 1; i <= 15; i++) { if (parseInt(cb.settings['fanMenuPrice' + i]) > 0) { msg += cb.settings['fan_tip_menu_icon'] + ' ' + cb.settings['menuItem' + i] + ' (' + parseInt(cb.settings['fanMenuPrice' + i]) + ' tokens)\n'; } } cb.sendNotice(msg, null, notice_fan_bg_color, notice_fan_color, 'bold', 'green'); cb.setTimeout(showFanTipMenu, (cb.settings.tip_menu_ad * 60000)); } } // Tip Menu Command function cmdTipMenu() { var msg = 'Tip Menu:\n'; if (cb.settings.tip_menu_horizontal == 'Yes') { for (i = 1; i <= 15; i++) { if (parseInt(cb.settings['menuPrice' + i]) > 0) { msg += tipmenu_theme + ' ' + cb.settings['menuItem' + i] + ' (' + parseInt(cb.settings['menuPrice' + i]) + ' tokens) '; } } cb.sendNotice(msg, null, tipmenu_bg, tipmenu_txt, 'bold'); } else { for (i = 1; i <= 15; i++) { if (parseInt(cb.settings['menuPrice' + i]) > 0) { msg += tipmenu_theme + ' ' + cb.settings['menuItem' + i] + ' (' + parseInt(cb.settings['menuPrice' + i]) + ' tokens)\n'; } } cb.sendNotice(msg, null, tipmenu_bg, tipmenu_txt, 'bold'); } } // Rotating Notifier function noticeAd() { var msg; if (cb.settings.rotnotice == 'Yes') { while (cb.settings['msg' + (ni + 1)] == 0) { //skip empty messages ni++; ni %= MAXITEMS; } msg = cb.settings['msg' + (ni + 1)]; msg = msg.replace("[hightipper]", high_tip_username); msg = msg.replace("[highamount]", high_tip_amount); ni++; ni %= MAXITEMS; cb.sendNotice(themenotice_top + '\n \u2022 '+msg + '\n' + themenotice_bottom,'',cb.settings['msgbackground'],cb.settings['msgcolor'],'bold'); cb.setTimeout(noticeAd, (cb.settings.notice_ad * 60000)); } } /*********************************************************************** Initialization ***********************************************************************/ // Tip Menu if (cb.settings.tip_menu_allowed == 'Yes') { cb.setTimeout(showTipMenu, (cb.settings.tip_menu_ad * 60000)); } // Fan Tip Menu if (cb.settings.tip_menu_allowed == 'Yes') { cb.setTimeout(showFanTipMenu, (cb.settings.tip_menu_ad * 60000)); } // Rotating Notifier if (cb.settings.rotnotice == 'Yes') { cb.setTimeout(noticeAd, (cb.settings.notice_ad * 60000)); } function init() { } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.