Bots Home
|
Create an App
Advils All In One
Author:
ibuprofems
Description
Source Code
Launch Bot
Current Users
Created by:
Ibuprofems
/* Chaturbate All-In-One App */ cb.settings_choices = [ { name: 'theme_text_color', type: 'str', minLength: 7, maxLength: 7, defaultValue: '#FFFFFF', label: 'Theme Text Color (hex)' }, { name: 'theme_bg_color', type: 'str', minLength: 7, maxLength: 7, defaultValue: '#101820', label: 'Theme Background Color (hex)' }, { name: 'theme_accent_color', type: 'str', minLength: 7, maxLength: 7, defaultValue: '#FF4D8D', label: 'Theme Accent Color (hex)' }, { name: 'theme_text_weight', type: 'choice', choice1: 'bold', choice2: 'normal', defaultValue: 'bold', label: 'Theme Text Weight' }, { name: 'auto_thank_enabled', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Enable Auto Thank You' }, { name: 'auto_thank_min_tip', type: 'int', minValue: 1, maxValue: 99999, 'default': 75, label: 'Auto Thank Minimum Tip' }, { name: 'auto_thank_message', type: 'str', minLength: 1, maxLength: 255, defaultValue: 'ty baby', label: 'Auto Thank Message ({user} {amount})' }, { name: 'auto_thank_include_amount', type: 'choice', choice1: 'No', choice2: 'Yes', defaultValue: 'No', label: 'Append Tip Amount To Thank You' }, { name: 'auto_thank_cooldown_sec', type: 'int', minValue: 0, maxValue: 600, 'default': 5, label: 'Auto Thank Cooldown Per User (sec)' }, { name: 'menu_enabled', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Enable Tip Menu' }, { name: 'menu_sort_order', type: 'choice', choice1: 'Ascending', choice2: 'Descending', defaultValue: 'Ascending', label: 'Tip Menu Sort Order' }, { name: 'menu_match_mode', type: 'choice', choice1: 'Exact', choice2: 'At or Above', defaultValue: 'Exact', label: 'Tip Match Mode' }, { name: 'menu_notice_target', type: 'choice', choice1: 'Both', choice2: 'Room', choice3: 'Tipper', defaultValue: 'Both', label: 'Menu Hit Notice Target' }, { name: 'menu_repeat_min', type: 'int', minValue: 0, maxValue: 240, 'default': 10, label: 'Repeat Tip Menu Every X Minutes (0=off)' }, { name: 'menu_send_on_enter', type: 'choice', choice1: 'No', choice2: 'Yes', defaultValue: 'No', label: 'Send Tip Menu To User On Enter' }, { name: 'menu_header', type: 'str', minLength: 1, maxLength: 120, defaultValue: 'Tip Menu', label: 'Tip Menu Header' }, { name: 'menu_list_1_name', type: 'str', minLength: 1, maxLength: 40, defaultValue: 'Main Menu', label: 'Menu 1 Name' }, { name: 'menu_list_1_items', type: 'str', minLength: 1, maxLength: 255, defaultValue: '75~ty baby~Hearts Overlay~ding~Thanks baby!;150~Flash~Sparkle Overlay~chime~You are amazing!', label: 'Menu 1 Items (amount~title~overlay~sfx~notice;...)' }, { name: 'menu_list_2_name', type: 'str', minLength: 0, maxLength: 40, required: false, defaultValue: '', label: 'Menu 2 Name (optional)' }, { name: 'menu_list_2_items', type: 'str', minLength: 0, maxLength: 255, required: false, defaultValue: '', label: 'Menu 2 Items (optional)' }, { name: 'menu_list_3_name', type: 'str', minLength: 0, maxLength: 40, required: false, defaultValue: '', label: 'Menu 3 Name (optional)' }, { name: 'menu_list_3_items', type: 'str', minLength: 0, maxLength: 255, required: false, defaultValue: '', label: 'Menu 3 Items (optional)' }, { name: 'menu_list_4_name', type: 'str', minLength: 0, maxLength: 40, required: false, defaultValue: '', label: 'Menu 4 Name (optional)' }, { name: 'menu_list_4_items', type: 'str', minLength: 0, maxLength: 255, required: false, defaultValue: '', label: 'Menu 4 Items (optional)' }, { name: 'reminder_enabled', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Enable Reminders' }, { name: 'reminder_repeat_min', type: 'int', minValue: 0, maxValue: 240, 'default': 15, label: 'Reminder Repeat Every X Minutes (0=off)' }, { name: 'reminder_mode', type: 'choice', choice1: 'Sequence', choice2: 'Random', defaultValue: 'Sequence', label: 'Reminder Rotation Mode' }, { name: 'reminder_1', type: 'str', minLength: 0, maxLength: 255, required: false, defaultValue: 'New menu available. Type /menu to see it.', label: 'Reminder 1' }, { name: 'reminder_2', type: 'str', minLength: 0, maxLength: 255, required: false, defaultValue: 'Tip goals and menu are fully customizable tonight.', label: 'Reminder 2' }, { name: 'reminder_3', type: 'str', minLength: 0, maxLength: 255, required: false, defaultValue: 'Thank you for being here. Your tips keep the show going.', label: 'Reminder 3' }, { name: 'reminder_4', type: 'str', minLength: 0, maxLength: 255, required: false, defaultValue: '', label: 'Reminder 4 (optional)' }, { name: 'reminder_5', type: 'str', minLength: 0, maxLength: 255, required: false, defaultValue: '', label: 'Reminder 5 (optional)' }, { name: 'reminder_6', type: 'str', minLength: 0, maxLength: 255, required: false, defaultValue: '', label: 'Reminder 6 (optional)' }, { name: 'transform_enabled', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Enable Chat Transformations' }, { name: 'transform_case_sensitive', type: 'choice', choice1: 'No', choice2: 'Yes', defaultValue: 'No', label: 'Transform Case Sensitive' }, { name: 'transform_whole_word', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Transform Whole Words Only' }, { name: 'transform_skip_broadcaster', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Skip Broadcaster Messages' }, { name: 'transform_rule_1_find', type: 'str', minLength: 1, maxLength: 40, defaultValue: 'BBC', label: 'Transform 1: Find' }, { name: 'transform_rule_1_replace', type: 'str', minLength: 1, maxLength: 120, defaultValue: 'British Broadcasting Channel', label: 'Transform 1: Replace With' }, { name: 'transform_rule_2_find', type: 'str', minLength: 0, maxLength: 40, required: false, defaultValue: '', label: 'Transform 2: Find (optional)' }, { name: 'transform_rule_2_replace', type: 'str', minLength: 0, maxLength: 120, required: false, defaultValue: '', label: 'Transform 2: Replace (optional)' }, { name: 'transform_rule_3_find', type: 'str', minLength: 0, maxLength: 40, required: false, defaultValue: '', label: 'Transform 3: Find (optional)' }, { name: 'transform_rule_3_replace', type: 'str', minLength: 0, maxLength: 120, required: false, defaultValue: '', label: 'Transform 3: Replace (optional)' }, { name: 'goal_enabled', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Enable Goal Tracker' }, { name: 'goal_title', type: 'str', minLength: 1, maxLength: 120, defaultValue: 'Night Goal', label: 'Goal Title' }, { name: 'goal_target', type: 'int', minValue: 1, maxValue: 999999, 'default': 1000, label: 'Goal Target Tokens' }, { name: 'goal_start', type: 'int', minValue: 0, maxValue: 999999, 'default': 0, label: 'Goal Start Tokens' }, { name: 'goal_bar_size', type: 'int', minValue: 10, maxValue: 30, 'default': 20, label: 'Progress Bar Size (chars)' }, { name: 'goal_allow_overflow', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Allow Goal To Go Over 100%' }, { name: 'goal_reset_on_complete', type: 'choice', choice1: 'No', choice2: 'Yes', defaultValue: 'No', label: 'Auto Reset Goal On Completion' }, { name: 'goal_announce_milestones', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Announce 25/50/75/100% Milestones' }, { name: 'goal_progress_repeat_min', type: 'int', minValue: 0, maxValue: 240, 'default': 5, label: 'Post Goal Progress Every X Minutes (0=off)' }, { name: 'goal_progress_template', type: 'str', minLength: 1, maxLength: 255, defaultValue: 'Goal {title}: {bar} {percent}% ({current}/{target}) - {remaining} left', label: 'Goal Progress Chat Template' }, { name: 'goal_update_subject', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Update Room Subject From Goal' }, { name: 'goal_subject_cooldown_sec', type: 'int', minValue: 0, maxValue: 600, 'default': 8, label: 'Room Subject Update Cooldown (sec)' }, { name: 'goal_subject_template', type: 'str', minLength: 1, maxLength: 255, defaultValue: '{title}: {remaining} tokens left ({percent}%)', label: 'Room Subject Template' }, { name: 'welcome_enabled', type: 'choice', choice1: 'No', choice2: 'Yes', defaultValue: 'No', label: 'Send Welcome Message On Enter' }, { name: 'welcome_message', type: 'str', minLength: 0, maxLength: 255, required: false, defaultValue: 'Welcome {user}! Type /menu to see the tip menu.', label: 'Welcome Message' } ]; var AIO = (function () { var state = { config: {}, theme: { fg: '#FFFFFF', bg: '#101820', accent: '#FF4D8D', weight: 'bold' }, menuItems: [], menuOrder: [], reminders: [], reminderIndex: 0, transformRules: [], timerVersion: { menu: 0, reminder: 0, goal: 0 }, autoThankTsByUser: {}, sessionTipTotal: 0, tipsByUser: {}, topTipper: { user: '', amount: 0 }, goal: { title: 'Night Goal', target: 1000, current: 0, completed: 0, milestones: {}, lastSubjectTs: 0 } }; function t(v) { return (v === null || v === undefined) ? '' : ('' + v).replace(/^\s+|\s+$/g, ''); } function n(v, d) { var x = parseInt(v, 10); return isNaN(x) ? d : x; } function b(v, d) { var s = t(v).toLowerCase(); if (s === 'yes' || s === 'true' || s === '1' || s === 'on') return true; if (s === 'no' || s === 'false' || s === '0' || s === 'off') return false; return d; } function hx(v, d) { var s = t(v).toUpperCase(); return /^#[0-9A-F]{6}$/.test(s) ? s : d; } function rep(ch, c) { var i, o = ''; for (i = 0; i < c; i++) o += ch; return o; } function esc(s) { return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } function ms() { return new Date().getTime(); } function sh(s, m) { if (!s) return ''; return s.length <= m ? s : (s.substring(0, m - 3) + '...'); } function gs(name, d) { return (cb.settings[name] === undefined || cb.settings[name] === null) ? d : cb.settings[name]; } function sn(msg, to, fg, bg, wt) { var m = t(msg); if (!m) return; try { cb.sendNotice(m, to || '', fg || state.theme.fg, bg || state.theme.bg, wt || state.theme.weight); } catch (e) { cb.sendNotice(m, to || ''); } } function chunk(msg, to, fg, bg, wt) { var lines = (msg || '').split('\n'), i, c = ''; for (i = 0; i < lines.length; i++) { if (c.length + lines[i].length + 1 > 430) { sn(c, to, fg, bg, wt); c = lines[i]; } else { c = c ? (c + '\n' + lines[i]) : lines[i]; } } if (c) sn(c, to, fg, bg, wt); } function ctx(user, amount, item) { return { room: cb.room_slug, user: t(user), amount: amount || 0, total: state.sessionTipTotal, goal_title: state.goal.title, goal_current: state.goal.current, goal_target: state.goal.target, goal_percent: gp(), goal_bar: gbar(), goal_remaining: grem(), menu_name: item ? item.menuName : '', menu_amount: item ? item.amount : 0, menu_title: item ? item.title : '', menu_overlay: item ? item.overlay : '', menu_sfx: item ? item.sfx : '' }; } function tpl(s, c) { var o = '' + s, k; for (k in c) if (c.hasOwnProperty(k)) o = o.split('{' + k + '}').join('' + c[k]); return o; } function pm(raw, name) { var out = [], p = (t(raw) ? raw.split(';') : []), i, cols, a, title, row; for (i = 0; i < p.length; i++) { row = t(p[i]); if (!row) continue; cols = row.indexOf('~') !== -1 ? row.split('~') : row.split('|'); a = n(t(cols[0]), 0); title = t(cols[1]); if (a <= 0 || !title) continue; out.push({ menuName: name, amount: a, title: title, overlay: t(cols[2]), sfx: t(cols[3]), notice: t(cols[4]), source: 'settings' }); } return out; } function midx(name) { var i; for (i = 0; i < state.menuOrder.length; i++) if (state.menuOrder[i] === name) return i; return 9999; } function sortMenus() { var asc = state.config.menuSortOrder === 'Ascending'; state.menuItems.sort(function (a, b) { var x = midx(a.menuName) - midx(b.menuName); if (x !== 0) return x; return asc ? (a.amount - b.amount) : (b.amount - a.amount); }); } function loadMenus() { var i, name, raw, arr; state.menuItems = []; state.menuOrder = []; for (i = 1; i <= 4; i++) { name = t(gs('menu_list_' + i + '_name', '')); raw = t(gs('menu_list_' + i + '_items', '')); if (!raw && !name) continue; if (!name) name = 'Menu ' + i; state.menuOrder.push(name); arr = pm(raw, name); state.menuItems = state.menuItems.concat(arr); } sortMenus(); } function menuGroups() { var g = {}, i, it, k; for (i = 0; i < state.menuItems.length; i++) { it = state.menuItems[i]; k = it.menuName || 'Menu'; if (!g[k]) g[k] = []; g[k].push(it); } return g; } function menuText() { var g = menuGroups(), lines = [], i, j, k, list, it; if (!state.config.menuEnabled || state.menuItems.length === 0) return 'Tip menu is currently empty.'; lines.push(state.config.menuHeader + ' (' + state.config.menuSortOrder + ')'); for (i = 0; i < state.menuOrder.length; i++) { k = state.menuOrder[i]; list = g[k] || []; if (!list.length) continue; lines.push('[' + k + ']'); for (j = 0; j < list.length; j++) { it = list[j]; lines.push(it.amount + ' - ' + it.title); } } lines.push('Use /menu anytime to view this again.'); return lines.join('\n'); } function menuUser(u) { chunk(menuText(), u, state.theme.fg, state.theme.bg, state.theme.weight); } function menuRoom() { chunk(menuText(), '', state.theme.fg, state.theme.bg, state.theme.weight); } function menuMatches(amount) { var i, m = [], best = null; if (!state.config.menuEnabled || state.menuItems.length === 0) return m; if (state.config.menuMatchMode === 'Exact') { for (i = 0; i < state.menuItems.length; i++) if (state.menuItems[i].amount === amount) m.push(state.menuItems[i]); return m; } for (i = 0; i < state.menuItems.length; i++) if (amount >= state.menuItems[i].amount && (!best || state.menuItems[i].amount > best.amount)) best = state.menuItems[i]; if (best) m.push(best); return m; } function menuHit(item, tip) { var base = '[' + item.menuName + '] ' + tip.amount + 'tks - ' + item.title, mode = state.config.menuNoticeTarget, msg; if (item.overlay) base += ' | Overlay: ' + item.overlay; if (item.sfx) base += ' | SFX: ' + item.sfx; if (mode === 'Room' || mode === 'Both') sn(base, '', state.theme.accent, state.theme.bg, state.theme.weight); if (mode === 'Tipper' || mode === 'Both') sn(base, tip.from_user, state.theme.accent, state.theme.bg, state.theme.weight); if (item.notice) { msg = tpl(item.notice, ctx(tip.from_user, tip.amount, item)); if (mode === 'Room' || mode === 'Both') sn(msg, '', state.theme.fg, state.theme.bg, state.theme.weight); if (mode === 'Tipper' || mode === 'Both') sn(msg, tip.from_user, state.theme.fg, state.theme.bg, state.theme.weight); } } function gpr() { if (!state.config.goalEnabled || state.goal.target <= 0) return 0; return (state.goal.current / state.goal.target) * 100; } function gp() { var x = Math.floor(gpr()); if (!state.config.goalAllowOverflow && x > 100) x = 100; if (x < 0) x = 0; return x; } function grem() { var x = state.goal.target - state.goal.current; return x > 0 ? x : 0; } function gbar() { var size = state.config.goalBarSize, p = gpr(), z = p, fill; if (z < 0) z = 0; if (z > 100) z = 100; fill = Math.round((z / 100) * size); if (fill < 0) fill = 0; if (fill > size) fill = size; return '[' + rep('#', fill) + rep('-', size - fill) + ']'; } function resetMiles() { state.goal.milestones = { 25: false, 50: false, 75: false, 100: false }; } function announceMiles() { var p, m = [25, 50, 75, 100], i, v; if (!state.config.goalEnabled || !state.config.goalAnnounceMilestones) return; p = gpr(); for (i = 0; i < m.length; i++) { v = m[i]; if (p >= v && !state.goal.milestones[v]) { state.goal.milestones[v] = true; sn('Goal milestone hit: ' + v + '% (' + state.goal.current + '/' + state.goal.target + ')', '', state.theme.accent, state.theme.bg, state.theme.weight); } } } function completeGoal() { var loops = 0, over; if (!state.config.goalEnabled || state.goal.target <= 0 || state.goal.current < state.goal.target) return; sn('Goal complete: ' + state.goal.title + ' (' + state.goal.current + '/' + state.goal.target + ')', '', state.theme.accent, state.theme.bg, state.theme.weight); if (!state.config.goalResetOnComplete) return; while (state.goal.current >= state.goal.target && loops < 20) { over = state.goal.current - state.goal.target; state.goal.completed += 1; state.goal.current = state.config.goalAllowOverflow ? over : 0; resetMiles(); loops += 1; } sn('Goal auto-reset. Completed cycles this session: ' + state.goal.completed + '.', '', state.theme.fg, state.theme.bg, state.theme.weight); } function subj(force) { var cd, e, c, s; if (!state.config.goalEnabled || !state.config.goalUpdateSubject) return; cd = state.config.goalSubjectCooldownSec * 1000; e = ms() - state.goal.lastSubjectTs; if (!force && cd > 0 && e < cd) return; c = ctx('', 0, null); c.title = state.goal.title; c.current = state.goal.current; c.target = state.goal.target; c.remaining = grem(); c.percent = gp(); c.bar = gbar(); s = sh(tpl(state.config.goalSubjectTemplate, c), 255); cb.changeRoomSubject(s); state.goal.lastSubjectTs = ms(); } function gline() { var c = ctx('', 0, null); c.title = state.goal.title; c.current = state.goal.current; c.target = state.goal.target; c.remaining = grem(); c.percent = gp(); c.bar = gbar(); return tpl(state.config.goalProgressTemplate, c); } function loadRem() { var i, v; state.reminders = []; state.reminderIndex = 0; for (i = 1; i <= 6; i++) { v = t(gs('reminder_' + i, '')); if (v) state.reminders.push(v); } } function nextRem() { var i; if (!state.reminders.length) return ''; if (state.config.reminderMode === 'Random') { i = Math.floor(Math.random() * state.reminders.length); return state.reminders[i]; } i = state.reminderIndex % state.reminders.length; state.reminderIndex += 1; return state.reminders[i]; } function postRem() { var m = nextRem(); if (m) sn(m, '', state.theme.fg, state.theme.bg, state.theme.weight); } function loadTrans() { var i, f, r; state.transformRules = []; for (i = 1; i <= 5; i++) { f = t(gs('transform_rule_' + i + '_find', '')); r = t(gs('transform_rule_' + i + '_replace', '')); if (f && r) state.transformRules.push({ find: f, replace: r }); } } function runTrans(text) { var out = '' + text, i, r, p, flags = state.config.transformCaseSensitive ? 'g' : 'gi'; for (i = 0; i < state.transformRules.length; i++) { r = state.transformRules[i]; p = state.config.transformWholeWord ? new RegExp('\\b' + esc(r.find) + '\\b', flags) : new RegExp(esc(r.find), flags); out = out.replace(p, r.replace); } return out; } function loopMenu() { var v, d; state.timerVersion.menu += 1; v = state.timerVersion.menu; if (!state.config.menuEnabled || state.config.menuRepeatMin <= 0) return; d = state.config.menuRepeatMin * 60000; cb.setTimeout(function () { if (v !== state.timerVersion.menu) return; menuRoom(); loopMenu(); }, d); } function loopRem() { var v, d; state.timerVersion.reminder += 1; v = state.timerVersion.reminder; if (!state.config.reminderEnabled || state.config.reminderRepeatMin <= 0 || !state.reminders.length) return; d = state.config.reminderRepeatMin * 60000; cb.setTimeout(function () { if (v !== state.timerVersion.reminder) return; postRem(); loopRem(); }, d); } function loopGoal() { var v, d; state.timerVersion.goal += 1; v = state.timerVersion.goal; if (!state.config.goalEnabled || state.config.goalProgressRepeatMin <= 0) return; d = state.config.goalProgressRepeatMin * 60000; cb.setTimeout(function () { if (v !== state.timerVersion.goal) return; sn(gline(), '', state.theme.fg, state.theme.bg, state.theme.weight); loopGoal(); }, d); } function staff(msg) { return msg.user === cb.room_slug || !!msg.is_mod; } function setGoal(target, title) { if (target > 0) state.goal.target = target; if (t(title)) state.goal.title = t(title); if (state.goal.current > state.goal.target && !state.config.goalAllowOverflow) state.goal.current = state.goal.target; resetMiles(); announceMiles(); subj(true); cb.drawPanel(); } function resetGoal(cur) { state.goal.current = cur >= 0 ? cur : 0; state.goal.completed = 0; resetMiles(); subj(true); cb.drawPanel(); } function help(isStaff) { var a = []; a.push('All-In-One Commands'); a.push('/menu -> show tip menu (private)'); a.push('/goal -> show goal status'); a.push('/aiohelp -> show command help'); if (isStaff) { a.push('/menushow -> post menu to room'); a.push('/menuadd menu|amount|title|overlay|sfx|notice'); a.push('/menudel menu|amount|title(optional)'); a.push('/menureload -> reload menus from settings'); a.push('/goalset target|title(optional)'); a.push('/goalreset current(optional)'); a.push('/remindnow -> post next reminder now'); a.push('/transforms -> list active text transforms'); } return a.join('\n'); } function addMenu(payload, user) { var p = payload.split('|'), mn = t(p[0]), amount = n(t(p[1]), 0), title = t(p[2]), ov = t(p[3]), sfx = t(p[4]), nt = t(p[5]); if (!mn || amount <= 0 || !title) { sn('Usage: /menuadd menu|amount|title|overlay|sfx|notice', user, state.theme.fg, state.theme.bg, state.theme.weight); return; } state.menuItems.push({ menuName: mn, amount: amount, title: title, overlay: ov, sfx: sfx, notice: nt, source: 'runtime' }); if (midx(mn) === 9999) state.menuOrder.push(mn); sortMenus(); sn('Added: [' + mn + '] ' + amount + ' - ' + title, user, state.theme.accent, state.theme.bg, state.theme.weight); } function delMenu(payload, user) { var p = payload.split('|'), mn = t(p[0]), amount = n(t(p[1]), 0), title = t(p[2]), i; if (!mn || amount <= 0) { sn('Usage: /menudel menu|amount|title(optional)', user, state.theme.fg, state.theme.bg, state.theme.weight); return; } for (i = 0; i < state.menuItems.length; i++) { if (state.menuItems[i].menuName !== mn) continue; if (state.menuItems[i].amount !== amount) continue; if (title && state.menuItems[i].title !== title) continue; state.menuItems.splice(i, 1); sn('Removed: [' + mn + '] ' + amount + (title ? (' - ' + title) : ''), user, state.theme.accent, state.theme.bg, state.theme.weight); return; } sn('No matching menu item found.', user, state.theme.fg, state.theme.bg, state.theme.weight); } function cmd(msg) { var x = t(msg.m), p, c, pay, st, i, lines, goalP, target, title, cur; if (!x || x.charAt(0) !== '/') return false; p = x.split(' '); c = t(p[0].toLowerCase()); pay = t(x.substring(c.length)); st = staff(msg); if (c === '/menu') { menuUser(msg.user); return true; } if (c === '/goal') { sn(gline(), msg.user, state.theme.fg, state.theme.bg, state.theme.weight); return true; } if (c === '/aiohelp') { chunk(help(st), msg.user, state.theme.fg, state.theme.bg, state.theme.weight); return true; } if (!st) return false; if (c === '/menushow') { menuRoom(); return true; } if (c === '/menuadd') { addMenu(pay, msg.user); return true; } if (c === '/menudel') { delMenu(pay, msg.user); return true; } if (c === '/menureload') { loadMenus(); sn('Menus reloaded from settings.', msg.user, state.theme.accent, state.theme.bg, state.theme.weight); return true; } if (c === '/goalset') { goalP = pay.split('|'); target = n(t(goalP[0]), 0); title = t(goalP[1]); if (target <= 0) sn('Usage: /goalset target|title(optional)', msg.user, state.theme.fg, state.theme.bg, state.theme.weight); else { setGoal(target, title); sn('Goal updated: ' + state.goal.title + ' (' + state.goal.target + ')', msg.user, state.theme.accent, state.theme.bg, state.theme.weight); } return true; } if (c === '/goalreset') { cur = n(pay, 0); resetGoal(cur); sn('Goal reset. Current=' + state.goal.current, msg.user, state.theme.accent, state.theme.bg, state.theme.weight); return true; } if (c === '/remindnow') { postRem(); sn('Reminder posted.', msg.user, state.theme.accent, state.theme.bg, state.theme.weight); return true; } if (c === '/transforms') { lines = []; if (!state.transformRules.length) lines.push('No transformation rules are active.'); else { lines.push('Active transformation rules:'); for (i = 0; i < state.transformRules.length; i++) lines.push((i + 1) + ') "' + state.transformRules[i].find + '" -> "' + state.transformRules[i].replace + '"'); } chunk(lines.join('\n'), msg.user, state.theme.fg, state.theme.bg, state.theme.weight); return true; } return false; } function onTip(tip) { var u = tip.from_user, amount = n(tip.amount, 0), total, m, i, amsg, cd, last, c; if (amount <= 0) return; state.sessionTipTotal += amount; total = n(state.tipsByUser[u], 0) + amount; state.tipsByUser[u] = total; if (total > state.topTipper.amount) { state.topTipper.user = u; state.topTipper.amount = total; } if (state.config.goalEnabled) { state.goal.current += amount; if (!state.config.goalAllowOverflow && state.goal.current > state.goal.target) state.goal.current = state.goal.target; announceMiles(); completeGoal(); subj(false); } if (state.config.autoThankEnabled && amount >= state.config.autoThankMinTip) { cd = state.config.autoThankCooldownSec * 1000; last = n(state.autoThankTsByUser[u], 0); if (cd <= 0 || (ms() - last) >= cd) { c = ctx(u, amount, null); amsg = tpl(state.config.autoThankMessage, c); if (state.config.autoThankIncludeAmount) amsg += ' (' + amount + ' tokens)'; sn(amsg, u, state.theme.accent, state.theme.bg, state.theme.weight); state.autoThankTsByUser[u] = ms(); } } m = menuMatches(amount); for (i = 0; i < m.length; i++) menuHit(m[i], tip); cb.drawPanel(); } function onEnter(user) { var u = user.user; if (state.config.welcomeEnabled && t(state.config.welcomeMessage)) sn(tpl(state.config.welcomeMessage, ctx(u, 0, null)), u, state.theme.fg, state.theme.bg, state.theme.weight); if (state.config.menuEnabled && state.config.menuSendOnEnter) menuUser(u); } function onMsg(msg) { var x = t(msg.m); if (cmd(msg)) { msg['X-Spam'] = true; return msg; } if (state.config.transformEnabled && state.transformRules.length && x && x.charAt(0) !== '/' && !(state.config.transformSkipBroadcaster && msg.user === cb.room_slug)) msg.m = runTrans(msg.m); return msg; } function panel() { var r1, r2, r3; if (state.config.goalEnabled) { r1 = sh(state.goal.title + ': ' + state.goal.current + '/' + state.goal.target, 45); r2 = sh(gbar() + ' ' + gp() + '%', 45); } else { r1 = 'Goal tracker disabled'; r2 = 'Enable in settings'; } r3 = sh('Session ' + state.sessionTipTotal + ' | Top ' + (state.topTipper.user || '--') + ' (' + state.topTipper.amount + ')', 45); return { template: '3_rows_of_labels', row1_label: 'Goal', row1_value: r1, row2_label: 'Progress', row2_value: r2, row3_label: 'Stats', row3_value: r3 }; } function load() { state.theme.fg = hx(gs('theme_text_color', '#FFFFFF'), '#FFFFFF'); state.theme.bg = hx(gs('theme_bg_color', '#101820'), '#101820'); state.theme.accent = hx(gs('theme_accent_color', '#FF4D8D'), '#FF4D8D'); state.theme.weight = t(gs('theme_text_weight', 'bold')) === 'normal' ? 'normal' : 'bold'; state.config.autoThankEnabled = b(gs('auto_thank_enabled', 'Yes'), true); state.config.autoThankMinTip = n(gs('auto_thank_min_tip', 75), 75); state.config.autoThankMessage = t(gs('auto_thank_message', 'ty baby')); state.config.autoThankIncludeAmount = b(gs('auto_thank_include_amount', 'No'), false); state.config.autoThankCooldownSec = n(gs('auto_thank_cooldown_sec', 5), 5); state.config.menuEnabled = b(gs('menu_enabled', 'Yes'), true); state.config.menuSortOrder = t(gs('menu_sort_order', 'Ascending')) === 'Descending' ? 'Descending' : 'Ascending'; state.config.menuMatchMode = t(gs('menu_match_mode', 'Exact')) === 'At or Above' ? 'At or Above' : 'Exact'; state.config.menuNoticeTarget = t(gs('menu_notice_target', 'Both')); if (state.config.menuNoticeTarget !== 'Room' && state.config.menuNoticeTarget !== 'Tipper' && state.config.menuNoticeTarget !== 'Both') state.config.menuNoticeTarget = 'Both'; state.config.menuRepeatMin = n(gs('menu_repeat_min', 10), 10); state.config.menuSendOnEnter = b(gs('menu_send_on_enter', 'No'), false); state.config.menuHeader = t(gs('menu_header', 'Tip Menu')); state.config.reminderEnabled = b(gs('reminder_enabled', 'Yes'), true); state.config.reminderRepeatMin = n(gs('reminder_repeat_min', 15), 15); state.config.reminderMode = t(gs('reminder_mode', 'Sequence')) === 'Random' ? 'Random' : 'Sequence'; state.config.transformEnabled = b(gs('transform_enabled', 'Yes'), true); state.config.transformCaseSensitive = b(gs('transform_case_sensitive', 'No'), false); state.config.transformWholeWord = b(gs('transform_whole_word', 'Yes'), true); state.config.transformSkipBroadcaster = b(gs('transform_skip_broadcaster', 'Yes'), true); state.config.goalEnabled = b(gs('goal_enabled', 'Yes'), true); state.goal.title = t(gs('goal_title', 'Night Goal')); state.goal.target = n(gs('goal_target', 1000), 1000); state.goal.current = n(gs('goal_start', 0), 0); state.config.goalBarSize = n(gs('goal_bar_size', 20), 20); if (state.config.goalBarSize < 10) state.config.goalBarSize = 10; if (state.config.goalBarSize > 30) state.config.goalBarSize = 30; state.config.goalAllowOverflow = b(gs('goal_allow_overflow', 'Yes'), true); state.config.goalResetOnComplete = b(gs('goal_reset_on_complete', 'No'), false); state.config.goalAnnounceMilestones = b(gs('goal_announce_milestones', 'Yes'), true); state.config.goalProgressRepeatMin = n(gs('goal_progress_repeat_min', 5), 5); state.config.goalProgressTemplate = t(gs('goal_progress_template', 'Goal {title}: {bar} {percent}% ({current}/{target}) - {remaining} left')); state.config.goalUpdateSubject = b(gs('goal_update_subject', 'Yes'), true); state.config.goalSubjectCooldownSec = n(gs('goal_subject_cooldown_sec', 8), 8); state.config.goalSubjectTemplate = t(gs('goal_subject_template', '{title}: {remaining} tokens left ({percent}%)')); state.config.welcomeEnabled = b(gs('welcome_enabled', 'No'), false); state.config.welcomeMessage = t(gs('welcome_message', 'Welcome {user}! Type /menu to see the tip menu.')); } function init() { load(); loadMenus(); loadRem(); loadTrans(); resetMiles(); announceMiles(); subj(true); loopMenu(); loopRem(); loopGoal(); cb.drawPanel(); sn('All-In-One app loaded. Use /aiohelp for commands.', cb.room_slug, state.theme.accent, state.theme.bg, state.theme.weight); } return { init: init, onTip: onTip, onMessage: onMsg, onEnter: onEnter, onDrawPanel: panel }; })(); cb.onTip(function (tip) { AIO.onTip(tip); }); cb.onMessage(function (msg) { return AIO.onMessage(msg); }); cb.onEnter(function (user) { AIO.onEnter(user); }); cb.onDrawPanel(function () { return AIO.onDrawPanel(); }); AIO.init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.