Bots Home
|
Create an App
test bot5
Author:
for_us_2_play
Description
Source Code
Launch Bot
Current Users
Created by:
For_Us_2_Play
/*********************************************************************** Title: My Multi-Bot Author: Mariuz7 Version: 0.4 (2015-01-14) 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 the Broadcaster only) * Room rules Based on : # Auto Tip Thank You 1.0 - Kmoore # Ultra Bot 1.06 - britney_and_justin # Room Rules 1.12.1 - Zingknaat To Do : Change Log : 1.0 Initial Release Version 0.4 Add Room Rules ***********************************************************************/ /*********************************************************************** Global Variables ***********************************************************************/ var notice_txt_color = '#990099'; var notice_bg_color = '#FFCCFF'; 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 our room [user].' }, // User Tip Total { name: 'user_tip_total_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Do you want to display users\' tip totals ?' }, // Convert Token { name: 'convert_token_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Do you want to display converted tokens in dollars ?' }, // Convert All Caps Messages { name: 'convert_all_caps_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Do you want to 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: 'Do you want to 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: 'Do you want to display 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 the love!', label: 'Tip thank you message, [tipper] = tipper\'s name' }, // User Gender { name: 'gender_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Do you want to display gender in front of messages ?' }, { name: 'gender_f', type: 'str', minLength: 1, maxLength: 10, label: 'Female Gender Label', defaultValue: '|F|' }, { name: 'gender_m', type: 'str', minLength: 1, maxLength: 10, label: 'Male Gender Label', defaultValue: '|M|' }, { name: 'gender_t', type: 'str', minLength: 1, maxLength: 10, label: 'Transsexual Gender Label', defaultValue: '|T|' }, { name: 'gender_c', type: 'str', minLength: 1, maxLength: 10, label: 'Couple Gender Label', defaultValue: '|C|' }, // Room Rules { name: 'room_rules_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Do you want to display 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} ] // 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 tipper_array[findTipper(tip['from_user'])][1] += parseInt(tip['amount']); } }); 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') { 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 } else { msg['c'] = '#6699AA'; // 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. } if (msg['tipped_tons_recently'] == true) { msg['c'] = '#924BAA'; // 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 m = '|' + tipper_array[findTipper(user)][1] + '| ' + message; return m; } function convertToken(token) { var dollar = Number(token) * token_value; return (dollar/100).toFixed(2); } 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'); } /*********************************************************************** Initialization ***********************************************************************/ function init() { } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.