Bots Home
|
Create an App
JOKERS TIP TALK OR GO
Author:
joker_luciano
Description
Source Code
Launch Bot
Current Users
Created by:
Joker_Luciano
// Tip, Talk or Go! limitCam Bot // Author: mark54321 // Version: 1.0 // // This bot hides the broadcaster's camera from viewers that don't tip or talk within a configurable time period. // // Broadcasters may set: // * The time interval in which a viewer must have tipped or chatted // * An optional "guest list". This is a list of usernames that are automatically allowed to view the cam without restriction // * The broadcaster may allow specific viewers in at any time (add them to the guest list) and remove that status as well // * The broadcaster may limit the camera to only blues. Grays will not see the camera. Anonymous users will always be blocked // because they can neither chat nor tip. // * Whether or not mods are automatically on the guest list // * Whether or not fan club members are automatically on the guest list // * The broadcaster and mods may remove specific users at any time. This removes them from the camera feed without having to ban them. // * "Removed" users can be "unremoved" by the broadcaster or mods var tipTalkApp = function () { var appName = "Tip, Talk or Go!", self, users = {}, timerSet = false, timerInterval = 60000, timerCount = 0, bluesOnly, activityTimeInterval, allowList, modsExempt, fansExempt; // Fore- and background colors for different chot notices var msgColors = { info:{background: "#ffffff", color: "#000090", weight:"normal"}, notice:{background: "#00cccc", color: "#000000", weight:"normal"}, warn:{background: "#cc6600", color: "#ffffff", weight:"normal"}, important:{background: "#aa0303", color: "#ffffff", weight:"bold"}, entered: {background: "#03aa03", color: "#ffffff", weight:"normal"} }; var lineDelimiter = "################################################################################"; return { // Initializes the app // This should be called after the broadcaster settting have been made init: function () { // Get some settings activityTimeInterval = cb.settings.activityTimeInterval * 60; bluesOnly = cb.settings.bluesOnly === "Yes" ? true : false; allowList = cb.settings.allowList && cb.settings.allowList.length ? cb.settings.allowList.split(" ") : []; modsExempt = cb.settings.modsPay === "No" ? true : false; fansExempt = cb.settings.fansPay === "No" ? true : false; self.sendInfo(cb.room_slug + "'s " + appName + " started"); }, // Helper function to initialize the timer and auction time keeping initTimer: function () { // Start the timer if needed if (!timerSet) { cb.setTimeout(self.onTimer, timerInterval); timerSet = true; } }, // Sets up and returns the broadcaster bot settings template getSettingChoices: function () { self = this; return [ { name: 'hiddenCamMessage', label: 'Message displayed in the camera when the show is in progress', type: 'str', minLength: 1, maxLength: 256, defaultValue: appName + ' Contribute to the room by tipping or talking or be removed ;)' }, { name: "activityTimeInterval", label: "The time interval in minutes. Users must tip or chat within each interval or be cut off from the camera.", type: "choice", choice1: 1, choice2: 10, choice3: 15, choice4: 20, choice5: 25, choice6: 30, choice7: 45, choice8: 60, defaultValue: 10 }, { name: "bluesOnly", label: "Should grays be blocked?", type: "choice", choice1: "Yes", choice2: "No", defaultValue: "No" }, { name: 'allowList', label: 'Guest List. Enter the usernames, separated by a SPACE, of the users that are automatically allowed in. You can add others at any time with the /allow comand', type: 'str', minLength: 0, maxLength: 512, required: false }, { name: "modsPay", label: "Do the rules apply to Mods?", type: "choice", choice1: "Yes", choice2: "No", defaultValue: "No" }, { name: "fansPay", label: "Do the rules apply to Fan Club members?", type: "choice", choice1: "Yes", choice2: "No", defaultValue: "No" } ]; }, // Called when a tip has been sent. // If the user is already in the show, we update their tip total for the interval. // If the user is not in the show and there is no entry fee, or the tip // (or cumulative tips) covers the entry fee, add them. onTip: function (tip) { var user = null, msg = "", tipAmount = parseInt(tip.amount, 10); // Check if the user exists if (self.userExists(tip.from_user)) { if (users[tip.from_user].isRemoved) { // User was explicitly removed. Let them know msg = tip.from_user + ": Thank you for the tip but you have been explicitly removed by " + cb.room_slug; msg += ". Only " + cb.room_slug + " can allow you back in again."; self.sendNotice(msg, tip.from_user); } else { // Update the time and tip total users[tip.from_user].tips += tipAmount; users[tip.from_user].startTime = new Date().getTime(); // Add them in case limitCam is acting up self.addUser(tip.from_user, tip.from_user_is_mod, tip.from_user_in_fanclub, cbjs.arrayContains(allowList, tip.from_user)); } } else { // User does not exist. Add them user = self.addUser(tip.from_user, tip.from_user_is_mod, tip.from_user_in_fanclub, cbjs.arrayContains(allowList, tip.from_user)); } }, // Called when a message has been sent onMessage: function (msg) { // Is this a command? var parts = msg.m.split(" "), hideMessage = true; // Update mod/fan club member status in case somthing has // changed along the way. Add/Remove users as if (self.userExists(msg.user)) { cb.log("onMessage: user exists. Updating mod status"); users[msg.user].isMod = msg.is_mod; users[msg.user].isFan = msg.in_fanclub; } if (parts[0] === "/start") { self.handleStart(msg); } else if (parts[0] === "/stop") { self.handleStop(msg); } else if (parts[0] === "/allow") { self.handleAllow(msg); } else if (parts[0] === "/unallow") { self.handleUnallow(msg); } else if (parts[0] === "/remove") { self.handleRemove(msg); } else if (parts[0] === "/unremove") { self.handleUnremove(msg); } else if (parts[0] === "/list") { self.handleList(msg); } else if (parts[0] === "/stats") { self.handleStats(msg); } else if (parts[0] === "/rules") { self.showRules(msg); } else if (parts[0] === "/help") { // Output the help self.showHelp(msg); } else { if (msg.user === cb.room_slug) { // Don't keep track of the broadcaster hideMessage = false; } else if (self.userExists(msg.user)) { // User exists if (users[msg.user].isRemoved) { // User was explicitly removed. Let them know msg = msg.user + ": You have been explicitly removed by " + cb.room_slug; msg += ". Only " + cb.room_slug + " can allow you back in again."; self.sendNotice(msg, msg.user); } else { // Update the time and tip total users[msg.user].startTime = new Date().getTime(); // add them in case limitCam is acting up self.addUser(msg.user, msg.is_mod, msg.in_fanclub, cbjs.arrayContains(allowList, msg.user)); hideMessage = false; } } else if (bluesOnly) { // User needs to be exempt or some form of blue if (self.isUserExempt(msg.user, msg.is_mod, msg.in_fanclub) || msg.has_tokens || msg.tipped_recently) { user = self.addUser(msg.user, msg.is_mod, msg.in_fanclub, cbjs.arrayContains(allowList, msg.user)); hideMessage = false; } } else { // User does not exist. Add them user = self.addUser(msg.user, msg.is_mod, msg.in_fanclub, cbjs.arrayContains(allowList, msg.user)); hideMessage = false; } } if (hideMessage) { // Prevent the command from being output to chat msg['X-Spam'] = true; } return msg; }, onEnter: function (user) { if (user.user === cb.room_slug) { // Broadacaster so nothing to do cb.log("onEnter: Broadcaster entered. Doing nothing."); return; } cb.log("onEnter: User " + user.user + " entered."); // Check if the user exists if (self.userExists(user.user)) { if (users[user.user].isRemoved) { // User was explicitly removed. Make sure they can't see the cam if (cb.limitCam_userHasAccess(user.user)) { // Remove the user cb.limitCam_removeUsers([user.user]); } } else if (self.isUserExempt(user.user, user.is_mod, user.in_fanclub)) { self.addUser(user.user, user.is_mod, user.in_fanclub, cbjs.arrayContains(allowList, user.user)); } else if (self.hasTimeExpired(user)) { // User re-entered the room and time had expired // Don't just let them see the cam cb.log("onEnter: User " + user.user + ": Time expired"); if (cb.limitCam_userHasAccess(user.user)) { // Remove the user cb.limitCam_removeUsers([user.user]); } } } else if (bluesOnly) { // User needs to be exempt or some form of blue if (self.isUserExempt(user.user, user.is_mod, user.in_fanclub) || user.has_tokens || user.tipped_recently) { self.addUser(user.user, user.is_mod, user.in_fanclub, cbjs.arrayContains(allowList, user.user)); } } else { // User does not exist. Add them self.addUser(user.user, user.is_mod, user.in_fanclub, cbjs.arrayContains(allowList, user.user)); } }, // Try to shut things down when the broadcaster leaves onLeave: function (user) { if (user.user === cb.room_slug) { // The user and msg objects have the same properties so this is ok self.handleStop(user); } }, // For cases when the the show is restarted we want to reset the info for // all of the users currently in the cam list resetUsers: function () { var now = new Date().getTime(); var camUsers = cb.limitCam_allUsersWithAccess(); var camUser; for (var i = 0; i < camUsers.length; i++) { camUser = camUsers[i]; if (typeof users[camUser] !== "undefined") { users[camUser].startTime = now; } } }, // Handles the /start command. msg is the message object // passed in to onMessage. handleStart: function (msg) { if (msg.user === cb.room_slug && !cb.limitCam_isRunning()) { // Reset the user info if we're restarting // or people are already in the list if (cb.limitCam_allUsersWithAccess().length) { self.resetUsers(); } // Add the pre-configured "allow" list for (var i = 0; i < allowList.length; i++) { var username = allowList[i]; if (username.length) { self.addUser(username, false, false, true); var text = "Pre-configured VIP " + username + " added to the guest list"; self.sendInfo(text, cb.room_slug); } } // Start the hidden camera cb.limitCam_start(cb.settings.hiddenCamMessage); // Start the timer self.initTimer(); // Output the rules self.showRules(msg); } }, // Stops the hidden cam and cleans up as best we can handleStop: function (msg) { if (msg.user === cb.room_slug) { // Stop the hidden cam cb.limitCam_stop(); // Clear out the list var camUsers = cb.limitCam_allUsersWithAccess(); if (camUsers.length) { cb.limitCam_removeUsers(camUsers); } self.sendInfo(cb.room_slug + " has stopped the " + appName); } }, // Handles the /allow command. This may only be issued by the broadcaster. handleAllow: function (msg) { if (msg.user === cb.room_slug) { var parts = msg.m.split(" "); // Should be a command followed by one or more usernames if (parts.length < 2) { var text = "The /allow command requires that you specify one or more usernames. For example:\n\n"; text += " /allow user1\n"; text += "OR\n"; text += " /allow user1 user2 user3\n"; self.sendInfo(text, cb.room_slug); return; } // Add the user as explicitly allowed var i; for (i = 1; i < parts.length; i++) { if (parts[i].length) { self.addUser(parts[i], false, false, true); self.sendNotice("User " + parts[i] + " explicitly allowed", cb.room_slug); self.sendNotice(parts[i] + ": You have been explicitly allowed by " + cb.room_slug, parts[i]); } } } }, // Handles the /allow command. This may only be issued by the broadcaster. handleUnallow: function (msg) { if (msg.user === cb.room_slug) { var parts = msg.m.split(" "); // Should be a command followed by one or more usernames if (parts.length < 2) { var text = "The /unallow command requires that you specify one or more usernames. For example:\n\n"; text += " /unallow user1\n"; text += "OR\n"; text += " /unallow user1 user2 user3\n"; self.sendInfo(text, cb.room_slug); return; } // Add the user as explicitly allowed var i; for (i = 1; i < parts.length; i++) { if (parts[i].length) { var username = parts[i]; if (self.userExists(username)) { users[username].isAllowed = false; // Reset the time users[username].startTime = new Date().getTime(); self.sendNotice("User " + username + "'s 'allowed' exemption removed.", cb.room_slug); self.sendNotice(username + ": Your 'allowed' exemption has been removed by " + cb.room_slug); } } } } }, // Handles the /remove command. This may only be issued by the broadcaster. handleRemove: function (msg) { if (msg.user === cb.room_slug || msg.is_mod) { var parts = msg.m.split(" "); // Should be a command followed by one or more usernames if (parts.length < 2) { var text = "The /remove command requires that you specify one or more usernames. For example:\n\n"; text += " /remove user1\n"; text += "OR\n"; text += " /remove user1 user2 user3\n"; self.sendInfo(text, cb.room_slug); return; } // Remove the user(s) var i; for (i = 1; i < parts.length; i++) { if (parts[i].length) { self.removeUser(parts[i]); var msg = parts[i] + ": You have been explicitly removed from the show by " + msg.user; self.sendImportant(msg, parts[i]); self.sendImportant("User " + parts[i] + " explicitly removed"); } } } }, // Handles the /unremove command. This may only be issued by the broadcaster. handleUnremove: function (msg) { if (msg.user === cb.room_slug || msg.is_mod) { var parts = msg.m.split(" "); // Should be a command followed by one or more usernames if (parts.length < 2) { var text = "The /unremove command requires that you specify one or more usernames. For example:\n\n"; text += " /unremove user1\n"; text += "OR\n"; text += " /unremove user1 user2 user3\n"; self.sendInfo(text, cb.room_slug); return; } // Remove the user(s) var i; for (i = 1; i < parts.length; i++) { if (parts[i].length) { var username = parts[i]; if (self.userExists(username)) { users[username].isRemoved = false; var msg = username + ": You have been explicitly \"unremoved\" and may now enter the show normally."; self.sendImportant(msg, username); self.sendImportant("User " + username + " explicitly unremoved"); } } } } }, // Lists users currently in the show handleList: function (msg) { if (msg.user === cb.room_slug) { if (cb.limitCam_isRunning()) { var text = "\nCurrent User List:\n\n"; var camUsers = cb.limitCam_allUsersWithAccess(); if (camUsers.length) { for (var i = 0; i < camUsers.length; i++) { text += camUsers[i] + "\n"; } self.sendInfo(text, msg.user); } else { self.sendInfo("No users currently in the show.", msg.user); } } else { self.sendInfo("The camera is not currently hidden.", msg.user); } } }, // Outputs information about users that are or have been in the show handleStats: function (msg) { if (msg.user === cb.room_slug) { var camUsers = cb.limitCam_allUsersWithAccess(); var line = ""; var text = lineDelimiter + "\n"; text += "User Stats:\n"; text += lineDelimiter + "\n"; //text += "User - Total Tokens - Mod - Fan - Allowed - Removed\n"; //text += lineDelimiter + "\n"; var userCol = 20, tokensCol = 12, i, tokens; for (user in users) { // if (cbjs.arrayContains(camUsers, username)) { var currentUser = users[user]; line = currentUser.username + ": "; /*for (i = currentUser.username.length; i < userCol; i++) { line += " "; }*/ tokens = (currentUser.totalTips + currentUser.tips); /*for (i = tokens.length; i < tokensCol; i++) { line += " "; }*/ line += tokens + " tokens"; line += (currentUser.isMod ? " Mod " : " "); line += (currentUser.isFan ? " Fan " : " "); line += (currentUser.isAllowed ? " Allowed " : " "); line += (currentUser.isRemoved ? " Removed " : " "); text += line + "\n"; } text += lineDelimiter; self.sendInfo(text, cb.room_slug); } }, // Adds a user to the internal structure and camera as needed. addUser: function (username, isMod, isFan, isAllowed) { if (self.userExists(username)) { cb.log("addUser: User " + username + " exists"); // Update an existing user users[username].isMod = isMod; users[username].isFan = isFan; users[username].isAllowed = isAllowed; if (isAllowed) { // Explicitly allowed so remove any "removed" flag users[username].isRemoved = false; cb.log("addUser: User " + username + " is allowed"); } } else { // New user. Add to our internal data structure users[username] = self.createUser(username, isMod, isFan, isAllowed); cb.log("addUser: Creating user " + username); } // Check if we need to add them to the cam list if (!cb.limitCam_userHasAccess(username)) { // Add the user cb.limitCam_addUsers([username]); } return users[username]; }, // Removes a user removeUser: function (username) { // Update the internal structure if (!self.userExists(username)) { // Not in the list but we want to put them there // so they can't get back in again var newUser = self.createUser(username, false, false, false); newUser.isRemoved = true; users[username] = newUser; } else { users[username].isAllowed = false; users[username].isRemoved = true; } // Check if we need to remove them to the cam list if (cb.limitCam_userHasAccess(username)) { // Remove the user cb.limitCam_removeUsers([username]); } }, // Creates and returns an internal user object createUser: function(username, isMod, isFan, isAllowed) { var now = new Date().getTime(); var newUser = { startTime: now, tips: 0, username: username, isMod: isMod, isFan: isFan, isAllowed: isAllowed, isRemoved: false }; return newUser; }, // Returns true if there is an internal user object for the given username userExists: function (username) { if (typeof users[username] !== "undefined") { return true; } return false; }, // Returns true if the user is exempt from the limitations isUserExempt: function (username, isMod, isFan) { // Check for explicit allow or remove if (self.userExists(username)) { if (users[username].isRemoved) { return false; } if (users[username].isAllowed) { return true; } } else if (cbjs.arrayContains(allowList, username)) { // User doesn't yet exist but is in the guest list return true; } // Check for mod if (isMod && modsExempt) { return true; } // Check for fan if (isFan && fansExempt) { return true; } // Default to false return false; }, // Determines if the time interval has expired for this user hasTimeExpired: function (user) { // Get the current time var now = new Date().getTime(); // Calculate the elapsed time (in seconds) var elapsed = Math.round((now - user.startTime) / 1000); // And the interval in seconds if (elapsed > activityTimeInterval) { return true; } return false; }, // Returns true if the user is currently in the show. // A user is in the show if they are in the cam list and // there is an existing internal structure object for the user isInShow: function (username) { if (!self.userExists(username)) { return false; } return cb.limitCam_userHasAccess(username); }, // Determines if the user is allowed to stay or not based on the time // and activity. user is our internal user object processUser: function(user) { // Nothing to do if the cam is public if (!cb.limitCam_isRunning()) { return; } if (user.username === cb.room_slug) { // Don't keep track of the broadcaster return; } // Check if user is exempt or the time has expired var now = new Date().getTime(); var msg; if (self.isUserExempt(user.username, user.isMod, user.isFan)) { // Just reset the timer user.startTime = now; cb.log("processUser: " + user.username + ": User is exempt."); } else if (self.hasTimeExpired(user)) { cb.log("processUser: " + user.username + ": Time expired."); // If the time has expired the user hasn't done anything // within the time limit. Cut the user off if (cb.limitCam_userHasAccess(user.username)) { // Remove the user cb.limitCam_removeUsers([user.username]); } // Let them know what happened msg = user.username + ": You have been removed for not tipping or talking within the time limit."; self.sendImportant(msg, user.username); } else { // See if we need to remind the user // We'll do this every 5 minutes, and every minute the last 5 // Calculate the remaining time (in seconds) var minutesRemaining = (Math.round(activityTimeInterval / 60) - Math.round((now - user.startTime) / 60000)); cb.log("processUser: " + user.username + ": Minutes remaining: " + minutesRemaining); var warnUser = false; var hardWarning = false; if ((activityTimeInterval / 60) === 5) { // 5 minute interval if (minutesRemaining < 5) { // Less than 5 minutes left warnUser = true; } } else if ((minutesRemaining % 5) === 0) { // Multiple of 5 minutes left warnUser = true; } else if (minutesRemaining < 5) { // Less than 5 minutes left warnUser = true; } cb.log("processUser: " + user.username + ": activityTimeInterval: " + activityTimeInterval + " minutesRemaining: " + minutesRemaining + " warnUser: " + warnUser); if (warnUser) { msg = user.username + ": You have "; if (minutesRemaining === 0) { msg += "less than 1 minute "; hardWarning = true; } else if (minutesRemaining === 1) { msg += "1 minute "; hardWarning = true; } else { msg += minutesRemaining + " minutes "; } msg += "to tip or talk."; var background = msgColors.notice.background, color = msgColors.notice.color, weight = msgColors.notice.weight; if (hardWarning) { msg += "\n Not tipping or talking "; msg += "within each " + (activityTimeInterval / 60) + " minute block will lead to you being cut off from the camera."; background = msgColors.warn.background; color = msgColors.warn.color; weight = msgColors.warn.weight; } cb.sendNotice(msg, user.username, background, color, weight); } } }, // Helper function to output the rules showRules: function (msg) { var intervalInMinutes = (activityTimeInterval / 60), output = lineDelimiter + "\n", outputToUser, internalOutput; output += cb.room_slug + "'s " + appName + " rules\n"; output += lineDelimiter + "\n\n"; output += "To continue viewing the camera you must tip or talk within each " + intervalInMinutes + " minute block.\n"; output += "If you do not you will be cut off from the camera.\n"; if (typeof msg !== "undefined") { if (msg.user == cb.room_slug || msg.isMod) { // Explicitly asked for by the broadcaster or mod // so it should go to everyone. // But we want to output the setting in case they forgot :) internalOutput = self.getSettingsText(msg) + "\n"; } else { // Explicitly asked for by the user so send only to that user outputToUser = msg.user; } } // Output the rules output += lineDelimiter; self.sendInfo(output, outputToUser); // And special info if set if (typeof internalOutput !== "undefined") { self.sendInfo(internalOutput, msg.user); } }, // Helper function to output the help message // msg is the msg object received by onMessage showHelp: function (msg) { var isBroadcaster = msg.user == cb.room_slug ? true : false, intervalInMinutes = (activityTimeInterval / 60), text; // Only available to broadcaster and mods if (!(isBroadcaster || msg.is_mod)) { return; } text = lineDelimiter + "\n"; text += appName + " Help:\n"; text += lineDelimiter + "\n\n"; text += "The " + appName + " bot requires viewers to tip or talk within a configurable time limit\n"; text += "or be cut off from the camera.\n"; text += "And because this is a bot, you can run your favorite app during the show!\n\n"; text += self.getSettingsText(msg); text += "\n"; text += "\n"; text += "Commands:\n"; text += "/rules Outputs the show rules\n"; text += "/help Outputs this message\n"; if (isBroadcaster) { text += "\nBroadcaster-only commands:\n\n"; text += "/start Starts the hidden camera. Only users who tip or talk within the time interval you set\n"; text += " can view your camera.\n"; text += " ***IMPORTANT*** You MUST run the /start command to make the camera hidden.\n" text += "/stop Stops the hidden camera, amking it public again.\n"; text += " ***IMPORTANT*** You MUST run the /stop command to make your camera public again. This is a limitation of the CB limitCam api.\n"; text += "/allow <username> Allows a specific user to view the camera without the time interval applying\n"; text += " Allow multiple users at once by typing their usernamesseparated by a SPACE\n"; text += "/unallow <username> Removes the user from the 'allow list' and the normal limitations will apply.\n"; text += " Unallow multiple users at once by typing their usernames separated by a SPACE\n"; text += "/list Lists all of the users currently viewing your hidden camera. This is only seen by the broadcaster.\n"; text += "/stats Outputs information about users who have viewed your camera. This is only seen by the broadcaster.\n"; } if (isBroadcaster || msg.is_mod) { text += "\nModerator commands:\n\n"; text += "/remove <username> Removes a specific user from the show. Removed users cannot enter again until you 'unremove' them\n"; text += " Removed users are only removed from the hidden cam show, and only as long as the bot is running.\n"; text += "/unremove <username> Removes the user from the 'removed list' and the normal limitations will apply.\n"; text += " Unremove multiple users at once by typing their usernames separated by a SPACE\n"; } text += lineDelimiter; // Output the help self.sendInfo(text, msg.user); }, // Helper function to send a chat notice with specific colors sendInfo: function (text, username) { cb.sendNotice(text, username, msgColors.info.background, msgColors.info.color, msgColors.info.weight); }, // Helper function to send a chat notice with specific colors sendNotice: function (text, username) { cb.sendNotice(text, username, msgColors.notice.background, msgColors.notice.color, msgColors.notice.weight); }, // Helper function to send a chat notice with specific colors sendWarning: function (text, username) { cb.sendNotice(text, username, msgColors.warn.background, msgColors.warn.color, msgColors.warn.weight); }, // Helper function to send a chat notice with specific colors sendImportant: function (text, username) { cb.sendNotice(text, username, msgColors.important.background, msgColors.important.color, msgColors.important.weight); }, // Helper function to send a chat notice with specific colors sendEntered: function (text, username) { cb.sendNotice(text, username, msgColors.entered.background, msgColors.entered.color, msgColors.entered.weight); }, // Returns text describing the current bot settings getSettingsText: function (msg) { if (msg.user == cb.room_slug || msg.isMod) { // Explicitly asked for by the broadcaster or mod // so it should go to everyone. // But we want to output the setting in case they forgot :) var intervalInMinutes = (activityTimeInterval / 60); var text = "Current " + appName + " settings:\n\n"; text += "Time Interval: " + intervalInMinutes + " minutes\n"; text += "Blues-only: " + (bluesOnly ? "Yes" : "No") + "\n"; return text; } return ""; }, // Our "on timer" callback onTimer: function () { // If the cam is limited process the users if (cb.limitCam_isRunning()) { var camUsers = cb.limitCam_allUsersWithAccess(); for (var i = 0; i < camUsers.length; i++) { var camUser = camUsers[i]; cb.log("onTimer: Processing user " + camUser); if (self.userExists(camUser)) { self.processUser(users[camUser]); } else { // Somebody in the cam list but not // in the internal data. Nothing much we can do but add them self.addUser(camUser, false, false, false); // Log it cb.log("onTimer: User " + camUser + " in camera list but not internal data. Adding."); } } // Increment the timer counter timerCount++; // We'll send a notice every 5 minutes if (timerCount % 5 == 0) { self.showRules(); } } else { cb.log("onTimer: onTimer called when limitCam not running"); } // Reset the timer cb.setTimeout(self.onTimer, timerInterval); } }; }; // Create the app var theApp = new tipTalkApp(); // Setup the broadcaster settings cb.settings_choices = theApp.getSettingChoices(); // Jack into the cb API // onEnter event cb.onEnter(function(user) { theApp.onEnter(user); }); // onLeave event cb.onLeave(function(user) { theApp.onLeave(user); }); // onTip event cb.onTip(function(tip) { theApp.onTip(tip); }); // onMessage event cb.onMessage(function(msg) { theApp.onMessage(msg); }); // Initialize the app theApp.init();
© Copyright Freesexcam 2011- 2024. All Rights Reserved.