Apps Home
|
Create an App
Asistente lunanoixx
Author:
lunanoixx
Description
Source Code
Launch App
Current Users
Created by:
Lunanoixx
/* * Asistente de Sala — app para Chaturbate (API clásica de apps: cb.*) * * Qué hace solo, sin tocar el teclado: * - Agradece cada propina y anuncia cuando alguien pide un ítem del menú. * - Agrega el tip menu al desplegable de propinas (los espectadores eligen con un clic). * - Lleva las metas en cadena, actualiza el título de la sala y el panel. * - Invita a privado (mensaje solo para esa persona) a quien ya dio varias propinas. * - Responde a quien pregunta por privado o spy con precio y cómo pedirlo. * - Saluda a cada persona que entra con el menú y la meta (una vez por sesión). * - Rota mensajes cada X minutos: menú, meta, privado/spy, fan club, links. * * Todos los mensajes salen como avisos del asistente, no como si los escribiera ella. * Comandos opcionales (solo broadcaster y mods): /menu /meta /siguiente /pvt */ /* ------------------------------------------------------------ ajustes */ var MENU_SLOTS = 10; cb.settings_choices = [ { name: 'lang', type: 'choice', label: 'Idioma de los mensajes / Message language', choice1: 'English', choice2: 'Español', choice3: 'Both / Ambos', defaultValue: 'Both / Ambos' }, { name: 'goals', type: 'str', minLength: 0, maxLength: 400, required: false, label: 'Metas en cadena: tokens:nombre | tokens:nombre (ej: 500:Dance | 800:Oil show)', defaultValue: '500:Goal show 1 | 800:Goal show 2 | 1200:Goal show 3' }, { name: 'tags', type: 'str', minLength: 0, maxLength: 200, required: false, label: 'Hashtags para el título (ej: #latina #new #lovense)', defaultValue: '' }, { name: 'pvt_price', type: 'int', minValue: 6, maxValue: 480, defaultValue: 60, label: 'Precio privado (tk/min)' }, { name: 'spy_price', type: 'int', minValue: 0, maxValue: 480, defaultValue: 30, label: 'Precio spy (tk/min, 0 = sin spy)' }, { name: 'invite_tk', type: 'int', minValue: 1, maxValue: 100000, defaultValue: 150, label: 'Invitar a privado cuando alguien suma estos tokens' }, { name: 'invite_tips', type: 'int', minValue: 1, maxValue: 100, defaultValue: 3, label: '…o cuando suma esta cantidad de propinas' }, { name: 'big_tip', type: 'int', minValue: 1, maxValue: 100000, defaultValue: 100, label: 'Propina grande desde (tk)' }, { name: 'fanclub', type: 'str', minLength: 0, maxLength: 250, required: false, label: 'Mensaje del fan club', defaultValue: 'Join my Fan Club for exclusive content and cheaper spy!' }, { name: 'links', type: 'str', minLength: 0, maxLength: 250, required: false, label: 'Links (redes / otras páginas)', defaultValue: '' }, { name: 'rotate_min', type: 'int', minValue: 2, maxValue: 60, defaultValue: 5, label: 'Rotar mensajes cada (minutos)' }, { name: 'welcome', type: 'choice', label: 'Saludar a quien entra', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' } ]; for (var s = 1; s <= MENU_SLOTS; s++) { cb.settings_choices.push({ name: 'menu' + s, type: 'str', minLength: 0, maxLength: 60, required: false, label: 'Tip menu ' + s + ' (ej: Dance:44)', defaultValue: '' }); } /* ------------------------------------------------------------ estado */ var menu = []; // {name, tk} var goals = []; // {tk, name} var goalIdx = 0; var goalProgress = 0; var totals = {}; // user -> {tk, n, invitedAt} var welcomed = {}; var answered = {}; // `${user}:${tipo}` -> ts var rotation = 0; var C = { gold: '#FFF4CC', goldInk: '#5A4300', blue: '#E3F0FF', blueInk: '#0B3A6E', green: '#DFF7E8', greenInk: '#0F5130' }; /* ------------------------------------------------------------ textos */ function L(en, es) { var lang = cb.settings.lang || 'Both / Ambos'; if (lang === 'English') return en; if (lang === 'Español') return es; return en + ' / ' + es; } function parseSettings() { menu = []; for (var i = 1; i <= MENU_SLOTS; i++) { var raw = (cb.settings['menu' + i] || '').trim(); var m = raw.match(/^(.+?)\s*[:\-=]\s*(\d+)$/); if (m) menu.push({ name: m[1].trim(), tk: parseInt(m[2], 10) }); } goals = []; (cb.settings.goals || '').split('|').forEach(function (part) { var g = part.trim().match(/^(\d+)\s*:\s*(.+)$/); if (g) goals.push({ tk: parseInt(g[1], 10), name: g[2].trim() }); }); } function menuText() { if (!menu.length) return ''; return 'TIP MENU: ' + menu.map(function (m) { return m.name + ' (' + m.tk + ')'; }).join(' | '); } function goal() { return goals.length ? goals[goalIdx % goals.length] : null; } function goalText() { var g = goal(); if (!g) return ''; var left = Math.max(0, g.tk - goalProgress); return L('GOAL: ' + g.name + ' - ' + left + ' tk left', 'META: ' + g.name + ' - faltan ' + left + ' tk'); } function pvtText() { var t = L('Private shows open: ' + cb.settings.pvt_price + ' tk/min (click "Private Show")', 'Privados abiertos: ' + cb.settings.pvt_price + ' tk/min (botón "Private Show")'); if (cb.settings.spy_price > 0) { t += '. ' + L('Spy while I\'m in private: ' + cb.settings.spy_price + ' tk/min', 'Spy cuando estoy en privado: ' + cb.settings.spy_price + ' tk/min'); } return t; } /* ------------------------------------------------------------ helpers */ function notice(text, to, bg, fg, weight) { if (!text) return; cb.sendNotice(text, to || '', bg || '', fg || '', weight || 'normal'); } function updateSubject() { var g = goal(); var subj = g ? goalText() : L('Welcome!', '¡Bienvenidos!'); if (cb.settings.tags) subj += ' ' + cb.settings.tags; cb.changeRoomSubject(subj.substring(0, 250)); } function addGoal(tk) { var g = goal(); if (!g) return; goalProgress += tk; if (goalProgress >= g.tk) { notice(L('GOAL REACHED: ' + g.name + '! Thank you all!', '¡META CUMPLIDA: ' + g.name + '! ¡Gracias a todos!'), '', C.green, C.greenInk, 'bolder'); goalProgress -= g.tk; goalIdx++; var next = goal(); if (next) { var nx = next.name + ' (' + next.tk + ' tk)'; notice(L('Next goal: ' + nx, 'Próxima meta: ' + nx), '', C.green, C.greenInk, 'bold'); } } updateSubject(); cb.drawPanel(); } function now() { return new Date().getTime(); } function once(key, minutes) { var t = answered[key]; if (t && now() - t < minutes * 60000) return false; answered[key] = now(); return true; } /* ------------------------------------------------------------ eventos */ cb.onTip(function (tip) { var u = tip.from_user; var tk = tip.amount; var st = totals[u] || (totals[u] = { tk: 0, n: 0, invitedAt: 0 }); st.tk += tk; st.n += 1; var item = null; for (var i = 0; i < menu.length; i++) if (menu[i].tk === tk) { item = menu[i]; break; } if (item) { notice(L(u + ' tipped for: ' + item.name + '!', u + ' pidió: ' + item.name + '!'), '', C.gold, C.goldInk, 'bold'); } else if (tk >= cb.settings.big_tip) { notice(L('HUGE thanks ' + u + ' for ' + tk + ' tokens!', '¡GRACIAS ' + u + ' por ' + tk + ' tokens!'), '', C.gold, C.goldInk, 'bolder'); } else { notice(L('Thank you ' + u + '!', '¡Gracias ' + u + '!'), '', '', '', 'normal'); } var shouldInvite = (st.tk >= cb.settings.invite_tk || st.n >= cb.settings.invite_tips) && (now() - st.invitedAt > 15 * 60000); if (shouldInvite) { st.invitedAt = now(); notice(L('You\'re one of my favorite tippers tonight. Want me all to yourself? Private: ' + cb.settings.pvt_price + ' tk/min, click "Private Show".', 'Sos de mis favoritos de hoy. ¿Me querés solo para vos? Privado: ' + cb.settings.pvt_price + ' tk/min, botón "Private Show".'), u, C.blue, C.blueInk, 'bold'); } addGoal(tk); }); cb.onEnter(function (user) { var u = user.user; if (cb.settings.welcome !== 'Yes' || welcomed[u]) return; welcomed[u] = true; var lines = [L('Welcome ' + u + '!', '¡Bienvenido ' + u + '!')]; if (user.in_fanclub) lines[0] = L('Welcome back, Fan Club member ' + u + '!', '¡Bienvenido de nuevo, ' + u + ' del fan club!'); if (goal()) lines.push(goalText()); if (menu.length) lines.push(menuText()); notice(lines.join('\n'), u, C.blue, C.blueInk, 'normal'); }); var PVT_WORDS = /\b(pvt|private|privado|privat|priv|1on1)\b/i; var SPY_WORDS = /\b(spy|espiar)\b/i; cb.onMessage(function (msg) { var u = msg.user; var text = (msg.m || '').trim(); var isStaff = (u === cb.room_slug) || msg.is_mod; if (isStaff && text.charAt(0) === '/') { var cmd = text.split(' ')[0].toLowerCase(); if (cmd === '/menu') notice(menuText(), '', C.gold, C.goldInk, 'bold'); else if (cmd === '/meta') notice(goalText(), '', C.green, C.greenInk, 'bold'); else if (cmd === '/siguiente') { goalIdx++; goalProgress = 0; updateSubject(); cb.drawPanel(); notice(goalText(), '', C.green, C.greenInk, 'bold'); } else if (cmd === '/pvt') notice(pvtText(), '', C.blue, C.blueInk, 'bold'); else return msg; msg['X-Spam'] = true; // oculta el comando del chat return msg; } if (!isStaff && PVT_WORDS.test(text) && once(u + ':pvt', 5)) { notice(L('Private: ' + cb.settings.pvt_price + ' tk/min. Click "Private Show" under the video to request it.', 'Privado: ' + cb.settings.pvt_price + ' tk/min. Pedilo con el botón "Private Show" debajo del video.'), u, C.blue, C.blueInk, 'bold'); } else if (!isStaff && SPY_WORDS.test(text) && cb.settings.spy_price > 0 && once(u + ':spy', 5)) { notice(L('When I\'m in a private show you can spy for ' + cb.settings.spy_price + ' tk/min.', 'Cuando estoy en privado podés espiar por ' + cb.settings.spy_price + ' tk/min.'), u, C.blue, C.blueInk, 'normal'); } return msg; }); cb.tipOptions(function () { if (!menu.length) return null; return { label: L('Choose from my menu:', 'Elegí del menú:'), options: menu.map(function (m) { return { label: m.name + ' (' + m.tk + ' tk)' }; }) }; }); cb.onDrawPanel(function () { var g = goal(); var top = null; for (var u in totals) if (!top || totals[u].tk > totals[top].tk) top = u; return { template: '3_rows_of_labels', row1_label: L('Goal', 'Meta') + ':', row1_value: g ? g.name : '-', row2_label: L('Progress', 'Progreso') + ':', row2_value: g ? (goalProgress + ' / ' + g.tk) : '-', row3_label: L('Top tipper', 'Top') + ':', row3_value: top ? (top + ' (' + totals[top].tk + ')') : '-' }; }); /* ------------------------------------------------------------ rotación */ function rotate() { var pool = []; if (menu.length) pool.push(function () { notice(menuText(), '', C.gold, C.goldInk, 'bold'); }); if (goal()) pool.push(function () { notice(goalText(), '', C.green, C.greenInk, 'bold'); }); pool.push(function () { notice(pvtText(), '', C.blue, C.blueInk, 'normal'); }); if (cb.settings.fanclub) pool.push(function () { notice(cb.settings.fanclub, '', C.blue, C.blueInk, 'normal'); }); if (cb.settings.links) pool.push(function () { notice(cb.settings.links, '', '', '', 'normal'); }); if (pool.length) pool[rotation++ % pool.length](); cb.setTimeout(rotate, cb.settings.rotate_min * 60000); } /* ------------------------------------------------------------ inicio */ parseSettings(); updateSubject(); cb.drawPanel(); notice(L('Room assistant is on.', 'Asistente de sala activado.'), cb.room_slug, '', '', 'normal'); cb.setTimeout(rotate, 60000);
© Copyright Chaturbate 2011- 2026. All Rights Reserved.