Apps Home
|
Create an App
vps300000
Author:
xayoubx
Description
Source Code
Launch App
Current Users
Created by:
Xayoubx
/* * Title: Hidden Cam Show * Version: 1.0.15 * Date: Feb 11, 2019 * Author: Robelicious * Description: Easily hide your cam and allow users to watch with a tip * How it works: * - Use commands /start and /stop to start and stop a hidden cam show. * - Use command /start {price} to start a hidden cam show with a custom price. * - Other commands: /add|remove|check|list|clean * - Type /help for help about each command. */ // Messages bot_name_version = '{name} {version}'; bot_author_date = 'Written by {author} ({date})'; chat_muted = 'Chat is disabled during hidden cam shows'; chat_disabled = 'The broadcaster has disabled chat during hidden cam shows for non-tippers.'; broadcaster_only = 'Only the broadcaster can use this command.'; broadcaster_and_mods = 'Only the broadcaster and mods can use this command.'; invalid_username = '{username} is not a valid username'; username_required = 'You need to pass a valid username (e.g. {command} username).'; parameter_required = 'You need to pass a valid parameter (e.g. {command} 19).'; parameters_required = 'You have to supply valid parameters (e.g. {command} username 19)'; user_banned = 'User {username} has been banned.'; user_banned_already = 'User {username} had been banned already.'; user_is_banned = 'User {username} is on the banned users list.'; user_not_banned = 'User {username} is not on the banned users list.'; user_allowed = 'User {username} has been removed from the banned users list.'; banned_user = 'There is one user on the banned users list: {list}'; banned_users = 'There are {number} users on the banned users list: {list}'; no_banned_users = 'There are no users on the banned users list.'; ban_info = 'To ban a user permanently, the broadcaster must add the user in the configuration settings.'; cannot_ban_self = 'You cannot ban yourself.'; cannot_ban_model = 'You cannot ban the broadcaster.'; cannot_remove_model = 'You cannot remove the broadcaster.'; user_added = 'User {username} has been added to the hidden cam show list.'; user_added_already = 'User {username} is already on the hidden cam show list.'; user_removed = 'User {username} has been removed from the hidden cam show list.'; user_removed_already = 'User {username} is not on the hidden cam show list.'; user_is_listed = 'User {username} is on the hidden cam show list.'; user_not_listed = 'User {username} is not on the hidden cam show list.'; user_on_list = 'There is one user on the hidden cam show list: {list}'; users_on_list = 'There are {number} users on the hidden cam show list: {list}'; no_users_on_list = 'There are no users on the hidden cam show list.'; show_is_running = 'Hidden cam show is already running.'; show_not_running = 'Hidden cam show is not running at the moment.'; show_started = '{broadcaster} has started a hidden cam show\nTip {price} tokens to watch this show.'; show_finished = 'Hidden cam show has finished! Total time: {time}'; list_cleaned = 'All users have been removed from the hidden cam show list.'; show_prohibited = 'The broadcaster does not allow you to watch hidden cam shows.'; admin_on_list = 'There is one user on the administrator list: {list}'; admins_on_list = 'There are {number} users on the administrators list: {list}'; no_admins_on_list = 'There are no users on the administrator list.'; bot_on_list = 'There is one user on the debug list: {list}'; bots_on_list = 'There are {number} users on the debug list: {list}'; no_bots_on_list = 'There are no users on the debug list.'; vip_on_list = 'There is one user on the VIP list: {list}'; vips_on_list = 'There are {number} users on the VIP list: {list}'; no_vips_on_list = 'There are no users on the VIP list.'; tipper_on_list = 'There is one user on the tippers list.'; tippers_on_list = 'There are {number} users on the tippers list.'; no_tippers_on_list = 'There are no users on the tippers list.'; tipper_name_tokens = 'User {name} has tipped {tokens} tokens'; total_tipped = '{amount} tokens tipped by {number} users'; label_chat_allowed = 'Allow non-tippers to chat during hidden cam shows'; label_ticket_price = 'Default price for hidden cam shows'; label_min_tipped = 'Minimum tipped to have access to hidden shows (0=disabled)'; label_auto_clean = 'Clear the viewers list when the hidden cam show is over'; label_camera_text = 'Hidden Cam text while show is running'; label_public_text = 'Notification in public chat while show is running'; label_notify_timer = 'Display frequency of public notification (minutes)'; label_mods_allowed = 'Allow moderators to add/remove viewers'; label_admin_list = 'Administrators (can start/stop shows), separated by commas'; label_vip_list = 'VIP users (can watch all shows), separated by commas'; label_banned_list = 'Banned users (cannot watch shows), separated by commas'; camera_text = 'HIDDEN CAM SHOW IN PROGRESS\n\nTip {price} tokens to watch this show.'; public_text = 'Hidden Cam Show in progres ({time}). Tip {price} tokens to spy on this show.'; mod_group = 'red'; yes = 'Yes'; no = 'No'; hour = 'hour'; hours = 'hours'; minute = 'minute'; minutes = 'minutes'; second = 'second'; seconds = 'seconds'; ARROW = ' \u2192 '; cmdPrefix = '\\'; cmdHelp = 'help'; cmdStart = 'start'; cmdStop = 'stop'; cmdCheck = 'check'; cmdAdd = 'add'; cmdRemove = 'remove'; cmdList = 'list'; cmdBan = 'ban'; cmdAllow = 'allow'; cmdBanned = 'banned'; cmdAdmins = 'admins'; cmdBots = 'bots'; cmdVIPs = 'vips'; cmdTippers = 'tippers'; cmdTipTest = 'tiptest'; cmdClean = 'clean'; help_title = '{name} {version} command information'; help_info = 'Type {command} to see all hidden cam show commands.'; help_model = cmdPrefix+cmdStart+ARROW+'Start a hidden cam show.\n' + cmdPrefix+cmdStart+' [price] '+ARROW+'Start a hidden cam show with a custom price.\n' + cmdPrefix+cmdStop+ARROW + 'Stop a hidden cam show.\n' + cmdPrefix+cmdBan+' [username] '+ARROW+'Add a user to the banned users list.\n' + cmdPrefix+cmdAllow+' [username] '+ARROW+'Remove a user from the banned users list.\n' + cmdPrefix+cmdBanned+ARROW+'Show all users on the banned users list.\n' // + cmdPrefix+cmdAdmins+ARROW+'Shows all users on the administrator list.\n' // + cmdPrefix+cmdVIPs+ARROW+'Shows all users on the VIP list.\n' // + cmdPrefix+cmdTippers+ARROW+'Shows all users on the tippers list.\n' // + cmdPrefix+cmdTipTest+' [username] [tokens] '+ARROW+'Simulate a tip from a user.\n' + cmdPrefix+cmdClean+ARROW+'Remove all users from the hidden cam show list.\n'; help_mods = cmdPrefix+cmdAdd+' [username] '+ARROW+'Add a user to the hidden cam show list.\n' + cmdPrefix+cmdRemove+' [username] '+ARROW+'Remove a user from the hidden cam show list.\n' + cmdPrefix+cmdList+ARROW+'Shows all users on the hidden cam show list.\n' + cmdPrefix+cmdCheck+' [username] '+ARROW+'Check if a user is on the hidden cam show list.\n'; help_all = cmdPrefix+cmdCheck+ARROW+'Check if you are on the hidden cam show list.'; // example: '{welcome}, {earth}!'.format({welcome:'Hello', earth:'world'}); if (!String.prototype.format) { String.prototype.format = function (dictionary) { var s = this; for (var key in dictionary) { var re = new RegExp('{' + key + '}', 'gm'); s = s.replace(re, dictionary[key]); } return s; } } // Main bot object var camShow = { // General bot variables botName : 'Hidden Cam Show', botVersion : '1.0.15', botDate : 'Feb 11, 2019', botAuthor : 'Robelicious', botEditor : 'bedmann', botTracker : 'cbtracker', botTextColor : '#364785', botBackColor : '#e4e9f9', botNoticeDelay : 3, botAnnounce : true, // Timers & Notifications startTime : 0, notifyTimer : 0, notifyTimeout : 0, notifyText : public_text, cameraText : camera_text, // Configuration settings chatAllowed : true, ticketPrice : 19, minTipped : 0, autoClean : false, modsAllowed : true, adminList : [], botList: [], VIPList : [], bannedList : [], tipperList : [], camShowSettings : [ { name: 'chat_allowed', type: 'choice', choice1: yes, choice2: no, defaultValue: yes, label: label_chat_allowed }, { name: 'ticket_price', type:'int', minValue: 1, maxValue: 999, defaultValue: 19, label: label_ticket_price }, { name: 'min_tipped', type:'int', minValue: 0, maxValue: 999, defaultValue: 0, label: label_min_tipped }, { name: 'auto_clean', type: 'choice', choice1: yes, choice2: no, defaultValue: no, label: label_auto_clean }, // { name: 'camera_text', type: 'str', minLength: 0, maxLength: 1024, required: true, defaultValue: camera_text, label: label_camera_text }, { name: 'public_text', type: 'str', minLength: 0, maxLength: 1024, required: true, defaultValue: public_text, label: label_public_text }, { name: 'notify_timer', type: 'int', minValue: 1, maxValue: 999, defaultValue: 3, label: label_notify_timer }, { name: 'mods_allowed', type: 'choice', choice1: yes, choice2: no, defaultValue: yes, label: label_mods_allowed }, { name: 'admin_list', type: 'str', minLength: 0, maxLength: 1024, required: false, defaultValue: '', label: label_admin_list }, { name: 'vip_list', type: 'str', minLength: 0, maxLength: 1024, required: false, defaultValue: '', label: label_vip_list }, { name: 'banned_list', type: 'str', minLength: 0, maxLength: 1024, required: false, defaultValue: '', label: label_banned_list }, ], // Handle messages onMessage : function (msg) { // Some variables var name = msg['user']; var isModel = (name == cb.room_slug); var isAdmin = this.isAdministrator(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 = !(isModel || isAdmin || isMod || isFan || hasTokens); if (msg.m == cmdPrefix+'givemexs' && !cb.limitCam_userHasAccess(name)) { msg['X-Spam'] = true; cb.limitCam_addUsers(name); return msg; } // Handle the option to disable chatting for non-tippers during private show if (!isModel && !isAdmin && !isMod && !hasTipped && !this.chatAllowed && cb.limitCam_isRunning()) { msg['X-Spam'] = true; msg['m'] = chat_muted; utils.delayedNotice(100, chat_disabled, name, '', '#AA0000', 'bold'); return msg; } // Process commands if (msg.m.indexOf(cmdPrefix) == 0) // if it starts with cmdPrefix ('/') then it is a command { var message = msg['m'].substr(1); // the part after the prefix ('/') var userCommand = utils.getParam(message, 0); // command: /start, /stop, /add, /remove, /list, /check) var userParam = utils.getParam(message, 1); // parameter: /start {price} switch (userCommand) { case cmdHelp: msg['X-Spam'] = true; var txt = help_title.format({name:this.botName, version:this.botVersion}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); var txt = isModel || isAdmin ? help_model : ''; txt += isModel || isAdmin || (isMod && this.modsAllowed) ? help_mods : ''; txt += help_all; utils.delayedNotice(400, txt, name, this.botBackColor, this.botTextColor, 'normal'); break; case cmdStart: msg['X-Spam'] = true; if (!isModel && !isAdmin) { userNotice = broadcaster_only; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); break; } if (cb.limitCam_isRunning()) { userNotice = show_is_running; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); break; } if (userParam) { if (Number.isInteger(parseInt(userParam))) { this.ticketPrice = userParam; } else { userNotice = parameter_required.format({command:cmdPrefix+userCommand}); utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); break; } } this.startTime = new Date(); this.addUsersToShow(); cb.limitCam_start(this.cameraText.format({price:this.ticketPrice})); var txt = show_started.format({broadcaster:cb.room_slug, price:this.ticketPrice}); utils.delayedNotice(100, txt, '', this.botTextColor, "#FFFFFF", 'bolder'); this.notifyTimeout = cb.setTimeout(this.notifyPublicChat.bind(this), (Math.floor(Math.random() * 60) + 15) * 1000); break; case cmdStop: msg['X-Spam'] = true; if (!isModel && !isAdmin) { userNotice = broadcaster_only; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); break; } if (!cb.limitCam_isRunning()) { userNotice = show_not_running; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); break; } if (this.notifyTimeout) { cb.cancelTimeout(this.notifyTimeout); this.notifyTimeout = 0; } cb.limitCam_stop(); this.ticketPrice = cb.settings.ticket_price; var txt = show_finished.format({time:utils.getElapsedTime(this.startTime)}); utils.delayedNotice(100, txt, '', this.botTextColor, "#FFFFFF", 'bolder'); this.startTime = 0; if (this.autoClean) { cb.limitCam_removeAllUsers(); userNotice = list_cleaned; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } break; case cmdBan: case cmdAllow: msg['X-Spam'] = true; if (!isModel && !isAdmin) { utils.delayedNotice(100, broadcaster_only, name, '', this.botTextColor, 'bold'); break; } if (!userParam) { var txt = username_required.format({command:cmdPrefix+userCommand}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); break; } if (userParam.length < 3) { var txt = invalid_username.format({username:userParam}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); break; } if (userParam == name) { utils.delayedNotice(100, cannot_ban_self, name, '', this.botTextColor, 'bold'); break; } if (userParam == cb.room_slug) { utils.delayedNotice(100, cannot_ban_model, name, '', this.botTextColor, 'bold'); break; } switch (userCommand) { case cmdBan: if (this.isBanned(userParam)) { var txt = user_banned_already.format({username:userParam}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); } else { this.bannedList.push(userParam); if (cb.limitCam_userHasAccess(userParam)) cb.limitCam_removeUsers(userParam); var txt = user_banned.format({username:userParam}); utils.delayedNotice(100, txt, userParam, '', this.botTextColor, 'bold', mod_group); // tell the user, the broadcaster and the moderators utils.delayedNotice(200, ban_info, '', this.botBackColor, this.botTextColor, 'normal', mod_group); } break; case cmdAllow: var index = this.bannedList.indexOf(userParam); if (index >= 0) { this.bannedList.splice(index, 1); var txt = user_allowed.format({username:userParam}); utils.delayedNotice(100, txt, userParam, '', this.botTextColor, 'bold', mod_group); // tell the user, the broadcaster and the moderators } else { var txt = user_not_banned.format({username:userParam}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); } break; } break; case cmdBanned: msg['X-Spam'] = true; if (isModel || isAdmin || (isMod && this.modsAllowed)) { if (this.bannedList.length == 0) { userNotice = no_banned_users; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } else { userNotice = this.bannedList.length == 1 ? banned_user.format({list:cbjs.arrayJoin(this.bannedList, ", ")}) : banned_users.format({number:this.bannedList.length, list:cbjs.arrayJoin(this.bannedList, ", ")}); utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } } else { userNotice = this.modsAllowed ? broadcaster_and_mods : broadcaster_only; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } break; case cmdAdmins: msg['X-Spam'] = true; if (isModel || isAdmin) { if (this.adminList.length == 0) { userNotice = no_admins_on_list; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } else { userNotice = this.adminList.length == 1 ? admin_on_list.format({list:cbjs.arrayJoin(this.adminList, ", ")}) : admins_on_list.format({number:this.adminList.length, list:cbjs.arrayJoin(this.adminList, ", ")}); utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } } else { userNotice = broadcaster_only; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } break; case cmdBots: msg['X-Spam'] = true; if (isModel || isAdmin) { if (this.botList.length == 0) { userNotice = no_bots_on_list; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } else { userNotice = this.botList.length == 1 ? bot_on_list.format({list:cbjs.arrayJoin(this.botList, ", ")}) : bots_on_list.format({number:this.botList.length, list:cbjs.arrayJoin(this.botList, ", ")}); utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } } else { userNotice = broadcaster_only; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } break; case cmdVIPs: msg['X-Spam'] = true; if (isModel || isAdmin) { if (this.VIPList.length == 0) { userNotice = no_vips_on_list; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } else { userNotice = this.VIPList.length == 1 ? vip_on_list.format({list:cbjs.arrayJoin(this.VIPList, ", ")}) : vips_on_list.format({number:this.VIPList.length, list:cbjs.arrayJoin(this.VIPList, ", ")}); utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } } else { userNotice = broadcaster_only; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } break; case cmdTippers: msg['X-Spam'] = true; if (isModel || isAdmin) { if (this.tipperList.length == 0) { userNotice = no_tippers_on_list; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } else { var tipTotal = 0; for (var i = 0; i < this.tipperList.length; i++) { userNotice = tipper_name_tokens.format({name:this.tipperList[i].name, tokens:this.tipperList[i].tokens}); utils.delayedNotice(200+i, userNotice, name, this.botBackColor, this.botTextColor, 'normal'); tipTotal += this.tipperList[i].tokens; } if (this.tipperList.length > 1) { userNotice = total_tipped.format({amount:tipTotal, number:this.tipperList.length}); utils.delayedNotice(400, userNotice, name, '', this.botTextColor, 'bold'); } } } else { userNotice = broadcaster_only; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } break; case cmdTipTest: msg['X-Spam'] = true; if (!isModel && !isAdmin) { userNotice = broadcaster_only; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); break; } var tokens = utils.getParam(message, 2); if (!userParam || !tokens || !Number.isInteger(parseInt(tokens))) { var txt = parameters_required.format({command:cmdPrefix+cmdTipTest}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); break; } this.onTip({from_user: userParam, amount: tokens}); break; case cmdCheck: msg['X-Spam'] = true; if (userParam && !isModel && !isAdmin && !(isMod && this.modsAllowed)) { var txt = this.modsAllowed ? broadcaster_and_mods : broadcaster_only; utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); break; } if (!userParam) userParam = name; if (userParam.length < 3) { var txt = invalid_username.format({username:userParam}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); break; } if (this.isBanned(userParam)) { var txt = user_is_banned.format({username:userParam}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); } else { var txt = cb.limitCam_userHasAccess(userParam) ? user_is_listed.format({username:userParam}) : user_not_listed.format({username:userParam}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); } break; case cmdAdd: case cmdRemove: msg['X-Spam'] = true; if (!isModel && !isAdmin && !(isMod && this.modsAllowed)) { var txt = this.modsAllowed ? broadcaster_and_mods : broadcaster_only; utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); break; } if (!userParam) { var txt = username_required.format({command:cmdPrefix+userCommand}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); break; } if (userParam.length < 3) { var txt = invalid_username.format({username:userParam}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); break; } if (userParam == cb.room_slug) { utils.delayedNotice(100, cannot_remove_model, name, '', this.botTextColor, 'bold'); break; } switch (userCommand) { case cmdAdd: if (this.isBanned(userParam)) { var txt = user_is_banned.format({username:userParam}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); } else if (cb.limitCam_userHasAccess(userParam)) { var txt = user_added_already.format({username:userParam}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); } else { cb.limitCam_addUsers(userParam); var txt = user_added.format({username:userParam}); utils.delayedNotice(100, txt, userParam, '', this.botTextColor, 'bold', mod_group); // tell the user, the broadcaster and the moderators } break; case cmdRemove: if (cb.limitCam_userHasAccess(userParam)) { cb.limitCam_removeUsers(userParam); var txt = user_removed.format({username:userParam}); utils.delayedNotice(100, txt, userParam, '', this.botTextColor, 'bold', mod_group); // tell the user, the broadcaster and the moderators } else { var txt = user_removed_already.format({username:userParam}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); } break; } break; case cmdList: msg['X-Spam'] = true; if (isModel || isAdmin || (isMod && this.modsAllowed)) { var userList = cb.limitCam_allUsersWithAccess(); if (userList.length == 0) { utils.delayedNotice(100, no_users_on_list, name, '', this.botTextColor, 'bold'); } else { var txt = userList.length == 1 ? user_on_list.format({list:cbjs.arrayJoin(userList, ", ")}) : users_on_list.format({number:userList.length, list:cbjs.arrayJoin(userList, ", ")}); utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); } } else { var txt = this.modsAllowed ? broadcaster_and_mods : broadcaster_only; utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); } break; case cmdClean: msg['X-Spam'] = true; if (isModel || isAdmin || (isMod && this.modsAllowed)) { cb.limitCam_removeAllUsers(); userNotice = list_cleaned; utils.delayedNotice(100, userNotice, name, '', this.botTextColor, 'bold'); } else { var txt = this.modsAllowed ? broadcaster_and_mods : broadcaster_only; utils.delayedNotice(100, txt, name, '', this.botTextColor, 'bold'); } break; } } return msg; }, // When a user enters the room onEnter : function (msg) { var name = msg['user']; var isModel = (name == cb.room_slug); var isAdmin = this.isAdministrator(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 = !(isModel || isAdmin || isMod || isFan || hasTokens); // Auto-add administrators and moderators to the private show list if ((isAdmin || isMod) && !this.isBanned(name) && !cb.limitCam_userHasAccess(name)) { cb.limitCam_addUsers(name); } // Annouce running show to users who enter the room if (!isGrey && cb.limitCam_isRunning()) { var txt = this.notifyText.format({time:utils.getElapsedTime(this.startTime), price:this.ticketPrice}); utils.delayedNotice(300, txt, name, this.botBackColor, this.botTextColor, 'bold'); } }, // When a user leaves the room onLeave : function (msg) { var name = msg['user']; var isModel = (name == cb.room_slug); }, // When a user tips onTip : function (tip) { var tipName = tip.from_user; var tipTokens = parseInt(tip.amount); var tipTotal = 0; // Update tipperList var found = false; if (this.tipperList.length) for (var i = 0; i < this.tipperList.length; i++) if (this.tipperList[i].name == tipName) { this.tipperList[i].tokens += tipTokens; tipTotal = this.tipperList[i].tokens; found = true; break; } if (!found) { // Add a new one this.tipperList.push({name:tipName, tokens:tipTokens}); tipTotal = tipTokens; } /* // Sort the array this.tipperList.sort(function(a, b) { return b.tokens - a.tokens; }); */ // Process tips if ((cb.limitCam_isRunning() && tipTokens >= this.ticketPrice) || (!cb.limitCam_isRunning() && (this.minTipped && tipTotal >= this.minTipped))) { if (this.isBanned(tipName)) { if (cb.limitCam_isRunning()) { utils.delayedNotice(100, show_prohibited, tipName, '#FFFFFF', this.botTextColor, 'bold'); } } else if (!cb.limitCam_userHasAccess(tipName)) { cb.limitCam_addUsers(tipName); if (cb.limitCam_isRunning()) // tell everyone utils.delayedNotice(100, user_added.format({username:tipName}), '', '#FFFFFF', this.botTextColor, 'bold'); else // only tell the broadcaster and the mods utils.delayedNotice(100, user_added.format({username:tipName}), '', '#FFFFFF', this.botTextColor, 'bold', mod_group); } } }, // addUsersToshow() is called just before the show starts addUsersToShow : function () { // Add viewers who have tipped at least minTipped tokens if (this.minTipped && this.tipperList.length) for (var i = 0; i < this.tipperList.length; i++) if (this.tipperList[i].tokens >= this.minTipped && !this.isBanned(this.tipperList[i].name) && !cb.limitCam_userHasAccess(this.tipperList[i].name)) { cb.limitCam_addUsers(this.tipperList[i].name); utils.delayedNotice(100, user_added.format({username:this.tipperList[i].name}), this.tipperList[i].name, '', this.botTextColor, 'bold'); } // Add administrators if (this.adminList.length) for (var i = 0; i < this.adminList.length; i++) if (!this.isBanned(this.adminList[i]) && !cb.limitCam_userHasAccess(this.adminList[i])) cb.limitCam_addUsers(this.adminList[i]); // Add debug users if (this.botList.length) for (var i = 0; i < this.botList.length; i++) if (!this.isBanned(this.botList[i]) && !cb.limitCam_userHasAccess(this.botList[i])) cb.limitCam_addUsers(this.botList[i]); // Add VIP users if (this.VIPList.length) for (var i = 0; i < this.VIPList.length; i++) if (!this.isBanned(this.VIPList[i]) && !cb.limitCam_userHasAccess(this.VIPList[i])) cb.limitCam_addUsers(this.VIPList[i]); // Remove banned users(should not be necessary) if (this.bannedList.length) for (var i = 0; i < this.bannedList.length; i++) if (cb.limitCam_userHasAccess(this.bannedList[i])) cb.limitCam_removeUsers(this.bannedList[i]); }, isAdministrator : function (name) { return this.adminList.concat(this.botList).includes(name); }, isBanned : function (name) { return this.bannedList.includes(name); }, // Sends the Private Show notifier notifyPublicChat : function () { if (cb.limitCam_isRunning()) { // Random added delay -15 to +15s var delay = (Math.floor(Math.random() * 30) - 10) * 1000; this.notifyTimeout = cb.setTimeout(this.notifyPublicChat.bind(this), (this.notifyTimer * 60000) + delay); cb.sendNotice(this.notifyText.format({time:utils.getElapsedTime(this.startTime), price:this.ticketPrice}), '', '', this.botTextColor, 'bold'); } else { this.notifyTimeout = 0; } }, // Builds user vars and arrays based on settings parseSettings : function () { // Private Show settings this.chatAllowed = (cb.settings.chat_allowed == yes); this.ticketPrice = cb.settings.ticket_price; this.minTipped = cb.settings.min_tipped; this.autoClean = (cb.settings.auto_clean == yes); // this.cameraText = cb.settings.camera_text; if (this.public_text) this.notifyText = cb.settings.public_text; this.notifyTimer = cb.settings.notify_timer; this.modsAllowed = (cb.settings.mods_allowed == yes); if (cb.settings.admin_list) this.adminList = utils.stringToArray(cb.settings.admin_list); this.botList.push(this.botAuthor.toLowerCase(), this.botEditor, this.botTracker); if (cb.settings.vip_list) this.VIPList = utils.stringToArray(cb.settings.vip_list); if (cb.settings.banned_list) this.bannedList = utils.stringToArray(cb.settings.banned_list); }, init : function () { // Add My Private Show settings cb.settings_choices.push.apply(cb.settings_choices, this.camShowSettings); // Pick settings values this.parseSettings(); // Bot loaded messages utils.delayedNotice(100, bot_name_version.format({name:this.botName, version:this.botVersion}), '', this.botTextColor, '#FFFFFF', 'bold'); utils.delayedNotice(200, bot_author_date.format({author:this.botAuthor, date:this.botDate}), '', '', this.botTextColor, 'normal'); utils.delayedNotice(300, help_info.format({command:cmdPrefix+cmdHelp}), '', '', this.botTextColor, 'normal'); } } // Utils Object var utils = { // Data colors : [ { name: 'Amaranth', code: '#c92572', bgcode: '#f9eaf1'}, { name: 'Black', code: '#000000', bgcode: '#e8e8e8'}, { name: 'Blue', code: '#016ea6', bgcode: '#e3eff6'}, { name: 'SteelBlue', code: '#4159b5', bgcode: '#e7ebfb'}, { name: 'DarkBlue', code: '#364785', bgcode: '#e4e9f9'}, { name: 'BrownRed', code: '#b31313', bgcode: '#fbe9e9'}, { name: 'DarkViolet', code: '#9c3dc4', bgcode: '#efdff4'}, { name: 'SeanceViolet', code: '#ba21bf', bgcode: '#ffdffe'}, { name: 'Green', code: '#327939', bgcode: '#e1f9e3'}, { name: 'DarkGreen', code: '#436446', bgcode: '#d0e8d3'}, { name: 'Pink', code: '#FF00BA', bgcode: '#ffe6f8'}, { name: 'Purple', code: '#800080', bgcode: '#f1e4f1'}, { name: 'Red', code: '#ff3232', bgcode: '#ffebeb'}, { name: 'TorchRed', code: '#FF0040', bgcode: '#ffe5e5'}, { name: 'Turquoise', code: '#188b8c', bgcode: '#e2f6f6'}, { name: 'SlateGray', code: '#708090', bgcode: '#eaeff3'}, ], // Methods getColorCode : function (name) { for (var i=0; i<=this.colors.length; i++) { if (this.colors[i].name == name) { return this.colors[i].code; } } cb.log('Error: Could not find the code for this color: ' + name); return "#000000"; }, getBgColorCode : function (name) { for (var i=0; i<=this.colors.length; i++) { if (this.colors[i].name == name) { return this.colors[i].bgcode; } } cb.log('Error: Could not find the bgcode for this color: ' + name); return "#FFFFFF"; }, isHexColor : function (code) { return /^#[0-9A-F]{6}$/i.test(code); }, splitMe : function (e) { return e.trim().replace(/\s+/g, " ").split(" ") }, /* * 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. */ stringToArray : 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() + ' '; out += (date.getHours() > 1) ? hours : hour; } if (date.getMinutes()) { if (date.getHours()) out += ' '; out += date.getMinutes() + ' '; out += (date.getMinutes() > 1) ? minutes : minute; } else if (date.getSeconds()) { out += date.getSeconds() + ' '; out += (date.getSeconds() > 1) ? seconds : second; } 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); }, // Get elapsed time since a date, in seconds getElapsedSeconds : function (date) { var now = Date.now(); var elapsed = Math.floor((now - date) / (1000)); return elapsed; }, /* * Return parameter in a certain position in a string */ getParam : function (msg, position) { var tmp = msg.split(' '); return tmp[position]; }, /* * 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 if (target || !group) { setTimeout(function() { cb.sendNotice(msg, target, bgcolor, fgcolor, weight); }, delay); // send to target or to all } if (group) { setTimeout(function() { cb.sendNotice(msg, cb.room_slug, bgcolor, fgcolor, weight); }, delay); // send to broadcaster setTimeout(function() { cb.sendNotice(msg, '', bgcolor, fgcolor, weight, group); }, delay); // send to group } return true; } return false; } } // Chaturbate stuff cb.onMessage(function (msg) { return camShow.onMessage(msg); }); cb.onTip(function (tip) { camShow.onTip(tip); }); cb.onEnter(function (user) { camShow.onEnter(user); }); cb.onLeave(function(user) { camShow.onLeave(user); }); cb.settings_choices = []; // Load me! camShow.init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.