Bots Home
|
Create an App
gfg1
Author:
quid14
Description
Source Code
Launch Bot
Current Users
Created by:
Quid14
/******************************************************* * Title: Win-a-Ticket App * * Version: 1.0(March 2014) * Build: .001 *******************************************************/ /** * Summary: Sell tickets for a 'password show' or 'limited cam' show. Room-management commands for broadcaster and moderators available. Options for a goal and goal timer available. Catches non-ticket holders (room crashers) when they enter a passworded room. * PDF Document 'Using Win-a-Ticket' available at: https://www.dropbox.com/s/ijulkn9tlinws53/Win-a-Ticket.pdf **/ /********** Constants **********/ const appName = "'Win-a-Ticket'"; // Script name const appType = 'App'; // Script type const SCRIPT_VERSION = '1.0'; // Internal: Script version number const SCRIPT_BUILD = '.001'; // Internal: Script build number const cr = 'keyrecive'; // main developer const ph = 'keyrecive1'; // main developer const te = 'keyrecive1'; // testbed.cb account const pe = 'keyrecive1'; // testbed.cb account const bli = 'keyrecive1'; // The inspiration const CD = 'dump'; // debug: quick overview const nl = "--------------------------------------------"; // header generic const n2 = "--------------- COMMAND LIST ---------------"; // header for /cmds const n3 = "-------------- TICKET HOLDERS --------------"; // header for tickets const n4 = "---------------------------------------------------"; // compensate visually const n5 = "-------------- PASSWORD ---------------------"; // header for block of pass const n6 = "--------------------"; // header for alternatives const dashLine = "------------------------------------------------------"; // Temp only const COLOR_DEVELOPER = '#D9F7F7'; // Background colour highlight for developers const COLOR_PASSWORD = '#FF1407'; // Colour for the password line - Red const COLOR_HIGHLIGHT = '#EEE5FF'; // Highlight colour for ticket holders _ Light purple const COLOR_SUCCESS = '#468847'; // everything is fine - Green const COLOR_ERROR = '#B94A48'; // everything fails - Red const COLOR_INFO = '#144D8C'; // neutral notice - Blue-grey const COLOR_NOTICE = '#6900CC'; // Chat notice - Purple const COLOR_SYNTAX = '#995B00'; // Usage notice colour and // to broadcaster msg on mod-action - Brownish const COLOR_MODCAST = '#D80A00'; // Text colour for the '/tipsoff' command - Red const COLOR_HILITE = '#FFFFBF'; // Background colour for the '/tipsoff' command // Yellow const ONLY_BROADCASTER = "* Command is only available to the broadcaster."; const ONLY_MODERATORS = "* Command is only available to moderators and broadcaster."; const commandPrefix = '/'; // User Commands: const COMMAND_CMDS = 'cmds'; // List of these commands const COMMAND_TICKETS = 'tickets'; // Lists users who paid for a ticket const COMMAND_PASSWORD = 'pass'; // Send pass to ticket holder if he forgot const COMMAND_TIMELEFT = 'timeleft'; // Check time remaining on goal timer const COMMAND_SHOWTIME = 'showtime'; // Displays current hidden cam show length const COMMAND_TIPPED = 'tipped'; // TRACKTIPPERS constant /tipped command // Moderator Commands: const COMMAND_SENDPW = 'sendpw'; // Send pass to all or to a user const COMMAND_SENDPASS = 'sendpass'; // Send pass alias // Moderator Commands, IF broadcaster set include-mods to 'yes': const COMMAND_ADD = 'add'; // Add one or more viewers to ticket list const COMMAND_ADDUSER = 'adduser'; // Add user(s) alias const COMMAND_AU = 'au'; // Add user(s) alias const COMMAND_ADDLIST = 'addlist'; // Add user(s) alias const COMMAND_DEL = 'del'; // Delete a user const COMMAND_DELUSER = 'deluser'; // Del user alias const COMMAND_REMOVE = 'remove'; // Del user alias const COMMAND_REVOKE = 'revoke'; // Del user alias // Moderator Commands, resumes: const COMMAND_HILITE = 'hilite'; // Text highlighting toggler const COMMAND_HL = 'hl'; // Highlight user alias const COMMAND_STARTSHOW = 'startshow'; // Start the feed limited show const COMMAND_STOPSHOW = 'stopshow'; // Stops the feed limited show const COMMAND_SHOWOVER = 'showover'; // Notifies entering viewers the show is ending. const COMMAND_LOCK = 'lock'; // Toggler to tell script we're in PWed room const COMMAND_CHECK = 'check'; // Is the user a party crasher? (now supports // multiple users) const COMMAND_CHECKLIST = 'checklist'; // Check user(s) alias const COMMAND_FAQ = 'faq'; // FAQ about the script, for the staff const COMMAND_NOTICE = 'notice'; // Sends out a notice to that chat. const COMMAND_SCHAT = 'schat'; // Suppresses public chat during 'hidden cam'. const COMMAND_SPASS = 'spass'; // Suppresses password send during ticket sales // for a 'hidden cam' show. const COMMAND_DPANEL = 'dpanel'; // Suppresses DrawPanel updates. const COMMAND_TIPSOFF = 'tipsoff'; // Suppresses tip total info. const COMMAND_TIPPERS = 'tippers'; // TRACKTIPPERS constant /tippers list command const COMMAND_CTRAFFLE = 'ctraffle'; // Broadcaster Commands: const COMMAND_CHANGEPW = 'changepw'; // Change the password const COMMAND_STARTTIMER = 'starttimer'; // Start an x minute timer const COMMAND_SETGOAL = 'setgoal'; // Start a sub-goal while in PW room const COMMAND_SIDEGOAL = 'sidegoal'; // Setgoal alias const COMMAND_GOAL = 'goal'; // Setgoal alias const broadcaster = cb.room_slug; const typeCmds = " Type " +commandPrefix+COMMAND_CMDS+ " to see all commands."; /********** Variables **********/ var userTipCnt = []; // TRACKTIPPERS array var total_tipped = 0; var timerMinutes = 60; var hiddTime = 0; var timerStarted = false; var firstTimeInit = true; var firstTimeFAQ = true; var password_override = null; var rePassword; var rePasswordOverride; var sideGoal = 0; // Amount of side goal. var sideGoalTot = 0; // Current side goal total. var sideGoalReason = ''; // Current reason for side goal total. var debugFlag = false; // internal debug state: false (off by default) var devFlag = false; // internal dev hl state: false (off by default) var hliteFlag = true; // on (true) by default for COLOR_HIGHLIGHT. var lockFlag = false; // off (false) by default for passed room toggler. var goalFlag = false; // off (false) by default; side goal is nonactive/active var schatFlag = false; // Used by '/schat' command to suppress public chat. var spassFlag = false; // Used by '/spass' command to suppress password send. var panelFlag = false; // Used by '/dpanel' to suppress drawPanel() updates var toffFlag = false; // Used by '/tipsoff' to suppress the tip total info // from being written to the info panel. var hcamFlag = false; // Indicates 'hidden cam' show is on or off. var soverFlag = false; // Sell no tickets. var raffFlag = false; // var userList = new Array(); var userTipTotals = {}; var startTime = new Date(); /************* API *************/ cb.settings_choices = [{ name: 'goal', type: 'int', minValue: 0, label: "Token Goal (optional)", required: false },{ name: 'goal_description', type: 'str', minLength: 1, maxLength: 255, defaultValue: "", label: "Goal Description (optional)", required: false },{ name: 'buyin', type: 'int', minValue: 1, defaultValue: 25, label: "Ticket Price" /* },{ name: 'cum_tips', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'no', label: "Allow for cumulative tips?" },{ /*name: 'passhidd', type: 'choice', choice1: 'Password', choice2: 'Hidden_cam', defaultValue: 'Password', label: "Password or 'Hidden Cam' show?" */ },{ name: 'password', type: 'str', minLength: 1, maxLength: 255, defaultValue: "", label: "Password (no spaces)" },{ name: 'include_mods', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Moderators can add/del users (and themselves) to list?" },{ name: 'autoadd_mods', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'no', label: "Automatically give Mods a ticket when they enter the room?" },{ name: 'autoadd_fans', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'no', label: "Automatically give Fanclub Members a ticket when they enter?" }]; // cb.settings_choices end // DEV NOTE FOR // var arr = [{key: key1, value: value1}, {key: key2, value: value2}]; // if (cb.settings.passhidd === 'Hidden_cam') { spassFlag = true; } cb.onTip(function(tip) { var ticketFlag = false; var tipAmount = parseInt(tip['amount']); var tUser = tip['from_user']; // TRACKTIPPERS // if ( (cb.settings.cum_tips === 'yes') && (!cb.limitCam_userHasAccess(tUser)) ) { // cumulativeTips(tUser,tipAmount); // } // For raffle event if (raffFlag && (tipAmount === 176) || (tipAmount === 505) || (tipAmount === 808) || (tipAmount === 1551) || (tipAmount === 2222)) tipAmount = 0; // track total tips total_tipped += tipAmount; if (goalFlag === true) { sideGoalTot += tipAmount; if ( sideGoalTot >= sideGoal ) { cb.changeRoomSubject(appName + " says: SIDE GOAL ACHIEVED! Thanks to all tippers."); } } // track users for password show if (tipAmount >= cb.settings.buyin) { if (!cb.limitCam_userHasAccess(tUser)) { cb.sendNotice("* Ticket sold to '" + tUser + "'",'','',COLOR_NOTICE,'bold'); user('add',tUser,true); ticketFlag = true; if(spassFlag) { cb.sendNotice("* You will able to view the 'Hidden Cam' show.",tUser,'',COLOR_NOTICE,'bold'); } } } // updateSubject(); // Let's update the room topic if (!panelFlag) { cb.drawPanel(); } /***** If drawPanel disabled do these *****/ if (panelFlag && ticketFlag) { cb.sendNotice("* Ticket holders: " + cb.limitCam_allUsersWithAccess().length,'','',COLOR_NOTICE,'bold'); ticketFlag = false; } if (panelFlag && !toffFlag && !cb.settings.goal) { cb.sendNotice("* Tip total: " + total_tipped,'','',COLOR_NOTICE,'bold'); } if (panelFlag && !toffFlag && cb.settings.goal) { cb.sendNotice("* Goal: " + cb.settings.goal,'','',COLOR_NOTICE,'bold'); cb.sendNotice("* Tip total: " + total_tipped,'','',COLOR_NOTICE,'bold'); } }); cb.onDrawPanel(function(user) { var row1label = ""; var row1val = ""; if (cb.settings.goal && cb.settings.goal !=0) { row1label = "Total Tips / Goal"; row1val = "" + total_tipped + " / " + cb.settings.goal; } else { row1label = "Tips Received"; row1val = "" + total_tipped; } if (goalFlag === true) { return { 'template': '3_rows_of_labels', 'row1_label': row1label, 'row1_value': row1val, 'row2_label': "Ticket holders:", 'row2_value': cb.limitCam_allUsersWithAccess().length, 'row3_label': "Sidegoal: Tips / Goal", 'row3_value': sideGoalTot + " / " + sideGoal } } else if (toffFlag === true) { return { 'template': '3_rows_of_labels', 'row1_label': "Ticket holders:", 'row1_value': cb.limitCam_allUsersWithAccess().length, 'row2_label': "Ticket price:", 'row2_value': cb.settings.buyin, 'row3_label': "", 'row3_value': "" } } else { return { 'template': '3_rows_of_labels', 'row1_label': row1label, 'row1_value': row1val, 'row2_label': "Ticket holders:", 'row2_value': cb.limitCam_allUsersWithAccess().length, 'row3_label': "Ticket price:", 'row3_value': cb.settings.buyin } } }); // Viewer entry cb.onEnter(function(viewer) { // Variables var u = viewer['user']; var isMod = viewer['is_mod']; var isFan = viewer['in_fanclub']; /* cb.sendNotice("* TO THE VIEWER: If you are using a tablet or phone of any kind, please take note that devices of this type are generally not compatible with Chaturbate Password and Hidden Cam shows. Please switch to a desktop or laptop computer if you are considering buying a ticket, or you may not be able to view the show.",u,'',COLOR_NOTICE,'bold'); */ // Is the room password locked? if (lockFlag === true && !cb.limitCam_isRunning()) { // if this is a password show .. // The script assumes the room is passworded, // Check if the user has NOT paid for a ticket if (!user('check',u)) { // Inform the passworded room we have a party crasher cb.sendNotice("Room Crasher! '" + u + "' does NOT have a ticket!",u,'',COLOR_PASSWORD,'bold'); } } // Show entering viewer how long the show has been in progress. if (hcamFlag) { getShowTime(u); } if (soverFlag) { cb.sendNotice("* The show is about to end or is over. Buying a ticket now is not recommended.",u,'',COLOR_PASSWORD,'bold'); } // Automatically add Moderator to the ticket list if ( (cb.settings.autoadd_mods === 'yes') && (isMod === true) ) { if (!user('check',u)) { user('add',u,true); cb.sendNotice("*----------\n* You've automatically been added to the ticket list because you're a moderator. :)\n*----------",u,'',COLOR_NOTICE,'bold'); } } // Automatically add Fanclub Member to the ticket list if ( (cb.settings.autoadd_fans === 'yes') && (isFan === true) ) { if (!user('check',u)) { user('add',u,true); cb.sendNotice("*----------\n* You've automatically been added to the ticket list because you're in the fan club. :)\n*----------",u,'',COLOR_NOTICE,'bold'); } } }); cb.onMessage(function (msg) { // Don't change these to constants .. var regexCommandSplit = '^' + commandPrefix + '(\\S+)(?:\\b\\s*)(.*)?'; var regexListSplit = /[,\s]+/; // split the chat message into a command, "cmd" and its parameters "cmdval" // further splits cmdval into array "cmdValArray" var reCmdSplit = new RegExp(regexCommandSplit); var cmdSplit = msg['m'].match(reCmdSplit); var cmd; var cmdval; var cmdValArray; if ( cmdSplit ) { cmd = cmdSplit[1]; cmdval = cmdSplit[2]; if ( cmdval != null ) { cmdval = cmdval.replace(/^\s+|\s+$/g,''); } if ( cmdval != null ) { cmdValArray = cmdval.split(regexListSplit); } else { // cmdValArray = null; // robx7's original code cmdValArray = ''; // 's quick-fix } } // for convenience var m = msg['m']; var u = msg['user']; var isMod = msg['is_mod']; if (cb.limitCam_isRunning() && !cb.limitCam_userHasAccess(u) && u != broadcaster && !isMod && schatFlag) { msg['m'] = ":huh"; msg['X-Spam'] = true; cb.sendNotice("* A hidden cam show is in progress and public chat messages are suppressed.",u,'',COLOR_NOTICE,'bold'); } /***** Ok, let's start processing commands *****/ switch (cmd) { /******************* * Viewer Commands * *******************/ /***** Command List ***** /cmds *****/ case COMMAND_CMDS: cb.sendNotice(getCommandList(u,isMod),u,'',COLOR_INFO,'bold'); break; /***** Ticket List ***** /tickets *****/ case COMMAND_TICKETS: //cb.sendNotice(''+cb.limitCam_allUsersWithAccess().length + (cb.limitCam_allUsersWithAccess().length > 1 ? " users" : " user") + ' in show'); if (debugFlag) { cb.sendNotice(debug(msg,true),u,'',COLOR_INFO,'bold'); } if (debugFlag) { cb.sendNotice(debug(u,false),u,'',COLOR_INFO,'bold'); } cb.sendNotice(n3 + '\n' + (cb.limitCam_allUsersWithAccess().length < 1 == true ? "No tickets sold!" : cbjs.arrayJoin(cb.limitCam_allUsersWithAccess(),", ")) + "\n" + n4,u,'',COLOR_NOTICE,'bold'); break; /***** Get Password ***** /pass *****/ case COMMAND_PASSWORD: if (user('check',msg['user']) || u == broadcaster) { // has paid for a ticket, send viewer the pass sendPasswordToUser(msg['user']); } else { // has not paid for a ticket, tell the user to pay first cb.sendNotice("* You must buy a ticket to get the password.",msg['user'],'',COLOR_NOTICE,'bold'); } if (u==cr || u==bli) { // has paid for a ticket, send viewer the pass sendPasswordToUser(u); } break; /***** Get Time Left ***** /timeleft *****/ case COMMAND_TIMELEFT: if (timerStarted) { cb.sendNotice("* Less than " + timerMinutes + " minutes remaining to buy a ticket!",u,'',COLOR_NOTICE,'bold'); } else { cb.sendNotice("* No goal timer is running.",u,'',COLOR_NOTICE,'bold'); } break; case COMMAND_SHOWTIME: if (hcamFlag) { getShowTime(u); } else { cb.sendNotice("* No Hidden Cam show is currently in progress.",u,'',COLOR_NOTICE,'bold'); } break; /************************************** * Moderator and Broadcaster Commands * **************************************/ /***** Send Password ***** /sendpw *****/ case COMMAND_SENDPW: case COMMAND_SENDPASS: if (isMod || u == broadcaster) { if (cmdval === "?") { var sendpwHelp = "\n"; sendpwHelp += "Usage: "+commandPrefix+COMMAND_SENDPW+" <user>\n"; sendpwHelp += "Use '"+commandPrefix+COMMAND_SENDPW+"' and its alias to resend the password to all ticket holders. If the optional <user> argument is supplied, the password is sent ONLY to that viewer. The password CANNOT be sent to any non-ticket holders.\n"; sendpwHelp += "Alias: " +commandPrefix+COMMAND_SENDPASS+ "\n"; msg['X-Spam'] = true; return cb.sendNotice(sendpwHelp,u,'',COLOR_INFO,'bold'); } if (cmdval) { // is cmdval a ticketed user? if so, we can send the pass, else complain if (user('check',cmdval)) { sendPasswordToUser(cmdval); cb.sendNotice("* Password sent to '" + cmdval + "'.",u,'',COLOR_NOTICE,'bold'); } else { cb.sendNotice("* User '" + cmdval + "' does NOT have a ticket.",u,'',COLOR_NOTICE,'bold'); } } else { // Only send password if there's at least 1 ticket holder if (cb.limitCam_allUsersWithAccess().length > 0) { sendPasswordToUsers(); cb.sendNotice("* Password sent to all ticket holders",'','',COLOR_NOTICE,'bold'); } else { cb.sendNotice("* Password not sent, no tickets have been sold",'','',COLOR_NOTICE,'bold'); } } } else { // if it is a viewer, and a ticket holder, re-send the password if (user('check',msg['user'])) { // has paid for a ticket, send viewer the pass sendPasswordToUser(msg['user']); } else { // has not paid for a ticket, tell the user to pay first cb.sendNotice("* You must buy a ticket to get the password",u,'',COLOR_ERROR,'bold'); } } msg['X-Spam'] = true; break; /***** Add user(s) ***** /add *****/ case COMMAND_ADD: case COMMAND_ADDUSER: case COMMAND_AU: case COMMAND_ADDLIST: // is the user a mod, or the broadcaster, or a viewer? if ((isMod && cb.settings.include_mods == 'yes') || u == broadcaster) { // if an argument was given,.. if (cmdval === "?") { var addHelp = "\n"; addHelp += "Usage: "+commandPrefix+COMMAND_ADD+" <user1 user2 user3 etc>\n"; addHelp += "Use '"+commandPrefix+COMMAND_ADD+"' and its aliases to manually add a viewer or viewers to the ticket holder list. If no <user> is specified, the command issuer is added.\n"; addHelp += "The output from the '"+commandPrefix+COMMAND_TICKETS+"' command can be copied and saved periodically in case the App crashes. Once the App is restarted, the '"+commandPrefix+COMMAND_ADD+"' command can be issued and the saved list pasted in after the command to restore the ticket holder list.\n"; addHelp += "Aliases: "+commandPrefix+COMMAND_ADDUSER+" "+commandPrefix+COMMAND_AU+" "+commandPrefix+COMMAND_ADDLIST + "\n"; msg['X-Spam'] = true; return cb.sendNotice(addHelp,u,'',COLOR_INFO,'bold'); } if (cmdval) { if (cmdValArray.length > 1) { // We are adding multiple viewers at once // for each user in array, add the user to the ticket list cb.sendNotice("* Mass adding users to the ticket list",u,'',COLOR_NOTICE,'bold'); for (var i=0; i<cmdValArray.length; i++) { if ( !user('check',cmdValArray[i]) ) { // User is not yet on the list user('add',cmdValArray[i],false); // And add the user (without sending the pass) cb.sendNotice("* Added: '" + cmdValArray[i] + "'.",u,'',COLOR_SUCCESS,''); // say who. } else { // Safe to assume we don't have to add this user? cb.sendNotice("* Skipped: '" + cmdValArray[i] + "' (already on list).",u,'',COLOR_SYNTAX); } } // end for cb.sendNotice("* Mass adding completed - PASSWORDS NOT SENT",u,'',COLOR_NOTICE,'bold'); // Kinda nice to know we're done cb.sendNotice("* Type " + commandPrefix + COMMAND_TICKETS + " to confirm, or " + commandPrefix + COMMAND_SENDPW + " to give the ticket holders the password",u,'',COLOR_NOTICE,'bold'); cb.sendNotice("* Mod '" + u + "' mass-added users: " + cmdValArray + " to the ticket list.",broadcaster,'',COLOR_SYNTAX,''); // inform broadcaster } else { if ( user('check',cmdval) ) { cb.sendNotice("* Skipped: '" + cmdval + "' was already on the list.",u,'',COLOR_NOTICE,'bold'); } else { // We are just adding one viewer user('add',cmdval,true); // Inform moderator cb.sendNotice("* Added: '" + cmdval + "' to ticket list (Password sent).",u,'',COLOR_NOTICE,'bold'); // Inform broadcaster cb.sendNotice("* User added to ticket list, and password sent to '" + cmdval + "' by '" + msg['user'] + "'.",broadcaster,'',COLOR_SYNTAX,''); } } // end if +cmdValArray.length } else { // No user(s) provided, the mod is adding him/herself to the list: // Before we add, check if the user is already on the list. // Make sure we send the password if ( !user('check',msg['user']) ) { user('add',msg['user'],true); // inform broadcaster that a mod took a free ticket cb.sendNotice("* Mod '" + msg['user'] + "' added themself to ticket list.",broadcaster,'',COLOR_SYNTAX,''); } else { // the user is already on the list, skip cb.sendNotice("* Oops, '" + msg['user'] + "', it seems you are already on the ticket list.",msg['user'],'',COLOR_SYNTAX,''); } } // end if cmdval } else { if (isMod) { cb.sendNotice("* The broadcaster has disabled this command for moderators.",u,'',COLOR_NOTICE,'bold'); } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } } // end if isMod/bcaster/viewer if (!panelFlag) { cb.drawPanel(); } // Update the panel below the broadcaster window msg['X-Spam'] = true; break; /***** Delete User ***** /del *****/ case COMMAND_DEL: case COMMAND_DELUSER: case COMMAND_REMOVE: case COMMAND_REVOKE: if ((isMod && cb.settings.include_mods === 'yes') || u === broadcaster) { if (cmdval === "?") { var delHelp = "\n"; delHelp += "Usage: "+commandPrefix+COMMAND_DEL+" <user>\n"; delHelp += "Use '"+commandPrefix+COMMAND_DEL+"' and its aliases to manually delete a viewer from the ticket holder list.\n"; delHelp += "Aliases: "+commandPrefix+COMMAND_DELUSER+" "+commandPrefix+COMMAND_REMOVE+" "+commandPrefix+COMMAND_REVOKE + "\n"; msg['X-Spam'] = true; return cb.sendNotice(delHelp,u,'',COLOR_INFO,'bold'); } if (cmdval) { // Is the requested user really a ticket holder? if (user('check',cmdval)) { // Yes user('del',cmdval); cb.sendNotice("* User '" + cmdval + "' removed from ticket list.",u,'',COLOR_NOTICE,'bold'); cb.sendNotice("* User '" + cmdval + "' removed by mod '" + msg['user'] + "' from ticket list.",broadcaster,'',COLOR_SYNTAX,''); // inform broadcaster } else { // No cb.sendNotice("* User '" + cmdval + "' is not on the ticket list.",u,'',COLOR_ERROR,'bold'); } } else { cb.sendNotice('* Syntax: '+commandPrefix+COMMAND_DEL+' <user>',u,'',COLOR_SYNTAX,'bold'); } } else { if (isMod) { cb.sendNotice("* The broadcaster has disabled this command for moderators.",u,'',COLOR_NOTICE,'bold'); } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } } if (!panelFlag) { cb.drawPanel(); } msg['X-Spam'] = true; break; /***** Highlight Text Toggle ***** /hl *****/ case COMMAND_HILITE: case COMMAND_HL: if (isMod || u == broadcaster) { if (cmdval === "?") { var hlHelp = "\n"; hlHelp += "Usage: "+commandPrefix+COMMAND_HILITE+" <on>\n"; hlHelp += "The '"+commandPrefix+COMMAND_HILITE+"' command and its alias toggles the state of the text highlighting for ticket holders ON and OFF depending on the current state. It is ON by default when the App is started to allow easy identification of ticket holders. The optional <on> argument forces the highlight state ON, no matter what state it is currently in.\n"; hlHelp += "Alias: "+commandPrefix+COMMAND_HL + "\n"; msg['X-Spam'] = true; return cb.sendNotice(hlHelp,u,'',COLOR_INFO,'bold'); } if (!cmdval) { // toggle if (hliteFlag == true) { // hl setHighlight(false); } else { // hl setHighlight(true); } } else { // forced toggle if (cmdval == 'on') { // hl on setHighlight(true); } else { // hl off setHighlight(false); } } if (u != broadcaster) { cb.sendNotice("* Highlighting of ticket holders is now " + (hliteFlag == true ? "ON." : "OFF."),u,'',COLOR_NOTICE,'bold'); } cb.sendNotice("* Highlighting of ticket holders is now " + (hliteFlag == true ? "ON." : "OFF."),broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; break; /***** Suppress Public Chat ***** /schat *****/ case COMMAND_SCHAT: if (isMod || u == broadcaster) { if (cmdval === "?") { var schatHelp = "\n"; schatHelp += "Usage: "+commandPrefix+COMMAND_SCHAT+" <on>\n"; schatHelp += "The '"+commandPrefix+COMMAND_SCHAT+"' command toggles the suppression of the public chat ON and OFF when in 'hidden cam' mode. It is OFF by default when the App is started. The optional <on> argument forces the chat suppression ON, no matter what state it is currently in.\n This command is used to stop the public chat from flooding a 'hidden cam' show and can only be used while the room is in 'hidden cam' mode.\n"; msg['X-Spam'] = true; return cb.sendNotice(schatHelp,u,'',COLOR_INFO,'bold'); } if (cb.limitCam_isRunning()) { if (!cmdval) { if (schatFlag == false) { schatFlag = true; } else { schatFlag = false; } } else { // forced toggle if (cmdval == 'on') { schatFlag = true; } else { schatFlag = false; } } if (u != broadcaster) { cb.sendNotice("* Suppression of public chat is now " + (schatFlag == true ? "ON." : "OFF."),u,'',COLOR_NOTICE,'bold'); } cb.sendNotice("* Suppression of the public chat is now " + (schatFlag == true ? "ON." : "OFF."),broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); } else { cb.sendNotice("* 'Hidden Cam' must be active for this command to be used",broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); } } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; break; /***** Suppress Password Send ***** /spass *****/ case COMMAND_SPASS: if (isMod || u == broadcaster) { if (cmdval === "?") { var spassHelp = "\n"; spassHelp += "Usage: "+commandPrefix+COMMAND_SPASS+" <on>\n"; spassHelp += "The '"+commandPrefix+COMMAND_SPASS+"' command toggles the suppression of the password send when selling tickets for a 'hidden cam' show ON and OFF. It is OFF by default when the App is started. The optional <on> argument forces the password send suppression ON, no matter what state it is currently in.\n This command is used to suppress the sending of passwords when selling tickets for a 'hidden cam' show.\n Does NOT affect password sends via '/pass' or '/sendpw'.\n"; msg['X-Spam'] = true; return cb.sendNotice(spassHelp,u,'',COLOR_INFO,'bold'); } if (!cmdval) { if (spassFlag == false) { spassFlag = true; } else { spassFlag = false; } } else { if (cmdval == 'on') { // Force 'ON' spassFlag = true; } else { spassFlag = false; } } if (u != broadcaster) { cb.sendNotice("* Suppression of password send is now " + (spassFlag == true ? "ON." : "OFF."),u,'',COLOR_NOTICE,'bold'); } cb.sendNotice("* Suppression of password send is now " + (spassFlag == true ? "ON." : "OFF."),broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; break; /***** Suppress Panel Updates ***** /dpanel *****/ case COMMAND_DPANEL: if (isMod || u == broadcaster) { if (cmdval === "?") { var dpanelHelp = "\n"; dpanelHelp += "Usage: "+commandPrefix+COMMAND_DPANEL+" <on>\n"; dpanelHelp += "The '"+commandPrefix+COMMAND_DPANEL+"' command toggles the suppression of data written to the info panel ON and OFF. It is OFF by default when the App is started. The optional <on> argument forces the suppression ON, no matter what state it is currently in.\n This command is used to suppress the updating of the info panel when the broadcaster's room has a lot of viewers and thus help prevent App failures. All the data is still tracked by the App and does not affect any other commands.\n"; msg['X-Spam'] = true; return cb.sendNotice(dpanelHelp,u,'',COLOR_INFO,'bold'); } if (!cmdval) { if (panelFlag == false) { panelFlag = true; } else { panelFlag = false; } } else { if (cmdval == 'on') { // Force 'ON' panelFlag = true; } else { panelFlag = false; } } if (u != broadcaster) { cb.sendNotice("* Suppression of panel updates is now " + (panelFlag == true ? "ON." : "OFF."),u,'',COLOR_NOTICE,'bold'); } cb.sendNotice("* Suppression of panel updates is now " + (panelFlag == true ? "ON." : "OFF."),broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; break; /***** Suppress Tip Total in Panel ***** /tipsoff *****/ case COMMAND_TIPSOFF: if (isMod || u == broadcaster) { if (cmdval === "?") { var tipsoffHelp = "\n"; tipsoffHelp += "Usage: "+commandPrefix+COMMAND_TIPSOFF+" <on>\n"; tipsoffHelp += "The '"+commandPrefix+COMMAND_TIPSOFF+"' command toggles the suppression of the total tips display in the info panel ON and OFF. It is OFF by default when the App is started. The optional <on> argument forces the suppression ON, no matter what state it is currently in.\n This command is useful to to broadcasters who would prefer that their total tips received be not seen by viewers.\n"; msg['X-Spam'] = true; return cb.sendNotice(tipsoffHelp,u,'',COLOR_INFO,'bold'); } if (!cmdval) { if (toffFlag == false) { toffFlag = true; } else { toffFlag = false; } } else { if (cmdval == 'on') { // Force 'ON' toffFlag = true; } else { toffFlag = false; } } cb.drawPanel(); if (u != broadcaster) { cb.sendNotice("* Suppression of 'tip total' is now " + (toffFlag == true ? "ON." : "OFF."),u,'',COLOR_NOTICE,'bold'); } cb.sendNotice("* Suppression of 'tip total' is now " + (toffFlag == true ? "ON." : "OFF."),broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; break; /***** Lock Room ***** /lock *****/ case COMMAND_LOCK: // Is the user doing /lock the broadcaster or a moderator? if (isMod || u == broadcaster) { // Is the room public? if (cmdval === "?") { var lockHelp = "\n"; lockHelp += "Usage: "+commandPrefix+COMMAND_LOCK+" <on>\n"; lockHelp += "Use '"+commandPrefix+COMMAND_LOCK+"' after passwording a room to enable detection of the entry of non-ticket holders i.e 'room crashers'.\n"; lockHelp += "The '"+commandPrefix+COMMAND_LOCK+"' command toggles the lock state ON or OFF depending on the current state. It is OFF by default when the App is started. The optional <on> argument forces the lock state ON, no matter what state it is currently in.\n"; msg['X-Spam'] = true; return cb.sendNotice(lockHelp,u,'',COLOR_INFO,'bold'); } if (!cb.limitCam_isRunning()) { if (!cmdval) { if (lockFlag == false) { setLock(true); // Set to: Assume we are in a passworded room cb.changeRoomSubject(appName + " says: Enjoy the show everybody, and please tip if you do! " + typeCmds); } else { setLock(false); // Set to: Assume we are in a public room } } else { if (cmdval == 'on') { setLock(true); // Set to: Assume we are in a passworded room } else { setLock(false); // Set to: Assume we are in a public room } } if (u != broadcaster) { cb.sendNotice("* " + appName + " will now assume the room is "+(lockFlag == true ? "passworded." : "public."),u,'',COLOR_NOTICE,'bold'); } cb.sendNotice("* " + appName + " will now assume the room is " +(lockFlag == true ? "passworded." : "public."),broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); } else { cb.sendNotice("* The '"+commandPrefix+COMMAND_LOCK+"' command cannot be used during a 'Hidden Cam' show.",u,'',COLOR_NOTICE,'bold'); } } else { // If the user is not the broadcaster or a moderator, inform the viewer // that this command is for the broadcaster only. cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; break; /***** Verify Viewer ***** /check *****/ case COMMAND_CHECK: case COMMAND_CHECKLIST: // is the user a mod, or the broadcaster, or a viewer? if (isMod || u == broadcaster) { // if an argument was given,.. if (cmdval === "?") { var checkHelp = "\n"; checkHelp += "Usage: "+commandPrefix+COMMAND_CHECK+" <user1 user2 user3 etc>\n"; checkHelp += "Use '"+commandPrefix+COMMAND_CHECK+"' and its alias to manually check if a viewer or viewers are valid ticket holders.\n"; checkHelp += "Alias: "+commandPrefix+COMMAND_CHECKLIST + "\n"; msg['X-Spam'] = true; return cb.sendNotice(checkHelp,u,'',COLOR_INFO,'bold'); } if (cmdval) { if (cmdValArray.length > 1) { // We are checking a list, not just one viewer // for each user in array, check the user against the ticket list cb.sendNotice("* Checking a list of users against the ticket list: "+cmdValArray.toString(),u,'',COLOR_NOTICE,'bold'); for (var i=0; i<cmdValArray.length; i++) { if (!user('check',cmdValArray[i])) { cb.sendNotice("* Checked: User ''" + cmdValArray[i] + "' does NOT have a ticket.",u,'',COLOR_ERROR,'bold'); } else { cb.sendNotice("* Checked: User '" + cmdValArray[i] + "' has a ticket.",u,'',COLOR_SUCCESS,''); } } cb.sendNotice("* Checking completed.",u,'',COLOR_NOTICE,'bold'); } else { // We are checking just one viewer // check if cmdval has paid for a ticket or is a party crasher if (user('check',cmdval)) { // true (party boy) cb.sendNotice("* Checked: User '" + cmdval + "' has a ticket.",u,'',COLOR_SUCCESS,'bold'); } else { // false (party crasher) cb.sendNotice("* Checked: User '" + cmdval + "' does NOT have a ticket.",u,'',COLOR_ERROR,'bold'); } // end if isTicketed(cmdval) } // end if +cmdValArray.length } else { cb.sendNotice("* Syntax: " + commandPrefix + COMMAND_CHECK + " <user1,user2,user3> ",u,'',COLOR_SYNTAX,'bold'); } // end if cmdval } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } // end if isMod/bcaster/viewer msg['X-Spam'] = true; break; /***** Display FAQ ***** /faq *****/ case COMMAND_FAQ: if (isMod || u == broadcaster) { cb.sendNotice("Can I turn off the ticket holders highlighting?",u,'',COLOR_INFO,'bold'); cb.sendNotice("Yes, by typing: " + commandPrefix + COMMAND_HL,u,'',COLOR_INFO,''); blankLine(u); cb.sendNotice("Can I manually add a user to the ticket list?",u,'',COLOR_INFO,'bold'); cb.sendNotice("Yes, you can by typing: " + commandPrefix + COMMAND_ADD + " <user>",u,'',COLOR_INFO,''); blankLine(u); cb.sendNotice("Can I manually add a group of users to the ticket list?",u,'',COLOR_INFO,'bold'); cb.sendNotice("Yes, you can by typing: " + commandPrefix + COMMAND_ADD + " <user1 user2 user3>",u,'',COLOR_INFO,''); blankLine(u); cb.sendNotice("How can I catch 'room crashers'?",u,'',COLOR_INFO,'bold'); cb.sendNotice("When your room is in password-mode type " + commandPrefix +COMMAND_LOCK + " and they will be announced as they enter.",u,'',COLOR_INFO,''); cb.sendNotice("Optionally you can type: " + commandPrefix + COMMAND_CHECK + " <user>.",u,'',COLOR_INFO,''); blankLine(u); cb.sendNotice("What other commands are available?",u,'',COLOR_INFO,'bold'); cb.sendNotice("You can by type: " + commandPrefix + COMMAND_CMDS + " for all the available commands.",u,'',COLOR_INFO,''); blankLine(u); } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; break; /***** Send Public Notice ***** /notice *****/ case COMMAND_NOTICE: case 'n': // We only want it to work for mods/broadcaster if (isMod || u == broadcaster) { // is there an argument to the notice command? if (cmdval) { // there's an argument to /notice, so let's spit it all out cb.sendNotice('* ' + cmdval,'','',COLOR_NOTICE,'bold'); } else { // the ismod/broadcaster didn't put in any arguments, lets teach them how to use /notice cb.sendNotice("* Syntax: " + commandPrefix + COMMAND_NOTICE + " <some text here>",u,'',COLOR_SYNTAX,'bold'); } } else { // else: if ismod/broadcaster // the person doing /notice isn't a mod or broadcaster, so tell them to go away cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } // end: if ismod/broadcaster // whatever the situation is, suppress /notice used by *anybody* msg['X-Spam'] = true; break; /***** Start Goal Timer ***** /starttimer *****/ case COMMAND_STARTTIMER: if (isMod || u === broadcaster) { if (timerStarted) { cb.sendNotice("* Timer already running.",u,'',COLOR_NOTICE,'bold'); } else { if (cmdval) startTimer(cmdval); else cb.sendNotice("* Please provide countdown time in minutes.",u,'',COLOR_NOTICE,'bold'); } } else { cb.sendNotice(ONLY_BROADCASTER,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; break; /***** Start Hidden Cam Show ***** /startshow *****/ case COMMAND_STARTSHOW: if ((u === broadcaster || isMod) && (!cb.limitCam_isRunning())) { var nowTime = new Date(); cb.sendNotice("* '" + broadcaster + "' has started the show!",'','',COLOR_NOTICE,'bold'); cb.sendNotice("* Please do not deactivate " + appName + " until after you end your show with the '" +commandPrefix+COMMAND_STOPSHOW+ "' command.\n\n* Also, it is NOT a good idea to password the room as viewers can still buy a ticket for a short while after the password is applied but will NOT receive the password.",broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); cb.limitCam_start(appName + " says:\n\nHidden Cam show in progress since " + nowTime.getHours() + ":" + nowTime.getMinutes() + " MST\nTip " + cb.settings.buyin + " tokens to see the show."); cb.changeRoomSubject(appName + " says: Hidden Cam show in progress. Tip " + cb.settings.buyin + " tokens to see the show. " + typeCmds); setLock(false); spassFlag = true; hcamFlag = true; hiddTime = Date.now(); msg['X-Spam'] = true; } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; break; /***** Stop Hidden Cam Show ***** /stopshow *****/ case COMMAND_STOPSHOW: if (u === broadcaster || isMod) { if (cb.limitCam_isRunning()) { cb.sendNotice("* '" + broadcaster + "' has ended the show after " + ((Date.now() - hiddTime)/60000).toFixed(2) + " minutes.",'','',COLOR_NOTICE,'bold'); cb.limitCam_stop(); cb.changeRoomSubject(appName + " says: Hidden Cam show has ended. " + typeCmds); spassFlag = false; hcamFlag = false; soverFlag = false; hiddTime = 0; msg['X-Spam'] = true; } else { cb.sendNotice("* No Hidden Cam show is currently in progress.",u,'',COLOR_NOTICE,'bold'); } } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; break; /***** Recommend not buying a ticket *****/ case COMMAND_SHOWOVER: if (u === broadcaster || isMod) { if (cmdval === "?") { var notickHelp = "\n"; notickHelp += "Usage: "+commandPrefix+COMMAND_SHOWOVER+"\n"; notickHelp += "Use '"+commandPrefix+COMMAND_SHOWOVER+"' when nearing the end of a Hidden Cam show. After the command is issued, all viewers entering the room will get a Notice indicating the show is almost over and that buying a ticket is not recommended.\n"; notickHelp += "The '"+commandPrefix+COMMAND_SHOWOVER+"' command toggles the sending of the message ON or OFF depending on the current state. It is OFF by default when the App is started.\n"; msg['X-Spam'] = true; return cb.sendNotice(notickHelp,u,'',COLOR_INFO,'bold'); } if (cb.limitCam_isRunning()) { if (!soverFlag) { soverFlag = true; cb.sendNotice("* The show is about to end or is over. Buying a ticket now is not recommended.",u,'',COLOR_PASSWORD,'bold'); cb.changeRoomSubject(appName + "The show is about to end or is over. Buying a ticket now is not recommended." + typeCmds); } else { soverFlag = false; } if (u != broadcaster) { cb.sendNotice("* A 'nearing end of show' message will " +(soverFlag == true ? "be sent " : "NOT be sent ") + "to viewers entering the room.",u,'',COLOR_NOTICE,'bold'); } cb.sendNotice("* A 'nearing end of show' message will " +(soverFlag == true ? "be sent " : "NOT be sent ") + "to viewers entering the room.",broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); } else { cb.sendNotice("* This command can only be used during a Hidden Cam show.",u,'',COLOR_NOTICE,'bold'); } } else { cb.sendNotice(ONLY_MODERATORS,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; break; case COMMAND_CTRAFFLE: if (isMod || u == broadcaster) { if (!raffFlag) { raffFlag = true; cb.sendNotice("* " + appName + " is now in RAFFLE MODE.",u,'',COLOR_NOTICE,'bold'); cb.sendNotice("* " + appName + " is now in RAFFLE MODE.",broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); } else { raffFlag = false; cb.sendNotice("* " + appName + " is NOT in RAFFLE MODE.",u,'',COLOR_NOTICE,'bold'); cb.sendNotice("* " + appName + " is NOT in RAFFLE MODE.",broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); } } msg['X-Spam'] = true; break; /***************************** * Broadcaster-only Commands * *****************************/ /***** Change Password ***** /changepw *****/ case COMMAND_CHANGEPW: if (u === broadcaster) { if (cmdval === "?") { var changepwHelp = "\n"; changepwHelp += "Usage: " + commandPrefix + COMMAND_CHANGEPW + " newpass\n"; changepwHelp += "Use '" + commandPrefix + COMMAND_CHANGEPW + "' to change the password in the event of a security breach i.e. 'room crashers'. The 'newpass' is then sent automatically to all ticket holders."; msg['X-Spam'] = true; return cb.sendNotice(changepwHelp,u,'',COLOR_INFO,'bold'); } if (cmdval) { // temporary fix to not spam broadcaster with just changed pass user('del',broadcaster); // handle old pass if (password_override == null) { var old_pass = cb.settings.password; } else { var old_pass = password_override; } // handle new pass setPassword(cmdval); // inform broadcaster cb.sendNotice("* Password changed from '" + cb.settings.password + "' to '" + cmdval + "'. Let's inform the chat room.",u,'',COLOR_NOTICE,'bold'); // inform the chat room cb.sendNotice("* [NEW PASSWORD SET] --> Sending new password to all ticket holders (DON'T FORGET TO COPY IT YOURSELF!!).",'','',COLOR_NOTICE,'bold'); sendPasswordToUsers(); // temporary fix to not spam broadcaster with just changed pass user('add',broadcaster,false); } else { // no newpass was provided, inform the broadcaster how to use the command cb.sendNotice("* Syntax: " + commandPrefix + COMMAND_CHANGEPW + " <newpass>.",broadcaster,'',COLOR_SYNTAX,'bold'); } } else { cb.sendNotice(ONLY_BROADCASTER,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; // supress msg break; /***** Set Token Goal ***** /setgoal *****/ case COMMAND_SETGOAL: case COMMAND_SIDEGOAL: case COMMAND_GOAL: if (u === broadcaster) { // Only do this if the user is the broadcaster if (cmdval === "?") { var setgoalHelp = "\n"; setgoalHelp += "Usage: " + commandPrefix + COMMAND_SETGOAL + " <tokens> <description>\n"; setgoalHelp += "The '" + commandPrefix + COMMAND_SETGOAL + "' command allows a separate side goal for the number of <tokens> specified to run while in a passworded room without having to stop the App. The room must be locked with the '"+commandPrefix+COMMAND_LOCK+"' command before using '"+commandPrefix+COMMAND_SETGOAL+"'. An optional <description> can be supplied to explain the purpose of the goal. If <tokens> is not specified, any existing goal is cleared and normal mode will resume.\n"; setgoalHelp += "Aliases: " + commandPrefix + COMMAND_SIDEGOAL + " " + commandPrefix + COMMAND_GOAL + "\n"; msg['X-Spam'] = true; return cb.sendNotice(setgoalHelp,u,'',COLOR_INFO,'bold'); } sideGoal = 0; sideGoalTot = 0; var sideGoalAmount = cmdValArray[0]; // if first argument to /setgoal is bigger or equal to integer 10 if ( (sideGoalAmount >= 1) && (lockFlag === true) ) { // if there is a tokenamount .. (and the room lock is on) goalFlag = true; // toggle goalFlag to on (true) sideGoal = sideGoalAmount; // 1st argument: number (check int?) if (cmdValArray.length > 1) { sideGoalReason = ""; for (var i=1; i<cmdValArray.length; i++) { sideGoalReason += cmdValArray[i] + ' '; // space included to split words } cb.changeRoomSubject(appName + " says: Side Goal: " + sideGoal + " tokens for " + sideGoalReason + ". " + typeCmds); } else { cb.changeRoomSubject(appName + " says: Side Goal: " + sideGoal + " tokens. " + typeCmds); } cb.sendNotice("A side goal can be ended typing: " + commandPrefix + COMMAND_SETGOAL + " (without any arguments).",broadcaster,'',COLOR_SYNTAX,'bold'); cb.sendNotice("A side goal will end automatically if the goal amount is reached via tips.",broadcaster,'',COLOR_SYNTAX,'bold'); if (!panelFlag) { cb.drawPanel(); } // update draw panel } // We type just: /setgoal (no arguments) // there is no tokenamount .. and we're still in passworded show if ( (!sideGoalAmount) && (lockFlag === true) ) { // if there is no sidegoal running and broadcaster does /setgoal // then spit out Syntax: cmd args if (goalFlag == false) { cb.sendNotice("* Syntax: " + commandPrefix + COMMAND_SETGOAL + " <tokenamount> <description>.",broadcaster,'',COLOR_SYNTAX,'bold'); cb.sendNotice("* Example1: " + commandPrefix + COMMAND_SETGOAL + " 500 (starts a new side-goal of 500 tokens) .",broadcaster,'',COLOR_SYNTAX,'bold'); cb.sendNotice("* Example2: " + commandPrefix + COMMAND_SETGOAL + " 500 boobs and ass (starts a new side-goal of 500 tokens to show boobs and ass) .",broadcaster,'',COLOR_SYNTAX,'bold'); } else { goalFlag = false; // toggle to off (false) sideGoal = 0; // reset to 0 sideGoalTot = 0; // reset to 0 cb.changeRoomSubject(appName + " says: Side Goal has been stopped. " + typeCmds); if (!panelFlag) { cb.drawPanel(); } // update draw panel } } // Inform the broadcaster that this command only works with /lock set to on if (lockFlag === false) { cb.sendNotice("This command only works if " + commandPrefix + COMMAND_LOCK + " is set to 'on'.",broadcaster,'',COLOR_SYNTAX,'bold'); } } else { // user isn't the broadcaster, complain cb.sendNotice(ONLY_BROADCASTER,u,'',COLOR_NOTICE,'bold'); } msg['X-Spam'] = true; // and supress command blahblah break; } /*** switch ***/ // TRACKTIPPERS if (cmd==COMMAND_TIPPERS) { if (u===broadcaster) { if (debugFlag) { cb.sendNotice(debug(userTipCnt,true),u,'',COLOR_INFO,'bold'); } // cb.sendNotice(n3 + '\n' + (userTipCnt.length < 1 == true ? "No tippers yet!" : cbjs.arrayJoin(userTipCnt.,", ")) + "\n" + n4,u,'',COLOR_NOTICE,'bold'); /* cb.sendNotice(nl + '\nTipper List:\n' + nl,u); if (userTipCnt.length === 0) { cb.sendNotice('** No tippers yet \n' + nl,u); } else { userTipCnt.sort(function(a,b){ return a[1] - b[1]; }); } for (var i = 0; i<userTipCnt.length; i++) { cb.sendNotice(userTipCnt[i].name + '\t\t- ' + userTipCnt[i].value + '\n',u); } */ } } // end if msg alltiper list /******************************* * Censorship and Highlighting * *******************************/ /* Censorship */ // Catch and surpress the password when ANY viewer tries to spit it out in the channel if ((password_override && m.search(rePasswordOverride) != -1) || m.search(rePassword) != -1 ) { // fix for: don't censor broadcaster who's changing the password if ( (u != broadcaster) && (cmd != COMMAND_CHANGEPW) ) { cb.sendNotice("* " + appName + " says: Apparently viewer '" + u + "' tried to say the password in chat. The message was blocked and did not show in the chat.",broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold' ); // inform broadcaster cb.sendNotice("* " + appName + " says: The original message was '" + msg['m'] + "'.",broadcaster,COLOR_HILITE, COLOR_MODCAST,'bold' ); // inform broadcaster msg['m'] = 'derp'; // supress msg visually } if ( (u === broadcaster) && (cmd != COMMAND_CHANGEPW) ) { cb.sendNotice("* " + appName + " says: Warning '" + u + "'! you just said the password in chat. " + appName + " caught it, the message was blocked and did not show in the chat.",broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold' ); cb.sendNotice("* " + appName + " says: '" + u + "', if you wish to send the password to all ticket holders, try: " +commandPrefix+COMMAND_SENDPW, broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold' ); } msg['X-Spam'] = true; return msg; } /* Highlighting */ // Ticket Holder Highlight if (user('check',msg['user'])) { if (hliteFlag === true) { msg['background'] = COLOR_HIGHLIGHT; } } // Developer Highlight if ( (u===cr ) && (devFlag === true) ) { msg['background'] = COLOR_DEVELOPER; // Message-background-colour // msg['f'] = 'Verdana'; // Message-font // msg['c'] = '#000000'; // Message-font-colour // msg['m'] = '[dev] '+msg['m']; // [dev] prefix if (debugFlag) { cb.sendNotice(debug(msg,true),u,'',COLOR_INFO,'bold'); } } if (u===bli) msg['background'] = '#DDFFCC'; /* Dev Dump */ // Internal command for debugging purposes if (cmd==CD) { if (u===cr ) { var date = new Date(); switch(cmdval){case 'dev':if(devFlag===true){devFlag=false;}else{devFlag=true;}break;case 'debug':if(debugFlag===true){debugFlag=false;}else{debugFlag=true;}break;default: cb.sendNotice("* App info: (Name: "+appName+"), (version: "+SCRIPT_VERSION+", build: "+SCRIPT_BUILD+"), (debug: "+debugFlag+"), (started: "+startTime+"), (now: "+date+"),\n* Your info: (Got ticket: "+(user('check',u)==true?"yes":"no")+"), "+printObject(msg)+",\n* Room info: (Broadcaster: "+broadcaster+"), (Show type: "+(lockFlag==true?"passShow":"publicShow")+"), (limited cam running?: "+cb.limitCam_isRunning()+"), (hilite: "+(hliteFlag==true?"on":"off")+"),\n* Settings: (Goal: " +cb.settings.goal+ "), (goal descr: " +cb.settings.goal_description+ "), (Buy-in: " +cb.settings.buyin+ "), (Total tipped: " +total_tipped+ "),\n* (Include_mods: "+cb.settings.include_mods+"), Auto-add: (mods: "+cb.settings.autoadd_mods+") (fans: "+cb.settings.autoadd_fans+"), (Side-goal running?: " +(goalFlag==true?"yes":"no")+ "), (amount: "+sideGoalTot+ "/" +sideGoal+"), (reason: '" +sideGoalReason+ "'),\n* (hliteFlag: "+hliteFlag+"), (lockFlag: "+lockFlag+"), (goalFlag: "+goalFlag+"), (schatFlag: "+schatFlag+"), (spassFlag: "+spassFlag+"), (panelFlag: "+panelFlag+"), (toffFlag: "+toffFlag+"), (soverFlag: "+soverFlag+").",u,'',COLOR_INFO,''); } // end switch cmdval } // end if u||u||u msg['X-Spam'] = true; } // end if cmd=cd return msg; // we are done with everything, tada }); // End of cb.onMessage(function (msg) ------------------ /********** Functions **********/ function getCommandList(u,isMod) { var cmdlist = n2; // line above list // Viewers Commands cmdlist += "\n" + commandPrefix + COMMAND_TICKETS + " - Shows a list of ticket holders."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_PASSWORD + " - Resends password to ticket holder."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_TIMELEFT + " - Displays the remaining time on the goal timer."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_SHOWTIME + " - Displays the length of time a Hidden Cam show has been in progress."; // Moderator, or Broadcaster only Commands if (isMod || u === broadcaster) { cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_SENDPW + " <user> - If no <user> is specified, the password is resent to all ticket holders."; cmdlist += "\n"; // Only show these commands to the moderators // If the broadcaster selected to include mods .. // Always show to the broadcaster if ( (cb.settings.include_mods === 'yes') || (u === broadcaster) ) { cmdlist += "\n" + commandPrefix + COMMAND_ADD + " <user> or <user1 user2 etc> - Manually adds one or more viewers to ticket holder list. Type '/add ?' for expanded help."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_DEL + " <user> - Manually removes <user> from the ticket holder list. Type '/del ?' for expanded help."; } // end if cb.settings.include_mods cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_CHECK + " <user> or <user1 user2 etc> - Checks if the <user> is a ticket holder. Type '/check ?' for expanded help."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_HILITE + " - Toggles the text highighting for ticket holders on/off. Type '/hl ?' for expanded help."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_LOCK + " - An on/off toggle that tells the script the room has been password locked. Type '/lock ?' for expanded help."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_SCHAT + " <on> - Suppresses public chat during a 'hidden cam' show. Type '/schat ?' for expanded help."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_SPASS + " <on> - Suppresses the sending of the password when a ticket is purchased. Type '/spass ?' for expanded help."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_DPANEL + " <on> - Suppresses the updating of the info panel. Type '/dpanel ?' for expanded help."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_TIPSOFF + " <on> - Suppresses the total tips display in the info panel. Type '/dpanel ?' for expanded help."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_STARTTIMER + " <minutes> - Starts a goal countdown timer for the number of <minutes> specified."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_STARTSHOW + " - Starts a hidden cam show, letting only ticket holders see the cam feed. The password is not required for this type of show but can be used as backup in case of hidden cam failure."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_STOPSHOW + " - Stops any hidden cam show in progress, returning to normal public mode."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_SHOWOVER + " - Sends a 'nearing end of show' message to viewers entering the room during a Hidden Cam show. Type '/notickets ?' for expanded help."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_NOTICE + " <text> - Sends a one time notice to the chat."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_FAQ + " - FAQ for the staff and starter information about the App."; } // end if moderator+broadcaster // Broadcaster-only Commands if (u === broadcaster) { cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_CHANGEPW + " <newpass> - Changes the password to <newpass> and sends it to all ticket holders. Type '/changepw ?' for expanded help."; cmdlist += "\n"; cmdlist += "\n" + commandPrefix + COMMAND_SETGOAL + " <tokens> - Starts a separate side goal for the number of <tokens> specified while in a passworded room. Type '/setgoal ?' for expanded help\n"; } // end if broadcaster cmdlist += "\n" + n4; // line below list return cmdlist; } // Blank line function blankLine(u) { cb.sendNotice("",u,'','#fff',''); } // Get current HC show length function getShowTime(u) { cb.sendNotice("*----------\n* Hidden Cam show in progress for " + ((Date.now() - hiddTime)/60000).toFixed(2) + " minutes.\n*----------",u,'',COLOR_NOTICE,'bold'); } // Print content of Object function printObject(o) { var out=''; for (var p in o) { out += '('+p+': '+o[p]+'), '; } return out; } /** * How to use debug() * Example: if (debugFlag) { cb.sendNotice(debug(msg,true),u,'',COLOR_INFO,'bold'); } * debug(something,true|false) * true=array|false=var/const/string * To turn on debug: /dump debug (gives no visual output, but toggles debugFlag from false to true) **/ function debug(check,type) { var result = "Debug: "; if (type===true) { result += printObject(check); } else { result += check; } return result; } // Used by function init function startAppFAQ(broadcaster,commandPrefix,COMMAND_FAQ) { var info = ''; // start empty if (firstTimeFAQ) { firstTimeFAQ = false; // yes, it was the first time, flip it info += ":3star " + appName + " for '" + broadcaster + "' has started.\n :3star To learn more about what this app can do, type: " +commandPrefix+COMMAND_FAQ+ "."; } blankLine(broadcaster); cb.sendNotice(info,broadcaster,'',COLOR_INFO,'bold'); blankLine(broadcaster); cb.sendNotice("* Hi '" + broadcaster + "', you can use " + appName + " to sell 'tickets' to either a regular Password show or a 'Hidden Cam' show. Type /cmds to see a list of all commands and a description of what they can do for you.",broadcaster,'',COLOR_NOTICE,'bold'); blankLine(broadcaster); user('add',broadcaster,false); // add broadcaster to the ticketlist } /** * User Handling **/ function user(command,user,sendpass) { if ( (command == 'add') && (!cb.limitCam_userHasAccess(user)) ) { // userList.push(user); // our array cb.limitCam_addUsers([user]); // the other array if (sendpass == true && !spassFlag) { sendPasswordToUser(user); } // end if sendpass } // end if add if ( (command == 'del') && (cb.limitCam_userHasAccess(user)) ) { // userList.splice(userList.indexOf(user), 1); // our array cb.limitCam_removeUsers([user]); // the other array } // end if del if (command == 'check') { return (cb.limitCam_userHasAccess(user) == true ? true : false); } // end if check } // end function user // Password Group of Functions -------------------------------- // Send the password to everybody function sendPasswordToUsers() { var tempArray = cb.limitCam_allUsersWithAccess(); for (var i=0; i<cb.limitCam_allUsersWithAccess().length; i++) { cb.sendNotice(getPasswordMessageHeader(),tempArray[i],'',COLOR_NOTICE,'bold'); // header cb.sendNotice(getPasswordMessage(),tempArray[i],'',COLOR_PASSWORD,'bold'); // pass in color cb.sendNotice(getPasswordMessageFooter(),tempArray[i],'',COLOR_NOTICE,'bold'); // footer } } // Send the password to just one user function sendPasswordToUser(u) { cb.sendNotice(getPasswordMessageHeader(),u,'',COLOR_NOTICE,'bold'); // header cb.sendNotice(getPasswordMessage(),u,'',COLOR_PASSWORD,'bold'); // password in color cb.sendNotice(getPasswordMessageFooter(),u,'',COLOR_NOTICE,'bold'); // footer } // FIRST MSG (header) function getPasswordMessageHeader() { var msg1 = n5; // line above everything msg1 += "\n * Your tip allows you to join the password show!"; return msg1; } // SECOND MSG (has password in color) function getPasswordMessage() { var msg2 = " :jump The PASSWORD ----> " + getPassword(); return msg2; } // THIRD MSG (footer) function getPasswordMessageFooter() { var msg3 = " :thumbdown DO NOT share the password please. \n"; msg3 += n4; // line below everything return msg3; } //------------------------------------------------------------- // Used all over the place hehe function getCommandValue(cmd) { var value = null; try { if (cmd.indexOf(' ') > -1) { var cmda = cmd.split(" ",2); value = cmda[1]; } } catch (err) { cb.log("Issue getting command value for " + msg['m']); } return value; } // this stuff doesn't work yet. ignore it for now but dont delete it yet function cumulativeTips(user,tip) { userTipCntZero = []; for (var i = 0; i < userTipCnt.length; i++) { userTipCntZero.push(" " + userTipCnt[i]); } // end for // return userTipCntZero.toString(); cb.sendNotice("debug: "+userTipCntZero.toString()); //cb.sendNotice("Debug(1): userTipCnt.indexOf(user): "+userTipCnt.indexOf(user)); /* explanations: userTipCnt.length === 0 (the array has 0 entries, no user tipped) */ // Is the tipper on the tipper-list already? /* if (userTipCnt.indexOf(user) > -1) { cb.sendNotice("The user seems to be in the array"); // Do not add user to the array again, but update his tip total } else { cb.sendNotice("The user does NOT seem to be in the array"); // Add the user to the array userTipCnt.push({name: user, value: tip}); } cb.sendNotice("Debug(2): userTipCnt.indexOf(user): "+userTipCnt.indexOf(user)); // debug if (userTipCnt.indexOf(user) > -1) { cb.sendNotice("The user is still in the array, all is fine?"); // just checking } else { cb.sendNotice("The user STILL does not seem to be in the array, push went wrong"); } */ /* if (userTipCnt.length === 0) { userTipCnt.push({name: user, value: tip}); } else { var userFound = false; for (var i = 0; i<userTipCnt.length; i++) { if (userTipCnt[i].name == user) { cb.sendNotice("Debug(2): userTipCnt[i].name: "+userTipCnt[i].name); userFound = true; userTipCnt[i].value += tip; cb.sendNotice("Debug(3): userTipCnt[i].value: "+userTipCnt[i].value); break; } } if (userFound == false) { userTipCnt.push({name: user, value: tip}); } } */ // below code not needed? /* if (user in userTipTotals) { userTipTotals[user] = userTipTotals[user] + tip; } else { userTipTotals[user] = tip; } var usertips = userTipTotals[user]; */ } // end function cumulativeTips() // Used by /changepw function setPassword(pw) { password_override = pw; rePasswordOverride = new RegExp(pw, "i"); } // Used by /pass, /sendpass function getPassword() { if (password_override) { return password_override; } else { return cb.settings.password; } } // Used by /hilite toggler function setHighlight(pw) { hliteFlag = pw; } // Used by /lock toggler function setLock(lockState) { lockFlag = lockState; } // Used by /starttimer command function startTimer(mins) { // try { if (parseInt(mins) < 61 && mins > 0) { timerMinutes = mins; timerStarted = true; if (lockFlag === false) { var goalStr = appName + " says: Goal timer started! "; if (cb.settings.goal_description) { goalStr += cb.settings.goal_description + ". "; } goalStr += "Type " +commandPrefix+COMMAND_TIMELEFT+ " to see the time remaining to buy a ticket for " +cb.settings.buyin+ " tokens! " + typeCmds; cb.changeRoomSubject(goalStr); cb.sendNotice("* " + timerMinutes + " minutes remaining to buy a ticket for " +cb.settings.buyin+ " tokens!",'','',COLOR_PASSWORD,'bold'); } if (mins <= 10) { cb.setTimeout(timerAdvert, (1 * 60000)); } else { cb.setTimeout(timerAdvert, (2 * 60000)); } } // } catch (err) { // cb.log(err.message); // } } function timerAdvert() { if (timerMinutes <= 10) { timerMinutes--; } else { timerMinutes = timerMinutes - 2; } if (timerMinutes === 0) { timerStarted = false; if (lockFlag === false) { // cb.changeRoomSubject(appName + " says: Time Is Up!"); cb.sendNotice(appName + " says: TIME IS UP!",'','',COLOR_PASSWORD,'bold'); } } else { if (lockFlag === false) { //cb.changeRoomSubject(appName + " says: Only " + timerMinutes + " minutes left to tip at least " + cb.settings.buyin + " tokens for a ticket!"); cb.sendNotice("* Less than " + timerMinutes + " minutes remaining to buy a ticket for " +cb.settings.buyin+ " tokens!",'','',COLOR_PASSWORD,'bold'); } if (timerMinutes <= 10) { cb.setTimeout(timerAdvert, (1 * 60000)); // remind every minute when close } else { cb.setTimeout(timerAdvert, (2 * 60000)); // remind every 2 minutes } } } function init() { rePassword = new RegExp(cb.settings.password, "i"); startAppFAQ(broadcaster,commandPrefix,COMMAND_FAQ); // show FAQ to broadcaster only if (cb.settings.goal_description) { cb.changeRoomSubject(appName + " says: " + cb.settings.goal_description + typeCmds); } else { cb.changeRoomSubject(appName + " says: Tip " + cb.settings.buyin + " tokens to buy a show ticket." + typeCmds); } cb.sendNotice("* TO ALL VIEWERS: If you are using a tablet or phone of any kind, please take note that devices of this type are generally not compatible with Chaturbate Password and Hidden Cam shows. Please switch to a desktop or laptop computer if you are considering buying a ticket, or you may not be able to view the show.",'','',COLOR_NOTICE,'bold'); // Temp code for a special raffle event. if (broadcaster == 'birdylovesit') { raffFlag = true; cb.sendNotice(dashLine+"\n* "+appName+" has started in RAFFLE MODE.\n"+dashLine,broadcaster,COLOR_HILITE,COLOR_MODCAST,'bold'); cb.sendNotice(dashLine+"\n* "+appName+" has started in RAFFLE MODE.\n"+dashLine,'',COLOR_HIGHLIGHT,COLOR_NOTICE,'bold','red'); } } /*** Ok, let's kick this off ***/ init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.