Bots Home
|
Create an App
Cappububu
Author:
cappu15
Description
Source Code
Launch Bot
Current Users
Created by:
Cappu15
cb.settings_choices = [ {name: 'commanders', label: 'Users who can use the bot\'s commands', type: 'str', defaultValue: 'juhne77 by codeanon', required: false}, {name: 'entry_msg', label: '[WELCOME MESSAGE] ---------------- Send a welcome message to users upon entering?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'entry_msg_txt', label: 'Message to send (use # where the user\'s name should be)', type: 'str', required: false, defaultValue: 'Welcome, #!'}, {name: 'entry_msg_color', label: 'Message color (hex code)', type: 'str', required: false, defaultValue: '#000000'}, {name: 'thanks_msg', label: '[THANK YOU MESSAGE] ---------------- Send a message to users upon tipping a certain amount?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'thanks_amt', label: 'Minimum amount required to receive Thank You message', type: 'int', defaultValue: 25}, {name: 'thanks_msg_txt', label: 'Message to send (use # where the user\'s name should be)', type: 'str', required: false, defaultValue: 'Thank you, #!'}, {name: 'thanks_msg_color', label: 'Message color (hex code)', type: 'str', required: false, defaultValue: '#000000'}, {name: 'tip_menu_obj', label: '[TIP MENU] ---------------- Tip menu values', type: 'str', required: false, defaultValue: '5: 1 Spank, 12: Titty Spank, 16: You like me!'}, {name: 'tip_menu_color', label: 'Tip menu color (hex code)', type: 'str', required: false, defaultValue: '#000000'}, {name: 'tip_menu_interval', label: 'Seconds between displays of the tip menu (0 = off)', type: 'int', defaultValue: '180'}, {name: 'tip_menu_delay', label: 'Seconds before first display of tip menu', type: 'int', defaultValue: 0, }, {name: 'lovers_color', label: '[LOVERS OF THE DAY] ------------------- Lovers of the day chart color', type: 'str', defaultValue: '#BD1398'}, {name: 'lovers_interval', label: 'Seconds between displays of the current lovers of the day (0 = off)', type: 'int', defaultValue: '180'}, {name: 'lovers_delay', label: 'Seconds before first display of Lover Of The Day', type: 'int', defaultValue: '60'}, {name: 'level_1_emote', label: '[TOKEN REWARDS] -------------------- Level 1 Emote', type: 'str', required: false}, {name: 'level_1_threshold', label: 'Level 1 Tokens', type: 'int', minValue: 0, defaultValue: 100, required: false}, {name: 'level_2_emote', label: 'Level 2 Emote', type: 'str', required: false}, {name: 'level_2_threshold', label: 'Level 2 Tokens', type: 'int', minValue: 0, defaultValue: 250, required: false}, {name: 'level_3_emote', label: 'Level 3 Emote', type: 'str', required: false}, {name: 'level_3_threshold', label: 'Level 3 Tokens', type: 'int', minValue: 0, defaultValue: 500, required: false}, {name: 'level_4_emote', label: 'Level 4 Emote', type: 'str', required: false}, {name: 'level_4_threshold', label: 'Level 4 Tokens', type: 'int', minValue: 0, defaultValue: 800, required: false}, {name: 'level_5_emote', label: 'Level 5 Emote', type: 'str', required: false}, {name: 'level_5_threshold', label: 'Level 5 Tokens', type: 'int', minValue: 0, defaultValue: 1000, required: false}, {name: 'lover_boys', label: '[TEAM LECSY] -------------------- Members', type: 'str', required: false}, {name: 'lover_boys_emote', label: 'Emote', type: 'str', required: false, defaultValue: ':emote'}, {name: 'message_0', label: '[ROTATING MESSAGES] -------------------- Message 01', required: false, type: 'str'}, {name: 'message_1', label: 'Message 02', required: false, type: 'str'}, {name: 'message_2', label: 'Message 03', required: false, type: 'str'}, {name: 'message_3', label: 'Message 04', required: false, type: 'str'}, {name: 'message_4', label: 'Message 05', required: false, type: 'str'}, {name: 'message_5', label: 'Message 06', required: false, type: 'str'}, {name: 'message_6', label: 'Message 07', required: false, type: 'str'}, {name: 'message_7', label: 'Message 08', required: false, type: 'str'}, {name: 'message_8', label: 'Message 09', required: false, type: 'str'}, {name: 'message_9', label: 'Message 10', required: false, type: 'str'}, {name: 'message_10', label: 'Message 11', required: false, type: 'str'}, {name: 'message_11', label: 'Message 12', required: false, type: 'str'}, {name: 'message_12', label: 'Message 13', required: false, type: 'str'}, {name: 'message_13', label: 'Message 14', required: false, type: 'str'}, {name: 'message_14', label: 'Message 15', required: false, type: 'str'}, {name: 'message_15', label: 'Message 16', required: false, type: 'str'}, {name: 'messages_interval', label: 'Seconds between displays of the rotating messages (0 = off)', type: 'int', defaultValue: '180'}, {name: 'messages_delay', label: 'Seconds before messages start rotating', type: 'int', defaultValue: '120'}, {name: 'messages_color', label: 'Message color (hex code)', type: 'str', defaultValue: '#000000', required: false}, ]; /********** ------------ TIPS ------------ **********/ var tipMenu = {}; //object containing the tip numbers and their corresponding values var tipLedger = {'---': 99}; //object containing a how much each user has tipped during this show var loverUser = '---'; //lover of the day //when a new tip comes in, increment everything cb.onTip(function (tip) { var user = tip['from_user']; var amount = tip['amount']; thankYou(user, amount); //send a thank you message if they've tipped enough checkTipMenu(user, amount); //see if they've tipped for an item on the menu updateTipLedger(user, amount); //add the user's tips calcLover(user); }); //thank a user for a high enough tip function thankYou(user, amount) { var num = Number(cb.settings.thanks_amt); cb.log(num); if (!isNaN(num) && amount >= num) { tipMessage(cb.settings.thanks_msg_txt.replace('#', user), user); } } //creates a data-based tip menu from the settings function parseTipMenu() { var menu = cb.settings.tip_menu_obj; if (menu) { var menuArray = menu.split(','); menuArray.forEach(function (item) { var itemArray = item.split(':'); var key = itemArray[0]; var value = itemArray[1]; if (key && value) tipMenu[key.trim()] = value.trim(); }); } } //increment a user's total function updateTipLedger(user, amount) { tipLedger[user] ? tipLedger[user] += amount : tipLedger[user] = amount; } //see if a user is the new lover function calcLover(user) { if (tipLedger[user] >= 100) { if (tipLedger[user] > tipLedger[loverUser] && user !== loverUser) { loverUser = user; var goldHearts = ':FBDKING'; var output = '********************************************\ \n' + goldHearts + ' ' + user + ' is the new King Of The Day! ' + goldHearts + '\ \n********************************************'; cb.sendNotice(newLines(output), '', '', cb.settings.lovers_color, 'bold', ''); } } } //send a notice if a user has tipped for something on the menu function checkTipMenu(user, amount) { if (tipMenu[amount]) tipMessage(user + ' tipped for ' + tipMenu[amount] + '!'); } /********** ------------ MESSAGES ------------ **********/ var tokenRewards = [] var loverBoys = []; //message handler cb.onMessage(function (msg) { if (msg['m'].charAt(0) === '/') { msg['X-Spam'] = true; cmd(msg['m'].substring(1), msg['user']); } else { msg = displayTokenRewards(msg); msg = displayLoverBoys(msg); msg = loverText(msg); } return msg; }); //change display options for lover of the day function loverText(msg) { if (loverUser === msg['user']) msg['background'] = '#F1E2AD'; return msg; } function displayLoverBoys(msg) { try { var user = msg['user']; var index = arrayIndexOf(loverBoys, user); if (user && index > -1) msg['m'] = cb.settings.lover_boys_emote + ' ' + msg['m']; return msg; } catch (e) { cb.sendNotice(e.message, cb.room_slug); } } //add the specified emote before a user's message if they've reached the threshold function displayTokenRewards(msg) { var tips = tipLedger[msg.user]; for (var i = 0; i < tokenRewards.length; i++) { if (tips >= tokenRewards[i].threshold) { msg['m'] = tokenRewards[i].emote + ' ' + msg['m']; break; } } return msg; } //generate token rewards based on settings function parseTokenRewards() { for (var i = 1; i <= 5; i++) { var emote = cb.settings['level_' + i + '_emote']; var threshold = cb.settings['level_' + i + '_threshold']; if (emote && emote.trim().length > 0 && threshold) { tokenRewards.push({'threshold': threshold, 'emote': emote.trim()}); } } if (tokenRewards.length > 1) { tokenRewards.sort(function(a, b) { return b.threshold - a.threshold; }); } } //generate lover boys based on settings function parseLoverBoys() { var input = cb.settings.lover_boys; if (input && input.length > 0) { loverBoys = input.split(','); for (var i = 0; i < loverBoys.length; i++) { loverBoys[i] = loverBoys[i].trim(); } } } cb.onEnter(function (user) { if (cb.settings.entry_msg === 'Yes') { var message = cb.settings.entry_msg_txt.replace('#', user['user']); cb.sendNotice(message, user['user'], '', cb.settings.entry_msg_color, 'bold', ''); } }); /********** ------------ ROTATORS ------------ **********/ var rotatingMessages = []; //display the tip menu function displayTipMenu(username) { var output = '***** TIP MENU *****'; for (var key in tipMenu) { output += '\n' + tipMenu[key] + ' [' + key + ' tokens]'; } output += '\n********************'; cb.sendNotice(newLines(output), '', '', cb.settings.tip_menu_color, 'bold', ''); } //rotate displays of the tip menu function tipMenuRotator() { displayTipMenu(); cb.setTimeout(tipMenuRotator, cb.settings.tip_menu_interval * 1000); } //display the Lovers of the Day function displayLovers() { var output = ''; if (loverUser !== '---') { output += '********* Lecsy\'s King of the Day *********\n:FBDKING ' + loverUser + ' (' + tipLedger[loverUser] + ') :FBDKING\n'; } output += '***** Tip ' + (tipLedger[loverUser] + 1) + ' to become Lecsy\'s King of the Day! *****'; cb.sendNotice(newLines(output), '', '', cb.settings.lovers_color, 'bold', ''); } //rotate displays of the lover of the day function loversRotator() { displayLovers(); cb.setTimeout(loversRotator, cb.settings.lovers_interval * 1000); } //display the next message in the rotation function showNextMessage() { var message = rotatingMessages[0]; cb.sendNotice(newLines(message), '', '', cb.settings.messages_color, 'bold', ''); rotatingMessages.push(rotatingMessages.shift()); } //rotate displays of messages function messageRotator() { showNextMessage(); cb.setTimeout(messageRotator, cb.settings.messages_interval * 1000); } //populate messages to be rotated from the settings page function parseRotatingMessages() { for (var i = 0; i < 20; i++) { var message = cb.settings['message_' + i]; if (message && message.length > 0) rotatingMessages.push(message); } } function startRotators() { if (cb.settings.lovers_interval && cb.settings.lovers_interval > 0) cb.setTimeout(loversRotator, cb.settings.lovers_delay * 1000); //starts the lovers rotator if (cb.settings.tip_menu_interval && cb.settings.tip_menu_interval > 0) cb.setTimeout(tipMenuRotator, cb.settings.tip_menu_delay * 1000); //starts the tip menu rotator if (cb.settings.messages_interval && cb.settings.messages_interval > 0 && rotatingMessages.length > 0) cb.setTimeout(messageRotator, cb.settings.messages_delay * 1000); //starts the tip menu rotator if (cb.settings.cc_interval && cb.settings.cc_interval > 0) cb.setTimeout(cumCounterRotator, cb.settings.cc_delay * 1000); //starts the cum counter rotator } /********** ------------ COMMANDS ------------ **********/ var cumCounter = 0; var commanders = []; function cmd(input, user) { if (arrayIndexOf(commanders, user) > -1 || user === cb.room_slug) { var msg = input.split(' '); switch (msg[0]) { case 'lex_note': var index = input.indexOf(' '); var note = input.substring(index).trim(); cb.sendNotice(newLines(note), '', '', cb.settings.lovers_color, 'bold'); break; case 'lex_cc': var num = Number(msg[1]); if (!isNaN(num)) { cumCounter = Math.floor(num); tellBoth('Cum Counter set to ' + num); } break; case 'lex_promote': promote(msg[1]); break; case 'lex_demote': demote(msg[1]); break; case 'lex_addteam': addLoverBoy(msg[1]); break; case 'lex_remteam': remLoverBoy(msg[1]); break; case 'lex_bm': var index = input.indexOf(' '); whisper(user, cb.room_slug, input.substring(index).trim()); break; } } } //adds a Lover Boy function addLoverBoy(user) { if (user && arrayIndexOf(loverBoys, user) === -1) { loverBoys.push(user); cb.sendNotice(newLines(user + ' joined Team Lecsy! :TEAMLEX'), '', '', cb.settings.highlight_color, 'bold'); } } //removes a Lover Boy function remLoverBoy(user) { var index = arrayIndexOf(loverBoys, user) if (user && index > -1) loverBoys.splice(index, 1); } //grants commander privileges to a user function promote(user) { if (arrayIndexOf(commanders, user) === -1) commanders.push(user); } //remove's a user's commander privileges function demote(user) { if (arrayIndexOf(commanders, user) > -1) commanders.splice(commanders.indexOf(user), 1); } function whisper(sender, recipient, message) { whisperNotice(sender, recipient, message); whisperNotice(sender, sender, message); } function whisperNotice(sender, recipient, message) { if (message && message.length > 0) { var output = '[' + sender.toUpperCase() + '] :: ' + message; cb.sendNotice(newLines(output), recipient, '#000000', 'FF0000', 'bold'); } } //adds the preset users to Commanders function parseCommanders() { if (cb.settings.commanders) commanders = cb.settings.commanders.replace(/\s/g, '').split(','); } /********** ------------ COMMUNICATION ------------ **********/ //send a message with the tip color function tipMessage(msg, user) { cb.sendNotice(newLines(msg), user, '#FB5858', '#FFFFFF', 'bold', ''); } //send a message with the room color function tellUser(msg, user) { cb.sendNotice(newLines(msg), user, '', cb.settings.entry_msg_color, 'bold', ''); } //send a message to the broadcaster function tellMe(msg) { cb.sendNotice(newLines(msg), cb.room_slug, '', cb.settings.entry_msg_color, 'bold', ''); } //send a message to mods function tellMods(msg) { cb.sendNotice(newLines(msg), '', '', cb.settings.entry_msg_color, 'bold', 'red'); } //send a message to broadcaster and mods function tellBoth(msg) { tellMe(msg); tellMods(msg); } /********** ------------ MISCELLANEOUS ------------ **********/ //make newlines more visible and readable function newLines(input) { return '\u25A0 ' + input.replace(new RegExp('\n', 'g'), '\n\u25A0 '); } //check if an array contains an instane of the object function arrayIndexOf(array, obj) { for (var i = 0; i < array.length; i++) { if (array[i] === obj) return i; } return -1; } /********** ------------ EXECUTE ------------ **********/ //starts the bot function init() { parseCommanders(); //adds the privileged users parseLoverBoys(); //adds the lover boys parseTipMenu(); //sets the tip menu parseTokenRewards(); //sets the special groups parseRotatingMessages(); //sets the rotating messges startRotators(); //starts all rotators } init(); //make it so!
© Copyright Chaturbate 2011- 2024. All Rights Reserved.