Bots Home
|
Create an App
Andy-BOT
Author:
2fitnessmadshere
Description
Source Code
Launch Bot
Current Users
Created by:
2fitnessmadshere
cb.settings_choices = function () { var output = []; var ins_index = 0; makeInstructions('[AJUSTES GENERALES] ---------------------- Las funciones mas basicas del bot.'); output.push({name: 'conversion', label: 'Mostrar las cantidades en dolares americanos al modelo cuando los tips sean recibidos', type: 'choice', choice1: 'Si', choice2: 'No', defaultValue: 'Si'}); output.push({name: 'tipTitles', label: 'Mostrar a los espectadores los tips como un titulo en el chat', type: 'choice', choice1: 'Si', choice2: 'No', defaultValue: 'Si'}); output.push({name: 'roomfgcolor', label: 'Color de texto aviso de la sala', type: 'str', defaultValue: '#000000', required: false}); output.push({name: 'roombgcolor', label: 'Color de fondo del aviso de la sala', type: 'str', defaultValue: '#FFFFFF', required: false}); output.push({name: 'mods', label: 'Moderador que puede acceder a los comandos del bot', type: 'str', defaultValue: 'codeanon', required: false}); makeInstructions('[MENU DE TIPS] ---------------------- El menu de tips puede aparecer en el chat en intervalos regulares. Usted puede especificar los valores, el formato y el color.'); output.push({name: 'tipMenu_obj', label: 'Valores', 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'}); output.push({name: 'tipMenu_interval', label: 'Segundos entre las apariciones del menu de tips (0 = inactivo)', type: 'int', defaultValue: 60, minvalue: 0}); output.push({name: 'tipMenu_format', label: 'Formato', type: 'choice', choice1: 'varias lineas', choice2: 'una linea', defaultValue: 'varias lineas'}); output.push({name: 'tipMenu_color', label: 'Color', type: 'str', required: false, defaultValue: '#880000'}); makeInstructions('[MARCADOR] ---------------------- El marcador aperece abajo del menu de tips. Contiene los cinco principales tippers. El usuario que mas ha propinado tendra una corona junto a su nombre, o usted puede elegir una imagen personalizada.'); output.push({name: 'lb_enabled', label: 'Activo', type: 'choice', choice1: 'Si', choice2: 'No', defaultValue: 'Si'}); output.push({name: 'lb_color', label: 'Color', type: 'str', defaultValue: '#000000', required: false}); output.push({name: 'lb_emote', label: 'Imagen personalizada', type: 'str', required: false}); makeInstructions('[GRACIAS AUTOMATICAS] ---------------------- Mostrar automaticamente una nota de agradecimiento cuando un usuario da una propina.'); output.push({name: 'thank_you_use', label: 'Activo', type: 'choice', choice1: 'Si', choice2: 'No', defaultValue: 'Si'}); output.push({name: 'thank_you_amt', label: 'Numero minimo para recibir un mensaje de agradecimiento', type: 'int', minValue: 1, defaultValue: 25}); output.push({name: 'thank_you_msg', label: 'Mensaje', type: 'str', defaultValue: 'Thank you, [user]!', required: false}); makeInstructions('[RESPUESTA AUTOMATICA] ---------------------- Mostrar automaticamente una respuesta cuando un usuario escribe una determinada palabra.'); output.push({name: 'wordnotice_0', label: 'Respuesta 01', type: 'str', required: false, defaultValue: 'pm, pms: PMs cost 5 tokens!'}); output.push({name: 'wordnotice_1', label: 'Respuesta 02', type: 'str', required: false}); output.push({name: 'wordnotice_2', label: 'Respuesta 03', type: 'str', required: false}); output.push({name: 'wordnotice_3', label: 'Respuesta 04', type: 'str', required: false}); output.push({name: 'wordnotice_4', label: 'Respuesta 05', type: 'str', required: false}); makeInstructions('[CENSURAR] -------------------- Censurar, restringir y ocultar automaticamente los mensajes de chat que no le gustan.'); output.push({name: 'block_for', label: 'A quien censurar', type: 'choice', choice1: 'Todos los usarios', choice2: 'Usuarios de gris', choice3: 'Nadie', defaultValue: 'Usuarios de gris'}); output.push({name: 'blocked', label: 'Palabras censuradas', type: 'str', required: false, defaultValue: 'bb,baby,babe,slut,whore,dick,penis,masturbate'}); output.push({name: 'block_type', label: 'Que hacer con las palabras bloqueadas', type: 'choice', choice1: 'censurar palabra', choice2: 'Ocultar todo el mensaje', defaultValue: 'Ocultar todo el mensaje'}); output.push({name: 'superblocked', label: '"Superblocked" palabras (siempre ocultas sin advertencia a quien las usa)', type: 'str', required: false}); output.push({name: 'sticky_keys', label: 'Censurar demasiadas letras repetidas', type: 'choice', choice1: 'Si', choice2: 'No', defaultValue: 'Si'}); output.push({name: 'capslock', label: 'Corregir automaticamente los mensajes en mayusculas', type: 'choice', choice1: 'Si', choice2: 'No', defaultValue: 'Si'}); output.push({name: 'block_grey_emotes', label: 'Evitar que los usuarios grises publiquen imagenes', type: 'choice', choice1: 'Si', choice2: 'No', defaultValue: 'Si'}); makeInstructions('[AVISOS AUTOMATICOS] -------------------- Estos mensajes aparecen automaticamente en el chat a intervalos regulares.'); output.push({name: 'message_0', label: 'Mensaje 01', required: false, type: 'str'}); output.push({name: 'message_1', label: 'Mensaje 02', required: false, type: 'str'}); output.push({name: 'message_2', label: 'Mensaje 03', required: false, type: 'str'}); output.push({name: 'message_2', label: 'Mensaje 03', required: false, type: 'str'}); output.push({name: 'message_3', label: 'Mensaje 04', required: false, type: 'str'}); output.push({name: 'message_4', label: 'Mensaje 05', required: false, type: 'str'}); output.push({name: 'message_5', label: 'Mensaje 06', required: false, type: 'str'}); output.push({name: 'message_6', label: 'Mensaje 07', required: false, type: 'str'}); output.push({name: 'message_7', label: 'Mensaje 08', required: false, type: 'str'}); output.push({name: 'message_8', label: 'Mensaje 09', required: false, type: 'str'}); output.push({name: 'message_9', label: 'Mensaje 10', required: false, type: 'str'}); output.push({name: 'message_10', label: 'Mensaje 11', required: false, type: 'str'}); output.push({name: 'message_11', label: 'Mensaje 12', required: false, type: 'str'}); output.push({name: 'message_12', label: 'Mensaje 13', required: false, type: 'str'}); output.push({name: 'message_13', label: 'Mensaje 14', required: false, type: 'str'}); output.push({name: 'message_14', label: 'Mensaje 15', required: false, type: 'str'}); output.push({name: 'messages_interval', label: 'Segundos entre las apariciones de los mensajes (0 = inactivo)', type: 'int', defaultValue: 60, minvalue: 0}); output.push({name: 'messages_delay', label: 'Segundos antes de que los mensajes comiencen a aparecer', type: 'int', defaultValue: 30, minvalue: 0}); output.push({name: 'messages_color', label: 'Color de mensajes', type: 'str', defaultValue: '#000000', required: false}); makeInstructions('[REGLAS DE LA SALA] -------------------- Estas reglas aparecen en su totalidad en el chat a intervalos regulares.'); output.push({name: 'rule0', label: 'Regla 1', type: 'str', required: false}); output.push({name: 'rule1', label: 'Regla 2', type: 'str', required: false}); output.push({name: 'rule2', label: 'Regla 3', type: 'str', required: false}); output.push({name: 'rule3', label: 'Regla 4', type: 'str', required: false}); output.push({name: 'rule4', label: 'Regla 5', type: 'str', required: false}); output.push({name: 'rule5', label: 'Regla 6', type: 'str', required: false}); output.push({name: 'rule6', label: 'Regla 7', type: 'str', required: false}); output.push({name: 'rules_interval', label: 'Segundos entre las apariciones de las reglas (0 = inactivo)', type: 'int', defaultValue: 180}); output.push({name: 'rules_delay', label: 'Segundos antes de que las reglas comiencen a aparecer', type: 'int', defaultValue: 60}); output.push({name: 'rules_color', label: 'Color de reglas', type: 'str', defaultValue: '#000000', required: false}); output.push({name: 'rules_enter', label: 'Enviar automaticamente una lista de reglas a los usuarios cuando entran en la sala', type: 'choice', choice1: 'Si', choice2: 'No'}); function makeInstructions(text) { output.push({name: 'instructions_' + ins_index, label: text, type: 'choice', choice1: '', required: false}); ins_index++; } return output; }(); //tips var tipTotal = 0; var tipLedger = {}; var tipMenu_obj; var tipMenuOn = true; var condensed = function (input) { if (input) return input === 'una linea'; }(cb.settings.tipMenu_format) //leaderboard var leaderBoard = function () { var arr = []; arr.color = cb.settings.lb_color; return arr; }(); var emote = function () { if (cb.settings.lb_emote && cb.settings.lb_emote.trim().length > 0) { return cb.settings.lb_emote.trim(); } else { return '\u265B'; } }(); //messages var reactives = {}; var blocked = []; blocked.name = 'blocked'; var superBlocked = []; superBlocked.name = 'super-blocked'; var blockType = cb.settings.block_type; //other var modList = []; /********** ------------ EVENT HANDLERS ------------ **********/ //when a new tip comes in, increment everything cb.onTip(function (tip) { var amount = tip['amount']; var user = tip['from_user']; addTip(user, amount); thankYou(user, amount); checkTips(user, amount); checkLeaderboard(user); }); //when a new message comes in, either process a command or change the display cb.onMessage(function (msg) { if (msg['m'].charAt(0) === '/') { msg['X-Spam'] = true; var user = msg['user']; if (user === cb.room_slug || cbjs.arrayContains(modList, user)) { cmd(msg['m'].substring(1), user); } } else { censor(msg); displayKing(msg); displayTips(msg); showReactions(msg); } return msg; }); /********** ------------ CENSORING ------------ **********/ //check if the messsage should be processed through the filter function shouldBeCensored(msg) { if (cb.settings.block_for === 'Todos los usarios') { return true; } else if (cb.settings.block_for === 'Usuarios de gris' && !hasImmunity(msg)) { return true; } return false; } //checks user for immunity to stickyKeys and Emoticons... function hasImmunity(msg) { return (msg['user'] === cb.room_slug || msg['is_mod'] || msg['has_tokens'] || msg['tipped_recently'] || msg['tipped_alot_recently'] || msg['tipped_tons_recently']); } //show automatic reactions to messages function showReactions(msg) { var text = msg['m'].toLowerCase(); for (var key in reactives) { var exp = RegExp('\\b' + key + '\\b'); if (exp.test(text)) tellUser(reactives[key]); } } //censor the message function censor(msg) { var warningMessage; var text = msg['m']; if (shouldBeCensored(msg) && containsBlockedWord(text)) { if (blockType === 'Ocultar todo el mensaje') { warningMessage = 'Your message has been removed due to the use of innapropriate word(s).' msg = processCensor(msg, warningMessage); } else { msg['m'] = censorBlockedWords(text); } } else if (!hasImmunity(msg)) { if (hasStickyKeys(text) && cb.settings.sticky_keys === 'Si') { warningMessage = 'Your message has been removed due to constant repitition of the same letter (Sticky Keys).' msg = processCensor(msg, warningMessage); } else if (hasEmoticon(text) && cb.settings.block_grey_emotes === 'Si') { warningMessage = 'I\'m sorry. grey users are not allowed to post emoticons.' msg = processCensor(msg, warningMessage); } else if (hasCapslock(text) && cb.settings.capslock === 'Si') { warningMessage = 'We\'ve detected that you\'re using too many capital letters. Here, let me fix that for you.'; tellUser(warningMessage, msg['user']); msg['m'] = String(msg['m']).toLowerCase(); } else if (containsSuperBlockedWord(text)) { msg['X-Spam'] = true; } } } //added new method rather than duplicate code. function processCensor(msg, warningMessage) { tellUser(warningMessage, msg['user']); msg['X-Spam'] = true; msg['m'] = '*******'; } //check if text contains sticky keys function hasStickyKeys(input) { str = input.replace(/\s+/g, '_'); return /(\S)(\1{2,})/g.test(str); } //check if text contains an emoticon function hasEmoticon(input) { var exp = /(^|\s):\w{3,}($|\s)/; if (exp.test(input)) return true; return false; } //check if text contains capslock function hasCapslock(input) { str = input.replace(/\s+/g, '_'); return /([A-Z]{3,})/g.test(str); } //censor only blocked words function censorBlockedWords(text) { var sanitized = text.replace(/\s+/g, ' '); var words = sanitized.split(' '); var censored = sanitized; for (var i = 0; i < blocked.length; i++) { for (var j = 0; j < words.length; j++) { var x = remPunk(words[j].toLowerCase()); if (x === blocked[i]) { words[j] = '*******'; } } } return words.join(' '); } //remove punctuation from a string function remPunk(text) { return text.replace(/[^A-Za-z0-9]/g, ''); } //see if a string contains a blocked word function containsBlockedWord(input) { var text = input.replace(/\s+/g, ' ').toLowerCase(); for (var i = 0; i < blocked.length; i++) { var exp = RegExp('\\b' + blocked[i] + '\\b'); if (exp.test(text)) return true; } return false; } function containsSuperBlockedWord(text) { var sanitized = text.replace(/[^a-zA-Z\d]/g, '').toLowerCase(); for (var i = 0; i < superBlocked.length; i++) { if (sanitized.indexOf(superBlocked[i]) > -1) { return true; } } return false; } /********** ------------ TIP DISPLAY ------------ **********/ //add the number of tips to the beginning of a user's message function displayTips(msg) { if (cb.settings.tipTitles === 'Si') { var user = msg['user']; if (tipLedger[user]) msg['m'] = '|' + tipLedger[user] + '| ' + msg['m']; } return msg; } //increment the user's entry in tipLedger function addTip(user, number) { tipTotal += number; if (cb.settings.conversion === 'Si') acct_notice(money(number) + ' recibido (' + money(tipTotal) + ' durante este show)'); tipLedger[user] ? tipLedger[user] += number : tipLedger[user] = number; } function thankYou(user, number) { if (cb.settings.thank_you_use === 'Si') { if (number >= cb.settings.thank_you_amt && cb.settings.thank_you_msg && cb.settings.thank_you_msg.trim().length > 0) { var output = cb.settings.thank_you_msg.replace(/\[user\]/g, user); tellUser(output, cb.settings.roomfgcolor); } } } function money(num) { if (!isNaN(num)) { var dollars = Math.ceil(num * 5) / 100; return '$' + parseFloat(Math.round(dollars * 100) / 100).toFixed(2); } return NaN; } //display a message if a user has tipped for something on the menu function checkTips(user, amount) { if (tipMenuOn && tipMenu_obj[amount]) { tellUser(user + ' tipped for ' + tipMenu_obj[amount] + '!', '', cb.settings.tipMenu_color); } } //start a rotating tip menu function tipRotator() { if (cb.settings.tipMenu_interval > 0) { if (tipMenuOn) displayTipMenu(); if (cb.settings.lb_enabled === 'Si') showLeaderboard(); cb.setTimeout(tipRotator, cb.settings.tipMenu_interval * 1000); } } /********** ------------ LEADERBOARD ------------ **********/ function checkLeaderboard(user) { if (leaderBoard.length === 0) { leaderBoard.push(user); } else { for (var i = 0; i < 5; i++) { var pos = leaderBoard[i]; if (!pos) { if (leaderBoard.indexOf(user) === -1) leaderBoard.push(user); break; } else if (tipLedger[user] > tipLedger[pos]) { if (leaderBoard.indexOf(user) === -1) leaderBoard.push(user); leaderBoard.sort(function (a,b) {return tipLedger[b] - tipLedger[a];}); while (leaderBoard.length > 5) leaderBoard.pop(); break; } } } } function showLeaderboard() { var title = '\u25CF \u25CF LEADERBOARD \u25CF \u25CF \u25CF '; var output = ''; if (leaderBoard.length > 0) { for (var i = 0; i < leaderBoard.length && i < 5; i++) { output += '\n' + (i + 1) + '. ' + leaderBoard[i] + ' |' + tipLedger[leaderBoard[i]] + '|'; if (i === 0) output += ' \u265B'; } output = output.trim(); } else { output = 'No tips yet!' } cb.sendNotice(newLines(title), '', cb.settings.tipMenu_color, '#FFFFFF', 'bold', ''); cb.sendNotice(newLines(output), '', '#FFFFFF', cb.settings.tipMenu_color, 'bold', ''); } function displayKing(msg) { if (leaderBoard[0] && msg.user === leaderBoard[0]) msg.m = emote + ' ' + msg.m; } /********** ------------ ROTATORS ------------ **********/ var rotatingMessages = []; //rotate displays of messages function messageRotator() { var message = rotatingMessages[0]; cb.sendNotice(newLines(message), '', '', cb.settings.messages_color, 'bold', ''); rotatingMessages.push(rotatingMessages.shift()); cb.setTimeout(messageRotator, cb.settings.messages_interval * 1000); } function rulesRotator() { showRules(); cb.setTimeout(rulesRotator, cb.settings.rules_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.messages_interval && cb.settings.messages_interval > 0 && rotatingMessages.length > 0) cb.setTimeout(messageRotator, cb.settings.messages_delay * 1000); if (cb.settings.rules_interval && cb.settings.rules_interval > 0 && rules && rules.length > 0) cb.setTimeout(rulesRotator, cb.settings.rules_delay * 1000); if (cb.settings.tipMenu_interval && cb.settings.tipMenu_interval) cb.setTimeout(tipRotator, 10000); } /********** ------------ RULES ------------ **********/ var rules = function () { var output = '====== ROOM RULES ======'; for (var i = 0; i < 7; i++) { var setting = cb.settings['rule' + i]; if (setting && setting.trim().length > 0) { output += '\n' + setting.trim(); } } output += '\n====================='; if (output !== '====== ROOM RULES ======\n=====================') return newLines(output); }(); function showRules(user) { cb.sendNotice(rules, user, '', cb.settings.rules_color, 'bold', ''); } cb.onEnter(function (user) { if (rules && cb.settings.rules_entrance === 'Si') showRules(user); }); /********** ------------ GENERAL ------------ **********/ //process superuser commands function cmd(input, user) { var s_msg = sanitize(input).split(' '); var msg = input.split(' '); switch (msg[0]) { case 'andy_total': var text = money(tipTotal) + ' (' + tipTotal + ' fichas) recibido durante este show.'; cb.sendNotice(text, user, '#FFFF00', '#000000', 'bold', ''); break; case 'andy_savetips': tellBoth('SAVE THE JSON STRING BELOW\n' + JSON.stringify(tipLedger)); break; case 'andy_saveblocked': tellBoth('SAVE THE COMMA-SEPARATED STRING BELOW\n' + blocked.toString()); break; case 'andy_help': showHelp(user); break; case 'andy_block': block(msg[1], blocked); break; case 'andy_superblock': block(msg[1], superBlocked); break; case 'andy_savesuperblocked': //Candehman tellBoth('SAVE THE COMMA-SEPARATED STRING BELOW\n' + superBlocked.toString()); break; case 'andy_allow': allow(msg[1], blocked); break; case 'andy_superallow': allow(msg[1], superBlocked); break; case 'andy_bm': if (msg[1]) broadcasterMessage(user, paramString(input)); break; case 'andy_cn': tellUser(paramString(input)); break; case 'andy_subj': if (msg[1]) cb.changeRoomSubject(paramString(input)); break; case 'andy_tipson': tipMenuOn = true; tellBoth('Tip menu active.'); break; case 'andy_tipsoff': tipMenuOn = false; tellBoth('Tip menu inactive.'); break; case 'andy#': if (msg[1]) evaluate(input, user); break; } } //execute javascript in a try/catch block function evaluate(input, user) { cb.setTimeout(function () { var command = paramString(input); try { eval(command); } catch (e) { tellUser('JS-ERR :: ' + e.message, user, '#CC0000'); } }, 150); } //find all arguments of a command function paramString(input, stringToIndex) { if (input) { if (!stringToIndex) return input.substring(input.indexOf(' ') + 1).trim(); return input.substring(input.indexOf(stringToIndex) + stringToIndex.length + 1).trim(); } return 'ERR'; } //send a message to the broadcaster function broadcasterMessage(user, message) { specialUserNotice('[' + user.toUpperCase() + '] :: "' + message + '"', cb.room_slug); specialUserNotice('Message sent to broadcaster.', user); } //block a word function block(word, array) { if (word && array) { word = word.replace(',', '').toLowerCase(); if (word.length > 0) { array.push(word); tellBoth('The word "' + word + '" has been ' + array.name + '.'); } } } //unblock a word function allow(word, array) { if (word && array) { var index = arrayIndexOf(array, word.toLowerCase()); if (index > -1) { array.splice(index, 1); tellBoth('The word "' + word + '" is no longer ' + array.name + '.'); } } } //sanitize a string for consistency function sanitize(input) { if (input) { var s = input.replace(/\s/g, ''); s = s.replace('}{', '} {'); s = s.replace('\s+', ' '); s = s.replace(':', ': '); return s; } return void 0; } /********** ------------ COMMUNICATION ------------ **********/ //send a message to the user with special formatting function specialUserNotice(msg, username) { if (msg && username) cb.sendNotice(newLines(msg), username, '#000000', '#FFFFFF', 'bold', ''); } function acct_notice(text) { cb.sendNotice(text, cb.room_slug, '#FFFF00', '#000000', 'bold', ''); for (var i = 0; i < modList.length; i++) { cb.sendNotice(text, modList[i], '#FFFF00', '#000000', 'bold', ''); } } //send a message to the user function tellUser(msg, user, color) { cb.sendNotice(newLines(msg), user, '', color, 'bold', ''); } //send a message to the broadcaster function tellMe(msg) { cb.sendNotice(newLines(msg), cb.room_slug, cb.settings.roombgcolor, cb.settings.roomfgcolor, 'bold', ''); } //send a message to mods function tellMods(msg) { cb.sendNotice(newLines(msg), '', cb.settings.roombgcolor, cb.settings.roomfgcolor, 'bold', 'red'); } //send a message to broadcaster and mods function tellBoth(msg) { tellMe(msg); tellMods(msg); } //show the help menu to mods and broadcaster function showHelp(user) { var output = '---- COMMANDS FOR G-BOT ---- \ \n/andy_help :: show this menu again \ \n/andy_total :: show total tips received \ \n/andy_savetips :: prints a JSON string of the current tips \ \n/andy_block [word] :: adds a word to the list of blocked words \ \n/andy_superblock [word] :: adds a word to the list of super blocked words \ \n/andy_superallow [word] :: removes a word from the list of super blocked words \ \n/andy_allow [word] :: removes a word from the list of blocked words \ \n/andy_cn [message] :: sends a notice to the entire room \ \n/andy_bm [message] :: sends a notice to the broadcaster \ \n/andy_subj [subject] :: changes the room subject \ \n/andy_tipsoff :: deactivates the tip menu \ \n/andy_tipson :: reactivates the tip menu \ \n/andy# [JavaScript] :: runs a JS expression (only use in emergencies)'; tellUser(output, user); } //show the tip menu function displayTipMenu(user) { var output = ''; if (condensed) { for (var key in tipMenu_obj) output += '\u25A0 ' + key + ' [' + tipMenu_obj[key] + '] '; tellUser(output.substring(1).trim(), user, cb.settings.tipMenu_color); } else { var title = '\u25CF \u25CF TIP MENU \u25CF \u25CF \u25CF '; for (var key in tipMenu_obj) output += '' + key + ' tokens [' + tipMenu_obj[key] + ']\n'; output = output.trim(); output += '\n=============='; cb.sendNotice(newLines(title), '', cb.settings.tipMenu_color, '#FFFFFF', 'bold', ''); tellUser(output, user, cb.settings.tipMenu_color); } } /********** ------------ MISCELLANEOUS ------------ **********/ //add to all newline characters in a string for readability 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; } /********** ------------ INITIALIZATION ------------ **********/ //run all initialization functions function init() { populateModList(); populateTipMenus(); parseTips(cb.settings.prevtips); parseBlocked(false, cb.settings.blocked); parseBlocked(true, cb.settings.superblocked); parseRotatingMessages(); //sets the rotating messges parseReactive(); showHelp(cb.room_slug); startRotators(); } //populates the mod list with the pre-defined users function populateModList() { var mods = String(cb.settings.mods).split(','); mods.forEach(function (entry) { entry = entry.trim(); modList.push(String(entry)); }); } //creates a data-based tip menu from the settings function parseTipMenu(menu) { var obj = {}; if (menu) { var menuArray = menu.split(','); menuArray.forEach(function (item) { cb.log(item); var itemArray = item.split(':'); var key = itemArray[0]; var value = itemArray[1]; if (key && value) obj[key.trim()] = value.trim(); }); } return obj; } //populates all data for tip menus function populateTipMenus() { tipMenu_obj = parseTipMenu(cb.settings.tipMenu_obj); } //import the previous data to tipLedger function parseTips(input) { input = sanitize(input); if (input) tipLedger = JSON.parse(input); else cb.log('No tips to parse.'); } //parse the blocked words function parseBlocked(isSuperBlocked, input) { if (input) { var s = input.replace(/\s/g, '').replace(/,{2,}/g, ',').toLowerCase(); var arr = s.split(','); if (isSuperBlocked) { superBlocked = arr; superBlocked.name = 'super-blocked'; } else { blocked = arr; blocked.name = 'blocked'; } } } //parse reactive notices function parseReactive() { for (var key in cb.settings) { var valid = key.slice(0, 11) === 'wordnotice_' && cb.settings[key].trim().length > 0 && cb.settings[key].indexOf(':') > 0; if (valid) { var item = cb.settings[key]; var index = item.indexOf(':'); var wordStr = item.substring(0, index).trim(); var words = wordStr.replace(/\s/g, '').split(','); var notice = item.substring(index + 1).trim(); for (var i = 0; i < words.length; i++) { var word = words[i].toLowerCase(); reactives[word] = notice; } } } } /********** ------------ EXECUTE ------------ **********/ init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.