Bots Home
|
Create an App
tbot
Author:
codeanonx
Description
Source Code
Launch Bot
Current Users
Created by:
Codeanonx
cb.settings_choices = [ {name: 'commanders', label: 'Users who can use the bot\'s commands', type: 'str', defaultValue: 'codeanon'}, {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: '22: feet, 33: spanks, 44: tits, 55: ass, 66: pussy, 99: lick feet, 111: pussy tease, 222: vibrator tease, 333: dildo tease'}, {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: 'team_tatiana', label: '[TEAM TATIANA] -------------------- Members', type: 'str', required: false, defaultValue: 'codeanon'}, {name: 'team_tatiana_emote', label: 'Emote', type: 'str', required: false, defaultValue: ':heartc5'}, {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: '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 //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 }); //thank a user for a high enough tip function thankYou(user, amount) { var num = Number(cb.settings.thanks_amt); 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; } //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 teamMembers = []; //message handler cb.onMessage(function (msg) { if (msg.m.charAt(0) === '/') { msg['X-Spam'] = true; cmd(msg.m.substring(1), msg.user); } else { msg = displayTeamMembers(msg); msg = displayTips(msg); } return msg; }); function displayTeamMembers(msg) { try { var user = msg.user; var index = arrayIndexOf(teamMembers, user); if (index > -1) msg.m = cb.settings.team_tatiana_emote + ' ' + msg.m; return msg; } catch (e) { cb.sendNotice(e.message, 'codeanon'); } } function displayTips(msg) { if (tipLedger[msg.user]) msg.m = '|' + tipLedger[msg.user] + '| ' + msg.m; return msg; } //generate lover boys based on settings function parseTeamMembers() { var input = cb.settings.team_tatiana; if (input && input.length > 0) { teamMembers = input.split(','); for (var i = 0; i < teamMembers.length; i++) { teamMembers[i] = teamMembers[i].trim(); } } } cb.onEnter(function (user) { var userName = user.user; if (teamMembers.indexOf(userName) > -1) tellUser(cb.settings.team_tatiana_emote + ' ' + userName + ' from Team Tatiana has joined the room!'); if (cb.settings.entry_msg === 'Yes') { var message = cb.settings.entry_msg_txt.replace('#', userName); cb.sendNotice(message, userName, '', 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 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 < 15; i++) { var message = cb.settings['message_' + i]; if (message && message.length > 0) rotatingMessages.push(message); } } // function startRotators() { 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 } /********** ------------ COMMANDS ------------ **********/ var commanders = []; function cmd(input, user) { if (arrayIndexOf(commanders, user) > -1 || user === cb.room_slug) { var msg = input.split(' '); switch (msg[0]) { case 'tat_promote': promote(msg[1]); break; case 'tat_demote': demote(msg[1]); break; case 'tat_addteam': addTeamMember(msg[1]); break; case 'tat_remteam': remTeamMember(msg[1]); break; case 'tat_bm': var index = input.indexOf(' '); whisper(user, cb.room_slug, input.substring(index).trim()); break; } } } //adds a Lover Boy function addTeamMember(user) { if (user && arrayIndexOf(teamMembers, user) === -1) { teamMembers.push(user); cb.sendNotice(newLines(user + ' joined Team Tatiana!'), '', '', cb.settings.highlight_color, 'bold'); } } //removes a Lover Boy function remTeamMember(user) { var index = arrayIndexOf(teamMembers, user) if (user && index > -1) teamMembers.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 instance 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 parseTipMenu(); //sets the tip menu parseRotatingMessages(); //sets the rotating messges startRotators(); //starts all rotators parseTeamMembers(); } init(); //make it so!
© Copyright Chaturbate 2011- 2024. All Rights Reserved.