Bots Home
|
Create an App
Babo Secret Show beta
Author:
babo1
Description
Source Code
Launch Bot
Current Users
Created by:
Babo1
/* # Babo Secret Show ## Summary Secret show with 3 modes - Pay once, Pay per min, One to One ## Full Description ### Modes: 1. Pay once : User pay once, watch full show (like Ticket show). 2. Pay per minute : User pay multiples of per minute price, watch that many minutes (like Group Show). 3. One to One : Only allow one user to view video (like Password Room). ### List of commands: /start - Start a secret show /stop - Stop a secret show /add username - Add users to secret show /del username - Remove users from secret show /list - List users in secret show ### Credits - This is a modified version of noiett's My Secret Show., with simplified options and different defaults. ### Changes 20210523 - add emoji to some notices - add sysbot, count broadcaster in user list - add */ var BSTAR = '\u2764', // ❤ ARROW = '\u2192', // → SBSQR = '\u25AA'; // ▪ /** * Prototypes */ String.prototype.getLastChar = function() { var str = this.toString(); return str[str.length - 1]; }; Date.prototype.addMinutes = function(minutes) { this.setTime(this.getTime() + (minutes * 60000)); return this; } Date.prototype.addSeconds = function(seconds) { this.setTime(this.getTime() + (seconds * 1000)); return this; } /** * Main app object */ var secretShow = { // default configuration modelName: cb.room_slug, botName: 'Babo Secret Show', botVersion: '03', botDate: '20201018', //botIcon : ':mtlcamleft', //botTimerIcon : ':5j4k5kjj4', botIcon: ':babo_yay', // botTimerIcon: ':babo_spy', botTextColor: '#4682B4', botBgColor: '', botTextWeight: 'bold', botWarningColor: '#636363', botNoticeDelay: 500, botAnnounce: true, timeLeftColor: '#000000', sysbot: 'sysbot', botMode: 0, showPrice: 99, minutePrice: 18, minTipped: 0, // add users tipped this amount or higher (0=disable) minMinutes: 1, // minimum minutes to join the show chatLevel: 0, noticeMessage: ':babo_spy Secret Show is running [ {time} ].', noticeTimer: 0, timeoutID: 0, timeoutRefresh: 0, refreshInterval: 9500, camMessage: 'Secret Show in progress!', extraTip: true, // allow tip higher than price preAdd: true, // allow tip before show begin autoClean: true, // clear users after show saveTimes: true, // save remaining time for users specialMods: true, freeMods: false, freeFans: false, startTime: 0, tippersList: [], userTimes: {}, VIPList: [], bannedList: [], adminList: [], modeList: { '1': 'FULL', '2': 'TIME', '3': 'NONE', }, modeList: { '1 - (Pay Once)': 'FULL', '2 - (Pay per Minute)': 'TIME', '3 - (One to One)': 'NONE', }, levelList: { 'All users': 'ALL', 'Users with tokens': 'BLUES', 'Users that tipped': 'TIPPERS', 'Users in Secret Show': 'SECRET', }, secretHelp: '', settings_choices: [ { name: 'secret_mode', type: 'choice', label: 'Choose Secret Show Mode (2)', defaultValue: '2', required: false }, { name: 'secret_price', type: 'int', label: 'Mode 1: PAY ONCE to watch full show ..... price (200)', minValue: 1, maxValue: 9999, defaultValue: 200 }, { name: 'secret_tokens_minute', type: 'int', label: 'Mode 2: PAY PER MINUTE ..... Price (18)', minValue: 1, maxValue: 999, defaultValue: 18 }, //{ name: 'secret_min', type:'int', label: 'Auto-add users that tipped this amount or more (0=disabled)', minValue: 0, maxValue: 999, defaultValue: 0 }, //{ name: 'secret_mods_viewers', type: 'choice', label: 'Allow mods to add/remove viewers (No)', choice1: 'Yes', choice2: 'No', defaultValue: 'No', required: false }, //{ name: 'secret_free_mods', type: 'choice', label: 'Mods have free access to shows (No)', choice1: 'Yes', choice2: 'No', defaultValue: 'No', required: false }, //{ name: 'secret_free_fans', type: 'choice', label: 'Fan Club Members have free access to shows (No)', choice1: 'Yes', choice2: 'No', defaultValue: 'No', required: false }, { name: 'secret_vip', type: 'str', label: 'Mode 3: ONE to ONE ..... (username)', minLength: 0, maxLength: 1024, required: false, defaultValue: 'babo_babo' }, { name: 'secret_admin', type: 'str', label: 'Admin username [can type commands and watch]', minLength: 0, maxLength: 1024, required: false, defaultValue: 'babo_babo' }, //{ name: 'secret_banned', type: 'str', label: 'Banned users (cannot tip to watch), separated by commas', minLength: 0, maxLength: 1024, required: false, defaultValue: '' }, ], /** * Builds user vars and arrays based on settings */ parseSettings: function() { // Bot Mode settings this.botMode = this.modeList[cb.settings.secret_mode]; this.showPrice = parseInt(cb.settings.secret_price); this.minutePrice = parseInt(cb.settings.secret_tokens_minute); //Babo ***** //RosePink : { code: '#FF00BA', bgcode: '#ffe8f9'}, this.botTextColor = '#FF00BA'; this.botBgColor = '#FFE8F9'; // who can chat? //this.chatLevel = 'SECRET'; //this.chatLevel = 'BLUES'; //this.chatLevel = 'TIPPERS'; this.chatLevel = 'ALL'; this.botAnnounce = true; this.noticeTimer = 1; // Privileges & special users this.specialMods = false; // allow mods to add/remove users this.freeMods = false; // allow moderators watch for free this.freeFans = false; // allow fans watch for free if (cb.settings.secret_admin) this.adminList = utils.settingsListToArray(cb.settings.secret_admin.toLowerCase()); if (cb.settings.secret_vip) this.VIPList = utils.settingsListToArray(cb.settings.secret_vip.toLowerCase()); if (cb.settings.secret_banned) this.bannedList = utils.settingsListToArray(cb.settings.secret_banned.toLowerCase()); // Users and admin help var prefix = '/'; modelHelp = '/sshelp ' + ARROW + ' Show all the secret show commands\n' + prefix + 'start ' + ARROW + ' Start the secret show (hide video from public)\n' + // prefix + 'start [price] ' + ARROW + ' Starts a secret show with a custom price\n' + prefix + 'stop ' + ARROW + ' Stop the secret show (show video to public)\n' + prefix + 'add [username] ' + ARROW + ' Adds users to the secret show\n' + prefix + 'del [username] ' + ARROW + ' Delete users from the secret show\n' + // prefix + 'check [username] ' + ARROW + ' Checks if a user is in the Secret Show\n' + prefix + 'list ' + ARROW + ' List all the users in the secret show'; }, onMessage: function(msg) { // Some variables var name = msg['user']; var isModel = (name == cb.room_slug); var isAdmin = this.isAdminUser(name); var isMod = msg['is_mod']; var isFan = msg['in_fanclub']; var hasTokens = msg['has_tokens']; var hasTipped = (msg['tipped_recently'] || msg['tipped_alot_recently'] || msg['tipped_tons_recently']); var isGrey = !(hasTokens || isMod || isModel || isFan); var botPrefix = '/'; if (this.startTime && !isModel) { var userInShow = this.userInSecretShow(name); // Grant free access if (!userInShow && (this.freeMods && isMod || this.freeFans && isFan)) { this.addUserToShow(name); } // Block users not allowed to chat if (this.chatLevel != 'ALL' && !isMod && !isFan) { if (isGrey || (!this.isTipper(name) && this.chatLevel == 'TIPPERS') || (!userInShow && this.chatLevel == 'SECRET')) { msg['X-Spam'] = true; msg['background'] = '#F4F4F4'; msg['c'] = '#a2a2a2'; msg['m'] = 'Message not sent ' + SBSQR + ' Only ' + this.chatLevel.toLowerCase() + ' are allowed to chat now.'; return; } } } // // If command then process if (msg.m.indexOf('/') == 0 || msg.m.indexOf('!') == 0) { // Handling commands var message = msg['m'].substr(1); var userParam = utils.getParam(message, 0); // command var userParam2 = utils.getParam(message, 1); // parameter 1 switch (userParam) { case 'sshelp': if (isModel || isAdmin || (isMod && this.specialMods)) { msg['X-Spam'] = true; this.sendHelp(name); } else { utils.userNotice(name, 'Only the broadcaster ' + (this.specialMods ? 'and mods ' : '') + 'can use this command.'); } break; case 'add': case 'del': case 'check': if (isModel || isAdmin || (isMod && this.specialMods)) { msg['X-Spam'] = true; if (!userParam2) { utils.userNotice(name, 'You need to type the user you want to ' + userParam + '.'); break; } switch (userParam) { case 'add': if (!this.addUserToShow(userParam2)) { utils.userNotice(name, 'User ' + userParam2 + ' is already in the viewers list.'); } break; case 'del': if (!this.removeUserFromShow(userParam2)) { utils.userNotice(name, 'User ' + userParam2 + ' is not in the viewers list.'); } break; case 'check': if (this.userInSecretShow(userParam2)) { utils.userNotice(name, 'User ' + userParam2 + ' is in the viewers list.'); } else { utils.userNotice(name, 'User ' + userParam2 + ' is not in the viewers list.'); } break; } } else { utils.userNotice(name, 'Only the broadcaster ' + (this.specialMods ? 'and mods ' : '') + 'can use this command.'); } break; case 'list': if (isModel || isAdmin || (isMod && this.specialMods)) { msg['X-Spam'] = true; var userList = cb.limitCam_allUsersWithAccess(); utils.userNotice(name, userList.length + " user(s) in Secret Show: " + cbjs.arrayJoin(userList, ", ").replace(this.sysbot, this.modelName)); } else { utils.userNotice(name, 'Only the broadcaster can use this command.'); } break; case 'start': if (isModel || isAdmin) { msg['X-Spam'] = true; if (userParam2) { // Parameter is Integer to start a secret show? if (!(userParam2 && Number.isInteger(parseInt(userParam2)))) { utils.userNotice(name, 'You need to type a valid parameter (e.g. ' + botPrefix + userParam + ' 25).'); break; } // Show running? if (cb.limitCam_isRunning()) { utils.userNotice(name, 'Secret Show is already running!'); break; } // Price range userParam2 = parseInt(userParam2); if (userParam2 < 1 || userParam2 > 1000) { utils.userNotice(name, 'Secret Show price must be between 1 and 1000.'); break; } // Start Show this.showPrice = userParam2; this.minutePrice = userParam2; this.startSecretShow(); } // No price given: use default else { if (cb.limitCam_isRunning()) { utils.userNotice(name, 'Secret Show is running already!'); break; } this.startSecretShow(); } } else { utils.userNotice(name, 'Only the broadcaster can use this command.'); } break; case 'stop': if (isModel || isAdmin) { msg['X-Spam'] = true; if (!cb.limitCam_isRunning()) { utils.userNotice(name, 'Secret Show is not running at the moment.'); break; } cb.limitCam_stop(); utils.roomInfoNotice(':babo_sad4 Secret Show is over! Duration time: ' + utils.getElapsedTime(this.startTime)); this.startTime = 0; // Reset default prices this.showPrice = cb.settings.secret_price; this.minutePrice = cb.settings.secret_tokens_minute; // Remove full show users if (this.autoClean) { if (this.removeFullShowUsers()) { utils.modelNotice('Users with full access have been removed from the Secret Show.'); } } // Handle remaining times if (this.botMode == 'TIME' && this.saveTimes) { if (this.saveTimeFromUsers()) { utils.modelNotice('The remaining times from all viewers have been saved.'); } } else { this.removePayPerMinuteUsers(); this.userTimes = {}; } // Cancel notifier if (this.timeoutID) { cb.cancelTimeout(this.timeoutID); this.timeoutID = 0; } } else { utils.userNotice(name, 'Only the broadcaster can use this command.'); } break; } } // Tip test if (isModel) this.tipTest(msg.m); return msg; }, onEnter: function(user) { var name = user['user']; var isMod = user['is_mod']; var isFan = user['in_fanclub']; var isModel = (name == cb.room_slug); var hasTokens = user['has_tokens']; var hasTipped = user['tipped_recently']; var isGrey = !(hasTokens || isMod || isModel || isFan); // Bot announcement if (!isGrey && this.botAnnounce) { // Announce running show if (this.startTime) { utils.userNotice(name, 'Secret Show is running [ ' + utils.getElapsedTime(this.startTime) + ' ]. ' + this.getPriceText(), '', this.botBgColor); } } // Grant free access if (this.startTime && !cb.limitCam_userHasAccess(name) && (this.freeMods && isMod || this.freeFans && isFan)) { this.addUserToShow(name); } }, onTip: function(tip) { var username = tip.from_user; var amount = parseInt(tip.amount); var found = false; var isMVP = false; var isAnon = tip.is_anon_tip; // Handle Lovers List: if (this.tippersList.length > 0) { isMVP = (username == this.tippersList[0].name); } // Update tipper for (var i = 0; i < this.tippersList.length; i++) { if (this.tippersList[i].name == username) { this.tippersList[i].tokens += amount; found = true; break; } } // Add a new one if (!found) this.tippersList.push({ name: username, tokens: amount }); // Sort the array this.tippersList.sort(function(a, b) { return b.tokens - a.tokens; }); // Handle Secret Show viewers // Full Show Mode if (this.botMode == 'FULL') { if (!this.userInSecretShow(username)) { if (cb.limitCam_isRunning() && (amount == this.showPrice || this.extraTip && amount > this.showPrice) || (this.preAdd && amount == this.showPrice)) { // Check possible ban if (!this.isBannedUser(username)) { this.addUserToShow(username, isAnon); } else { utils.userNotice(username, 'Sorry, the broadcaster doesn\'t allow you to watch hidden shows.'); } } } } // Pay per Minute Mode else if (cb.limitCam_isRunning() && this.botMode == 'TIME') { var minutesBought = parseInt(amount / this.minutePrice); if (minutesBought > 0) { // Check possible ban if (!this.isBannedUser(username)) { this.addMinutesToUser(username, minutesBought, isAnon); } else { utils.userNotice(username, 'Sorry, the broadcaster doesn\'t allow you to watch hidden shows.'); } } else { if (this.userInSecretShow(username)) { utils.userNotice(username, 'You must tip at least ' + this.minutePrice + 'tk to get more minutes of show viewing.', this.botWarningColor); } } } }, isAdminUser: function(name) { return this.adminList.includes(name); }, isVIPUser: function(name) { return this.VIPList.includes(name); }, isBannedUser: function(name) { return this.bannedList.includes(name); }, isTipper: function(name) { for (var i = 0; i < this.tippersList.length; i++) { if (this.tippersList[i].name == name) { return true; } } return false; }, userInSecretShow: function(name) { return cb.limitCam_userHasAccess(name); }, addUserToShow: function(name, is_anon) { if (!this.userInSecretShow(name)) { cb.limitCam_addUsers(name); utils.roomInfoNotice(BSTAR + ' ' + (is_anon ? 'anonymous user' : name) + ' has been added to the Secret Show'); return true; } return false; }, removeUserFromShow: function(name) { if (cb.limitCam_userHasAccess(name)) { cb.limitCam_removeUsers(name); delete this.userTimes[name]; utils.roomNotice(BSTAR + ' ' + name + ' has been removed from the Secret Show'); return true; } return false; }, /** * Starts the show and takes care of everything */ startSecretShow: function() { // Start Show this.startTime = new Date(); cb.limitCam_start(this.camMessage + ' ' + this.getPriceText()); // Add tippers this.addTippersToShow(); // Add VIP users this.addVIPUsersToShow(); // Restore pay per minute times pending this.restoreTimeFromUsers(); // Notify Mods & Fans if needed this.notifyFreeAccessUsers(); // Notify room utils.roomInfoNotice(':babo_yay2 Secret Show has started. ' + this.getPriceText().replace(/ *\([^)]*\) */g, "")); // Launch refresh & notifier timers if (this.botMode == 'TIME') this.timeoutRefresh = cb.setTimeout(this.refreshUsers.bind(this), this.refreshInterval); this.timeoutID = cb.setTimeout(this.displayShowNotice.bind(this), (Math.floor(Math.random() * 60) + 15) * 1000); }, /** * Send command help to the user */ sendHelp: function(target) { var head = ' Secret Show Help '; var outMsg = modelHelp; if (head) utils.delayedNotice(300, head, target, this.botTextColor, this.botBgColor, 'bold'); utils.delayedNotice(600, outMsg, target, this.botBgColor, this.botTextColor, 'normal'); }, /** * Add good tippers and vip users to the Secret Show */ addTippersToShow: function() { cb.limitCam_addUsers(this.sysbot); // Add good tippers if (this.minTipped && this.tippersList.length && this.botMode != 'NONE') { var out = ''; var tippers = 0; for (var i = 0; i < this.tippersList.length; i++) { if (this.tippersList[i].tokens >= this.minTipped && !this.isBannedUser(this.tippersList[i].name)) { if (!cb.limitCam_userHasAccess(this.tippersList[i].name)) { cb.limitCam_addUsers(this.tippersList[i].name); tippers++; } } } if (tippers) { out = tippers + ' user' + ((tippers > 1) ? 's' : '') + ' that tipped ' + this.minTipped + 'tks or more ha' + ((tippers > 1) ? 've' : 's') + ' been added to the show'; } if (out) { utils.delayedNotice(800, out, '', this.botBgColor, this.botTextColor, 'bolder'); } } }, /** * Add users in the VIP list to the show */ addVIPUsersToShow: function() { for (var i = 0; i < this.VIPList.length; i++) { if (!cb.limitCam_userHasAccess(this.VIPList[i])) cb.limitCam_addUsers(this.VIPList[i]); } }, /** * Notification for users with free access */ notifyFreeAccessUsers: function() { var target = []; // Mods only if (this.freeMods) { target.push('red'); } // Fan Club if (this.freeFanClub) { target.push('green'); } // Deliver notification if (target.length) { for (var i = 0; i < target.length; i++) { var msg = target[i] + ' can access the show if they type in the room or refresh.'; msg = msg.replace('red', 'Moderators'); msg = msg.replace('green', 'Fan Club Members'); utils.groupNotice(target[i], msg, '', this.botBgColor); } } }, /** * Returns a text indicating the price of the show */ getPriceText: function() { if (this.botMode == 'FULL') { return 'Tip ' + this.showPrice + 'tks to watch full show!'; } else if (this.botMode == 'TIME') { if (this.minMinutes > 1) { return 'Tip ' + (this.minutePrice * this.minMinutes) + 'tk to join and ' + this.minutePrice + 'tk/min for extra time!'; } else { return 'Tip ' + this.minutePrice + 'tk/min to watch!'; } } else if (this.botMode == 'NONE') { return 'This is a ONE to ONE show, please FOLLOW me. I will be right back!'; } }, /** * Sends the Secret Show notifier */ displayShowNotice: function() { if (cb.limitCam_isRunning()) { var msg = this.noticeMessage + ' ' + this.getPriceText(); msg = msg.replace('{time}', utils.getElapsedTime(this.startTime)); // Random delay -10 to +10s var delay = (Math.floor(Math.random() * 20) - 10) * 1000; utils.roomNotice(msg); var userList = cb.limitCam_allUsersWithAccess(); utils.modelNotice(userList.length + " user(s) in Secret Show: " + cbjs.arrayJoin(userList, ", ").replace(this.sysbot, this.modelName)); this.timeoutID = cb.setTimeout(this.displayShowNotice.bind(this), (this.noticeTimer * 60000) + delay); } else { this.timeoutID = 0; } }, /** * Adds viewing time to a user */ addMinutesToUser: function(name, minutes, is_anon) { if (!this.userInSecretShow(name)) { if (minutes < this.minMinutes) { utils.userNotice(name, 'The minimum tip to enter the Secret Show is ' + (this.minMinutes * this.minutePrice) + 'tk.'); return; } var nowDate = new Date(); this.userTimes[name] = { endTime: nowDate.addSeconds(parseInt(minutes) * 60), ticks: 0, savedTime: 0 }; this.addUserToShow(name, is_anon); } else { if (this.userTimes[name]) { this.userTimes[name].endTime = this.userTimes[name].endTime.addMinutes(minutes); this.userTimes[name].ticks = 0; utils.roomInfoNotice(BSTAR + ' ' + (is_anon ? 'anonymous user' : name) + ' tipped for ' + minutes + ' minute' + (minutes > 1 ? 's' : '') + ' more of Secret Show'); } else { // User has full access so no time to add return; } } utils.userNotice(name, this.botTimerIcon + ' You have [ ' + utils.getTimeLeft(this.userTimes[name].endTime) + ' ] of viewing time.', this.botTimeLeftColor); }, /** * Save the total time left for a future show */ saveTimeFromUsers: function() { var total = 0; var nowDate = new Date(); for (var user in this.userTimes) { if (this.userTimes[user].endTime.getTime() > nowDate.getTime()) { this.userTimes[user].savedTime = utils.getSecondsLeft(this.userTimes[user].endTime); utils.userNotice(user, this.botTimerIcon + ' You have [ ' + utils.getTimeLeft(this.userTimes[user].endTime).trim() + ' ] of viewing time for the next show.', this.botTimeLeftColor); total++; } else { delete this.userTimes[user]; } } return total; }, /** * Restore the times remaining of all users, setting their new endTime */ restoreTimeFromUsers: function() { for (var user in this.userTimes) { var nowDate = new Date(); if (this.userTimes[user].savedTime > 0) { var newTime = parseInt(this.userTimes[user].savedTime); this.userTimes[user] = { endTime: nowDate.addSeconds(newTime), ticks: 0, savedTime: 0 }; utils.userNotice(user, this.botTimerIcon + ' You have [ ' + utils.getTimeLeft(this.userTimes[user].endTime) + ' ] of viewing time.', this.botTimeLeftColor); } } }, /** * Remove all viewers with time remaining */ removePayPerMinuteUsers: function() { for (var user in this.userTimes) { if (cb.limitCam_userHasAccess(user)) { cb.limitCam_removeUsers(user); } } }, /** * Remove all users with full show access */ removeFullShowUsers: function() { var allUsers = cb.limitCam_allUsersWithAccess(); var usersToRemove = []; for (var i = 0; i < allUsers.length; i++) { if (!this.userTimes.hasOwnProperty(allUsers[i])) { usersToRemove.push(allUsers[i]); } } for (var i = 0; i < usersToRemove.length; i++) cb.limitCam_removeUsers(usersToRemove[i]); return usersToRemove.length; }, /** * Removes users with no time remaining * Sends a notification with time left */ refreshUsers: function() { if (cb.limitCam_isRunning()) { var nowDate = new Date(); for (var user in this.userTimes) { if (this.userTimes[user].endTime.getTime() <= nowDate.getTime()) { this.removeUserFromShow(user); } else { if (utils.getMinutesLeft(this.userTimes[user].endTime) < 1) { if (this.userTimes[user].ticks > 0) { utils.userNotice(user, this.botTimerIcon + ' Less than 1 min of viewing time. Tip a multiple of ' + this.minutePrice + ' to continue watching!', this.botTimeLeftColor); this.userTimes[user].ticks = 0; } } else { // Notify only after 8 refresh times this.userTimes[user].ticks++; if (this.userTimes[user].ticks % 8 == 0) { utils.userNotice(user, this.botTimerIcon + ' You have [ ' + utils.getTimeLeft(this.userTimes[user].endTime) + ' ] of viewing time.', this.botTimeLeftColor); } } } } this.timeoutRefresh = cb.setTimeout(this.refreshUsers.bind(this), this.refreshInterval); } else { this.timeoutRefresh = 0; } }, /* * Populates a choice setting * @index : Position in the settings array */ loadSettingChoices: function(itemList, index) { var count = 0; for (var item in itemList) { count++; cb.settings_choices[index]['choice' + count] = item; } }, /** * Testing with tips (format: tip username amount) */ tipTest: function(e) { var t = e.indexOf("tip"); if (-1 != t) { var n = utils.splitMe(e.substring(t)); if (3 == n.length) { var o = n[1], a = parseInt(n[2]); isNaN(a) || 0 >= a || this.onTip({ from_user: o, amount: a }); } } }, init: function() { // Add My Secret Show settings cb.settings_choices.push.apply(cb.settings_choices, this.settings_choices); //this.loadSettingChoices(utils.colorList, 0); this.loadSettingChoices(this.modeList, 0); //this.loadSettingChoices(this.levelList, 2); // Pick settings values this.parseSettings(); // Bot loaded messages utils.delayedNotice(this.botNoticeDelay, secretShow.botName + ' [Mode ' + cb.settings.secret_mode + ' ]', '', this.botTextColor, this.botBgColor, 'bold'); utils.delayedNotice(this.botNoticeDelay + 200, 'Type /sshelp to see all commands.', '', this.botBgColor, this.botTextColor, 'normal'); } } /** * Utils object */ var utils = { // Data colorList: { Amaranth: { code: '#c92572', bgcode: '#f9eaf1' }, Black: { code: '#000000', bgcode: '#e8e8e8' }, Blue: { code: '#4343e3', bgcode: '#e6ebff' }, LightBlue: { code: '#59aff8', bgcode: '#e1effb' }, SteelBlue: { code: '#859ebd', bgcode: '#edf1f9' }, DarkBlue: { code: '#161683', bgcode: '#e0e9ff' }, DarkBrown: { code: '#4c0017', bgcode: '#ede0e4' }, DeepPink: { code: '#FF1493', bgcode: '#ffedf7' }, BrownRed: { code: '#b31313', bgcode: '#fbe9e9' }, DarkOrange: { code: '#dc5500', bgcode: '#f9efe8' }, DarkViolet: { code: '#8600b3', bgcode: '#efdff4' }, Eucalyptus: { code: "#2B886D", bgcode: '#dde5e3' }, SeanceViolet: { code: '#ba21bf', bgcode: '#ffdffe' }, Green: { code: '#327939', bgcode: '#e1f9e3' }, GreenYellow: { code: '#89d90a', bgcode: '#edfbd8' }, GoldYellow: { code: '#FFA500', bgcode: '#fffbe8' }, DarkGreen: { code: '#436446', bgcode: '#e4ede5' }, CeriseRed: { code: '#e32370', bgcode: '#ffeef5' }, Pink: { code: '#F77FBE', bgcode: '#FCEFF6' }, RosePink: { code: '#FF00BA', bgcode: '#ffe8f9' }, Olive: { code: '#9FA64E', bgcode: '#F7F8EB' }, Purple: { code: '#800080', bgcode: '#f1e4f1' }, Red: { code: '#ff3232', bgcode: '#ffe5e5' }, SlateGray: { code: '#708090', bgcode: '#edf1f4' }, Turquoise: { code: '#1ba0a2', bgcode: '#e2f6f6' }, }, // Methods getColorCode: function(name) { return (this.colorList[name] ? this.colorList[name].code : '#000000'); }, getBgColorCode: function(name) { return (this.colorList[name] ? this.colorList[name].bgcode : '#FFFFFF'); }, isHexColor: function(code) { return /^#[0-9A-F]{6}$/i.test(code); }, splitMe: function(e) { return e.trim().replace(/\s+/g, " ").split(" ") }, /* * Replaces $ in a text depending on whether the num parameter is greater than 1 or not */ pluralExp(num, text) { return num + ' ' + text.replace('$', (num > 1 ? 's' : '')); }, /** * Create array with all elements in the string @strlist with separator "," * @flagSpaces: Spaces allowed inside elements when true * set it TRUE for nicknames and similars, * skip it for expressions with spaces. */ settingsListToArray: function(strList, flagSpaces) { // Trim string and inner items strList = strList.trim() strList = strList.replace(/[ ]+,|,[ ]+/g, ','); // Remove empty items and commas at the end strList = strList.replace(/[,]+/g, ','); strList = strList.replace(/(,+$)/g, ''); // If spaces are not allowed inside items, replace with separator if (!flagSpaces) { strList = strList.replace(/ /g, ','); } return (strList.split(',')); }, /** * Returns the time from a Date object in a string format: 1h 2mins 45secs */ timeToString: function(date) { var out = ''; if (date.getHours()) out += date.getHours() + 'h'; if (date.getMinutes()) { out += ' ' + date.getMinutes(); out += (date.getMinutes() > 1) ? 'mins' : 'min'; } if (date.getSeconds()) { out += ' ' + date.getSeconds(); out += (date.getSeconds() > 1) ? 'secs' : 'sec'; } return out; }, /** * Returns a string with the time elapsed since a date value */ getElapsedTime: function(startTime) { var elapsedSeconds = this.getElapsedSeconds(startTime); var date = new Date(elapsedSeconds * 1000); // Fix for date problem on cb that adds 17h for unknown reason (on testbed works fine) date.setHours(Math.floor(elapsedSeconds / 3600)); return this.timeToString(date); }, /** * Returns a string with the time left to reach a date value */ getTimeLeft: function(endTime) { var secondsLeft = this.getSecondsLeft(endTime); var date = new Date(secondsLeft * 1000); // Fix for date problem on cb that adds 17h for unknown reason (on testbed works fine) date.setHours(Math.floor(secondsLeft / 3600)); return this.timeToString(date); }, /** * Returns elapsed time since a date, in seconds */ getElapsedSeconds: function(date) { var now = Date.now(); var elapsed = Math.floor((now - date) / (1000)); return elapsed; }, /** * Returns time left for a date, in minutes */ getMinutesLeft: function(date) { var now = Date.now(); var left = Math.floor((date - now) / 60000); return left; }, /** * Returns time left for a date, in seconds */ getSecondsLeft: function(date) { var now = Date.now(); var left = Math.floor((date - now) / 1000); return left; }, /** * Return parameter in a certain position in a string */ getParam: function(msg, position) { var tmp = msg.split(' '); return tmp[position]; }, /** * Send notifications */ userNotice: function(user, msg, color, bgcolor, weight, group) { if (msg) { cb.sendNotice(msg, user, (bgcolor ? bgcolor : '#FFFFFF'), (color ? color : secretShow.botTextColor), (weight ? weight : 'bold'), group); } }, modelNotice: function(msg, color, bgcolor, weight) { this.userNotice(cb.room_slug, msg, color, bgcolor, (weight ? weight : 'bold')); }, groupNotice: function(group, msg, color, bgcolor, weight) { this.userNotice('', msg, color, bgcolor, weight, group); }, roomNotice: function(msg, color, bgcolor, weight) { this.userNotice('', msg, (color ? color : secretShow.botTextColor), (bgcolor ? bgcolor : secretShow.botBgColor), (weight ? weight : 'bold')); }, roomInfoNotice: function(msg, color, bgcolor, weight) { this.userNotice('', msg, (color ? color : secretShow.botBgColor), (bgcolor ? bgcolor : secretShow.botTextColor), (weight ? weight : 'bold')); }, /** * Send delayed notice * @msg: message to send * @target: send the notice to this target * @delay: delay time in miliseconds * @weight: font weight * @group: send to group of users * */ delayedNotice: function(delay, msg, target, bgcolor, fgcolor, weight, group) { if (msg && Number.isInteger(delay) && delay > 0) { // Send Notice setTimeout(function() { cb.sendNotice(msg, target, bgcolor, fgcolor, weight, group); }, delay); return true; } else { return false; } } } // Chaturbate stuff cb.onMessage(function(msg) { return secretShow.onMessage(msg); }); cb.onTip(function(tip) { secretShow.onTip(tip); }); cb.onEnter(function(user) { secretShow.onEnter(user); }); cb.settings_choices = []; // Load me! secretShow.init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.