Bots Home
|
Create an App
aaa
Author:
reaoknky84
Description
Source Code
Launch Bot
Current Users
Created by:
Reaoknky84
/*********************************************************************** Author: Noddie82 Title: The Gift of Voice and Color Description: Silences all grays, except those that you decide should be allowed to talk. Moderators and people with tokens have voice by default, but can loose it. Change Log: v1.1 - 2013-04-10: Added option to grant users special background-colors Added option to reset all background-colors Added toggle to disable/reenable voice control v1.0 - 2013-04-09: Initial Release. Title: My Multi-Bot Author: Mariuz7 Version: 0.8 (2015-01-31) This bot implements many functions: * Auto Tip Thank You * Identify User Gender * Match message color to user color * Custom Welcome Message * User Tip Total * Convert all caps messages * Convert token to $$$ (for Broadcaster only) * Room rules * 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 To Do : Change Log : 1.0 Initial Release Version 0.8 Tip Menu ***********************************************************************/ /*********************************************************************** Global Variables ***********************************************************************/ 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 ?' }, // 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' }, // 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_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 15, label: 'Delay in minutes between notice being displayed (minimum 1)' }, { 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 } ] // User Tip Total var tipper_array = new Array; var num_of_tippers = 0; // Covert token to $$$ var token_value = 5; var total_tip = 0; /*********************************************************************** Event Handling ***********************************************************************/ var voiceToggle = 1; var voicedUsers = new Array(); var coloredUsers = new Array(); var colors = new Array(); colors['blue'] = "3399FF"; colors['orange'] = "FF9933"; colors['pink'] = "FF6699"; colors['green'] = "008000"; colors['teal'] = "00FFFF"; colors['gray'] = "CCCCCC"; colors['aqua'] = "00FFFF"; colors['violet'] = "EE82EE"; colors['tan'] = "D2B48C"; colors['yellow'] = "FFFF00"; colors['sky'] = "87CEEB"; colors['fuschia'] = "FF00FF"; colors['forest'] = "228B22"; colors['gold'] = "FFD700"; colors['crimson'] = "DC143C"; colors['red'] = "FF0000"; var notice_txt_color = '#990099'; var notice_bg_color = '#FFCCFF'; var alert_txt_color = '#B40431'; var alert_bg_color = '#F6CED8'; cb.chatNotice("The Gift of Voice and Color activated"); cb.chatNotice("/voice USER to give voice"); cb.chatNotice("/unvoice USER to take voice away"); cb.chatNotice("/listvoices to list who has voice"); cb.chatNotice("/color USER COLOR to make a user have a special background-color"); cb.chatNotice("- Possible colors: blue, orange, pink, green, teal, gray. No color specified will reset the background"); cb.chatNotice("/togglevoice - toggle the voice control on or off (Default On)"); cb.chatNotice("/resetcolors - reset all custom colors"); cb.onMessage(function (msg) { var usr = msg['user']; if(coloredUsers[usr]) { msg['background'] = '#' + colors[coloredUsers[usr]]; ; //grant the gift of cool background colors } var isMod = usr == cb.room_slug || msg['is_mod']; var hasVoice = voicedUsers[usr] && true; if(isMod) { hasVoice = true; //mods always have voice and cannot be unvoiced } else if(msg['has_tokens'] || msg['in_fanclub'] ) { if(voicedUsers[usr] == null) { //if a user has tokens or is in fanclub, they must explicitly loose voice to be silenced hasVoice = true; } else { hasVoice = voicedUsers[usr]; } } if(!hasVoice && voiceToggle) { //only stop message if voice is toggled on msg['X-Spam'] = true; //tell the user his message cannot be read by anyone else cb.chatNotice("*** Your message was not delivered because you don't have voice ***",usr); return msg; } if(isMod) { if(msg['m'].substring(0,11) == "/listvoices") { msg['X-Spam'] = true; cb.chatNotice("*** Voiced people ***",usr); for (var i in voicedUsers) { if(i && voicedUsers[i]) { cb.chatNotice(i,usr); } } } else if(msg['m'].substring(0,6) == "/voice") { var temp = msg['m'].split(" "); if(temp.length > 1) { voicedUsers[temp[1].trim()] = true; cb.chatNotice("The Gift of Voice has been granted to '" + temp[1].trim() + "'!"); } else { cb.chatNotice("Useage: /voice USER",usr); } msg['X-Spam'] = true; } else if(msg['m'].substring(0,8) == "/unvoice") { var temp = msg['m'].split(" "); if(temp.length > 1) { voicedUsers[temp[1].trim()] = false; cb.chatNotice("The Gift of Voice has been removed from '" + temp[1].trim() + "'!"); } else { cb.chatNotice("Useage: /unvoice USER",usr); } msg['X-Spam'] = true; } else if(msg['m'].substring(0,6) == "/color") { var temp = msg['m'].split(" "); if(temp.length == 1) { cb.chatNotice("Useage /color USER color",usr); cb.chatNotice("- Possible colors: blue, orange, pink, green, teal, gray",usr); } else if(temp.length > 1) { var theColor = null; var theUser = temp[1].trim(); if(temp.length > 2) { theColor = temp[2].trim(); if(colors[theColor] ) { cb.chatNotice("The Gift of the Color " + theColor + " has been granted to '" + theUser + "'!"); } else { if(theColor.substring(0,1) == "#") { theColor = theColor.substring(1,7); colors[theColor] = theColor; //save the special color code } else { cb.chatNotice("Unknown color - Possible colors: blue, orange, pink, green, teal, gray",usr); theColor = coloredUsers[theUser]; } } } else { cb.chatNotice("The Gift of Color has been removed from '" + theUser + "'!"); } coloredUsers[theUser] = theColor; } msg['X-Spam'] = true; } else if(msg['m'] == "/togglevoice") { if(voiceToggle) { voiceToggle = false; cb.chatNotice("Voice control disabled, everyone can talk!"); } else { cb.chatNotice("Voice control enabled, grays can no longer talk!"); voiceToggle = true; } msg['X-Spam'] = true; } else if(msg['m'] == "/resetcolors") { cb.chatNotice("All colors have been reset!"); coloredUsers = new Array(); msg['X-Spam'] = true; } } return msg; }); 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']); } // Tip Menu if (cb.settings.tip_menu_allowed == 'Yes') { for (var i = 1; i <= 10; i++) { if (tip['amount'] == parseInt(cb.settings['menuPrice' + i])) { cb.sendNotice(':heart7 :heart7 ' + tip['from_user'] + ' tipped for : ' + cb.settings['menuItem' + i], null, alert_bg_color, alert_txt_color, 'bold'); } } } }); cb.onMessage(function(msg) { var message = msg['m']; // 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 (cb.settings.gender_allowed == 'Yes' && msg['user'] != cb.room_slug) { 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; } // User tip total if (cb.settings.user_tip_total_allowed == 'Yes' && 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 } } 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'; for (i = 1; i <= 10; i++) { if (parseInt(cb.settings['menuPrice' + i]) > 0) { msg += ':heart2 ' + cb.settings['menuItem' + i] + ' (' + parseInt(cb.settings['menuPrice' + i]) + ' tokens)\n'; } } cb.sendNotice(msg, null, notice_bg_color, notice_txt_color, 'bold'); cb.setTimeout(showTipMenu, (cb.settings.tip_menu_ad * 60000)); } /*********************************************************************** Initialization ***********************************************************************/ // Tip Menu if (cb.settings.tip_menu_allowed == 'Yes') { cb.setTimeout(showTipMenu, (cb.settings.tip_menu_ad * 60000)); } function init() { }
© Copyright Chaturbate 2011- 2026. All Rights Reserved.