Bots Home
|
Create an App
kbot test
Author:
sabrinataco
Description
Source Code
Launch Bot
Current Users
Created by:
Sabrinataco
/*********************************************************************** Title: My Multi-Bot Author: Mariuz7 Version: 1.1 (2015-11-26) 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 Change Log : 1.1 Fix apps command prefix - Thanks to acrazyguy! 1.0 Initial Release Version 0.8 Tip Menu ***********************************************************************/ /*********************************************************************** Global Variables ***********************************************************************/ var notice_txt_color = '#990099'; var notice_bg_color = '#faf2ff'; 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 ?' }, // 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 ***********************************************************************/ 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 && 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; } // 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() { } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.