Apps Home
|
Create an App
asf234234
Author:
eberk123
Description
Source Code
Launch App
Current Users
Created by:
Eberk123
/* ******************************************************* * Title: KarenShow * Author: Ryan * ******************************************************* */ // vars var gEnableShow = true; var gTotalTipToday = 0; var gHighTipUsername = null; var gHighTipAmount = 0; var last_tip_username = null; var TIME_ONE_SEC = 1000; var TIME_ONE_MINUTE = 60 * TIME_ONE_SEC; var CONFIG_ADVERT_MINUTES = 1 * TIME_ONE_MINUTE; var EMOTE_STAR = ' :star_olivia_dellvine '; var EMOTE_STARS = EMOTE_STAR + EMOTE_STAR + EMOTE_STAR; var gOptOutList = new Array(); var gHashTag = '#karen #dice #show #cute #sexy #hot #bigroundeye #beautiful #pvt'; var gUsingLovense = false; var gSpecialUser = 'raccoon_pig'; var gShowSubject = true; // requires resetting too var playerStats = {}; var gameStats = {firstplace: '',secondplace: '',thirdplace: '',firsttips: 0,secondtips: 0,thirdtips: 0}; var gCurrentCommandArg = new Array(); // i'm abusing global variable here, this is used to store current command argument (only valid during command parsing) // you need to populate this, refer to init() for more information var gAdvertInformation = new Array(); var gCommandInformation = new Array(); // Karen show variable var gSetShowTimerCommand = '/settimer'; var gSetVoteRequirementCommand = '/setvote'; var gSetGoalPrizeCountCommand = '/setprizegoal'; var gSetGoalVoteCountCommand = '/setvotegoal'; var gAddPrizeCommand = '/addprize'; var gRemovePrizeCommand = '/removeprize'; var gGoalTarget = 1000; // goal target for voting session var gGoalCurrent = 0; // current goal target for voting session var gMiniGoalTarget = 200; // the goal target for random prize var gMiniGoalCurrent = 0; // current goal target var gVoteRequirement = 200; // number of votes required for the prize to be chosen var gVotePrize = new Array(); // track voting count of each available prize (key is 0 to N prize count - 1, data is vote count for goal) var gVotePrizeCount = 0; // each time we vote prize, this will increment by one (each time we process one vote prize, this will decrement by one) var gTimer = 0; // our timer for the voting goal var gTimerPaused = true; // control whether timer is paused var gPrizeList = [ "Spank Ass", "Close up on Boob", "Twerk Ass", "Play with Boob", "Play with left Boob", "Play with right Boob", "Flash Ass", "Pussy Flash", // N.A "Triple Flash" // N.A ]; var gVoteOptions = [ {text:"Remove Bra", time:10}, {text:"Remove Panties", time:10}, {text:"Nude", time:5}, {text:"Topless Dance", time:8}, {text:"Bottom off Dance", time:8} ]; cb.tipOptions(function(user) { // tip option only enabled when voting is in session, this allow user to continue tipping for messages if(gVotePrizeCount != 0) { var voteChoice = new Array(); for (var key in gVotePrize) { if (gVotePrize.hasOwnProperty(key)) { voteChoice.push({label: key}); } } return {options: voteChoice, label:"Every token is one vote:"}; } else { return; } }); /* SETTINGS */ cb.settings_choices = new Array(); /* ON TIP */ cb.onTip(function (tip) { if(gEnableShow) { last_tip_username = tip['from_user']; gTotalTipToday += tip['amount']; if(tip['amount'] > gHighTipAmount) { gHighTipAmount = tip['amount']; gHighTipUsername = tip['from_user']; } //IncrementAdvertMessagesCount(); if (last_tip_username in playerStats) { playerStats[last_tip_username].totaltips += tip['amount'] } else { playerStats[last_tip_username] = { totaltips: tip['amount'] } } // update tip statistic trackTips(last_tip_username, tip['amount']); if(inArray(last_tip_username, gOptOutList)) { notify(last_tip_username + ' opt out from prizes, tips will be ignored, type \'/opt\' to opt in/out from prizes'); } else { handleVoteGoal(tip['amount'], tip['from_user'], tip['message']); } } }); /* DRAW PANEL */ cb.onDrawPanel(function (user) { if(gEnableShow) { // when voting is in session we need to display top 3 votes if(gVotePrizeCount != 0) { var topVoteKey = GetTopVotePrize(); var secondVoteKey = GetSecondVotePrize(); var thirdVoteKey = GetThirdVotePrize(); return { 'template': '3_rows_of_labels', 'row1_label': 'First:', 'row1_value': topVoteKey + ' (' + gVotePrize[topVoteKey] + ' votes)', 'row2_label': 'Second:', 'row2_value': secondVoteKey + ' (' + gVotePrize[secondVoteKey] + ' votes)', 'row3_label': 'Third:', 'row3_value': thirdVoteKey + ' (' + gVotePrize[thirdVoteKey] + ' votes)' } } // else we show the normal stuff else { var timeInMinutes = Math.floor(gTimer/60); var timeInSeconds = gTimer % 60; var timeLeftText = timeInMinutes + ' min ' + timeInSeconds + ' sec'; if(timeInMinutes == 0 && timeInSeconds == 0) { timeLeftText = ' Ended'; } if(gTimerPaused) { timeLeftText = ' Paused'; } return { 'template': '3_rows_of_labels', 'row1_label': 'Token to random flash:', 'row1_value': (gMiniGoalTarget - gMiniGoalCurrent) + ' left', 'row2_label': 'Token to vote goal:', 'row2_value': (gGoalTarget - gGoalCurrent) + ' left', 'row3_label': 'Time Left:', 'row3_value': timeLeftText } } } }); /* START OF GAME SPECIFIC FUNCTION */ function AddPrize(prize) { if(!(prize in gVotePrize)) { gVotePrize[prize] = 0; return true; } return false; } function RemovePrize(prize) { if(prize in gVotePrize) { delete gVotePrize[prize]; updateSubject(); return true; } return false; } function RemovePrizeIndex(prizeIndex) { var index = 0; var prize = ''; for (var key in gVotePrize) { if (gVotePrize.hasOwnProperty(key)) { ++index; if(index == prizeIndex) { prize = key; } } } if(prize in gVotePrize) { delete gVotePrize[prize]; notify('Removing prize from voting list: ' + prize, 'roomHost', '#FFFFFF', '#FF0000'); updateSubject(); return true; } return false; } function InitVoteGoal() { // add all prize in default prize list for(var i = 0; i < gVoteOptions.length; ++i) { if(gVoteOptions[i].time != 0) { AddPrize(gVoteOptions[i].text + ' ' + gVoteOptions[i].time + 'min'); } else { AddPrize(gVoteOptions[i].text); } } } function ResetVoteGoal() { // reset all votes to zero for (var key in gVotePrize) { if (gVotePrize.hasOwnProperty(key)) { gVotePrize[key] = 0; } } } function GetTopVotePrize() { var topPrizeKey = ''; var topVoteCount = -1; for (var key in gVotePrize) { if (gVotePrize.hasOwnProperty(key)) { if(topVoteCount < gVotePrize[key]) { topVoteCount = gVotePrize[key]; topPrizeKey = key; } } } return topPrizeKey; } function GetVoteList() { var text = 'KarenVoteGoal game rule:\n'; text += 'Voting session will also be held at every ' + gGoalTarget + ' goal\n'; text += 'You can vote by tipping and choosing your vote in the tip option (only during voting session)\n'; text += 'Voting session ends when we hit the vote requirement (' + gVoteRequirement + ' votes)\n\n'; text += 'Poll:\n'; var index = 1; for (var key in gVotePrize) { if (gVotePrize.hasOwnProperty(key)) { text += index + ') ' + key + ' - ' + gVotePrize[key] + ' votes\n'; ++index; } } return text; } // not the smartest way to implement, but i'm lazy function GetSecondVotePrize() { var topVoteKey = GetTopVotePrize(); var secondPrizeKey = ''; var topVoteCount = -1; for (var key in gVotePrize) { if (gVotePrize.hasOwnProperty(key) && key != topVoteKey) { if(topVoteCount < gVotePrize[key]) { topVoteCount = gVotePrize[key]; secondPrizeKey = key; } } } return secondPrizeKey; } // not the smartest way to implement, but i'm lazy function GetThirdVotePrize() { var topVoteKey = GetTopVotePrize(); var secondVoteKey = GetSecondVotePrize(); var thirdPrizeKey = ''; var topVoteCount = -1; for (var key in gVotePrize) { if (gVotePrize.hasOwnProperty(key) && key != topVoteKey && key != secondVoteKey) { if(topVoteCount < gVotePrize[key]) { topVoteCount = gVotePrize[key]; thirdPrizeKey = key; } } } return thirdPrizeKey; } function HandleVoteGoalWin(votePrize) { // if we hit the vote requirement for anyone, mark it as prize won if(gVotePrize[votePrize] >= gVoteRequirement) { ResetVoteGoal(); --gVotePrizeCount; notify('Vote requirement reached!!! Prize won: ' + EMOTE_STARS + votePrize + EMOTE_STARS, null, '#FFFFFF', '#000000', null); } } function GetRandomPrize() { return gPrizeList[Math.floor(Math.random() * (gPrizeList.length - 2))]; } function handleVoteGoal(tipAmount, user, votePrize) { gMiniGoalCurrent += tipAmount; // ensure we don't add to the goal if it exceed if(gVotePrizeCount == 0) { gGoalCurrent += tipAmount; } // if voting is in session, all tip will contribute to the votes // NOTE: must be processed before we count goal, cause we don't want current vote // to affect voting if(gVotePrizeCount != 0) { // if no vote is chosen, the current top vote will be chosen as default if(votePrize == '') { votePrize = GetTopVotePrize(); } gVotePrize[votePrize] += tipAmount; notify(user + ' bought ' + tipAmount + ' votes for ' + votePrize, null, '#FFFFFF', '#000000', null); HandleVoteGoalWin(votePrize); } var prizeCount = 0; while(gMiniGoalCurrent >= gMiniGoalTarget) { ++prizeCount; gMiniGoalCurrent -= gMiniGoalTarget; // need to roll for a random prize notify('Prize won for reaching flash goal: ' + EMOTE_STARS + GetRandomPrize() + EMOTE_STARS); // ensure we don't get a wall of prize if(prizeCount >= 10) { gMiniGoalCurrent = 0; break; } } // each time we hit the goal increment prize count if(gGoalCurrent >= gGoalTarget) { // NOTE: we reset so it can only be 1 at max gGoalCurrent = 0; ++gVotePrizeCount; } // need to update subject and drawboard each time someone tip updateSubject(); } /* Initialization */ function init() { // this ensure app restart doesn't screw up gHighTipUsername = null; gHighTipAmount = 0; last_tip_username = null; // you need to populate this gAdvertInformation = new Array(); gCommandInformation = new Array(); playerStats = {}; initCommand(); // initialize our required information for notification // it's given in a key value pair where key refers to the function to trigger the notification // intialTimer refers to the initial timer before it's fired // periodicTimer refers to the periodic timer after the first firing // minMsgCount refers to the minimum number of messages before the message can fire (this prevent us from spamming the room when no one is typing) // maxNoFireCount refers to the max number of time we can avoid firing the notification before we will force it to fire gAdvertInformation[advertGamerules] = { initialTimer: 0.1 * CONFIG_ADVERT_MINUTES, periodicTimer: CONFIG_ADVERT_MINUTES, minMsgCount: 20, maxNoFireCount: 4}; gAdvertInformation[advertLeaderboard] = { initialTimer: 0.5 * CONFIG_ADVERT_MINUTES, periodicTimer: CONFIG_ADVERT_MINUTES, minMsgCount: 10, maxNoFireCount: 7 }; gAdvertInformation[advertTimerCountdown] = { initialTimer: TIME_ONE_SEC, periodicTimer: TIME_ONE_SEC, minMsgCount: 0, maxNoFireCount: 0 }; // start our periodic timer // automatically initialize those required variable, this is basically constructor in c++ class for (var key in gAdvertInformation) { if (gAdvertInformation.hasOwnProperty(key)) { gAdvertInformation[key].currentMsgCount = 0; // number of msg we have seen since we last fire it gAdvertInformation[key].missedFireCount = gAdvertInformation[key].maxNoFireCount; // number of time we skipped firing the messages (set to max to ensure it's fired) } } cb.setTimeout(advertLeaderboard, gAdvertInformation[advertLeaderboard].initialTimer); cb.setTimeout(advertTimerCountdown, gAdvertInformation[advertTimerCountdown].initialTimer); cb.setTimeout(advertGamerules, gAdvertInformation[advertGamerules].initialTimer); InitVoteGoal(); updateSubject(); } init(); /* Helper function */ function initCommand() { gCommandInformation = new Array(); // initialize our command information // public command gCommandInformation['/help'] = { callBackFcn: handleHelpCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'display all available command in KarenKeno' }; gCommandInformation['/leaderboard'] = { callBackFcn: handleLeaderBoardCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'display KarenKeno Leaderboard' }; gCommandInformation['/opt'] = { callBackFcn: handleOptCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'Opt in or out of prize' }; gCommandInformation['/polls'] = { callBackFcn: handleVotesListing, userGroupCallBackFcn: checkIsViewer, helpText: 'Show existing votes' }; gCommandInformation['/poll'] = { callBackFcn: handleVotesListing, userGroupCallBackFcn: checkIsViewer, helpText: 'Show existing votes' }; gCommandInformation['/prize'] = { callBackFcn: handlePrizeListing, userGroupCallBackFcn: checkIsViewer, helpText: 'Show prize list' }; gCommandInformation['/prizes'] = { callBackFcn: handlePrizeListing, userGroupCallBackFcn: checkIsViewer, helpText: 'Show prize list' }; gCommandInformation['/p'] = { callBackFcn: handlePrizeListing, userGroupCallBackFcn: checkIsViewer, helpText: 'Show prize list' }; gCommandInformation['!p'] = { callBackFcn: handlePrizeListing, userGroupCallBackFcn: checkIsViewer, helpText: 'Show prize list' }; // privilege user command gCommandInformation['/helpall'] = { callBackFcn: handleHelpCommandAll, userGroupCallBackFcn: checkHasPrivileges, helpText: 'send /help to everyone' }; gCommandInformation['/hashtaglovense'] = { callBackFcn: handleToggleHashtagLovense, userGroupCallBackFcn: checkHasPrivileges, helpText: 'Toggle hashtag for lovense' }; gCommandInformation['/leaderboardall'] = { callBackFcn: handleLeaderBoardCommandAll, userGroupCallBackFcn: checkHasPrivileges, helpText: 'send /leaderboard to everyone' }; gCommandInformation['/pollall'] = { callBackFcn: handleVotesListingAll, userGroupCallBackFcn: checkIsViewer, helpText: 'Send existing vote to everyone' }; gCommandInformation['/prizeall'] = { callBackFcn: handlePrizeListingAll, userGroupCallBackFcn: checkIsViewer, helpText: 'Send prize list to everyone' }; // host command gCommandInformation['/totaltoken'] = { callBackFcn: handleTotalTokenCommand, userGroupCallBackFcn: checkIsHost, helpText: 'show total token gained so far' }; gCommandInformation['/toggleshowsubject'] = { callBackFcn: handleToggleUseSubject, userGroupCallBackFcn: checkIsHost, helpText: 'Toggle usage of show subject' }; gCommandInformation['/enableshow'] = { callBackFcn: handleEnableShow, userGroupCallBackFcn: checkIsHost, helpText: 'Enable/Disable the show' }; gCommandInformation['/pause'] = { callBackFcn: handlePauseTimer, userGroupCallBackFcn: checkIsHost, helpText: 'Toggle pause show' }; gCommandInformation[gSetShowTimerCommand] = { callBackFcn: handleShowTimerCommand, userGroupCallBackFcn: checkIsHost, helpText: '\'' + gSetShowTimerCommand + ' <new_amount>\' will change our show timer' }; gCommandInformation[gSetGoalPrizeCountCommand] = { callBackFcn: handleGoalPrizeCommand, userGroupCallBackFcn: checkIsHost, helpText: '\'' + gSetGoalPrizeCountCommand + ' <new_amount>\' will change our goal count requirement for prizes' }; gCommandInformation[gSetGoalVoteCountCommand] = { callBackFcn: handleGoalVoteCommand, userGroupCallBackFcn: checkIsHost, helpText: '\'' + gSetGoalVoteCountCommand + ' <new_amount>\' will change our goal count requirement for voting' }; gCommandInformation[gSetVoteRequirementCommand] = { callBackFcn: handleVoteRequirementCommand, userGroupCallBackFcn: checkIsHost, helpText: '\'' + gSetVoteRequirementCommand + ' <new_amount>\' will change our goal count requirement for voting' }; gCommandInformation[gAddPrizeCommand] = { callBackFcn: handleAddPrizeCommand, userGroupCallBackFcn: checkIsHost, helpText: '\'' + gAddPrizeCommand + ' <prize>\' will add a new prize to our voting list' }; gCommandInformation[gRemovePrizeCommand] = { callBackFcn: handleRemovePrizeCommand, userGroupCallBackFcn: checkIsHost, helpText: '\'' + gRemovePrizeCommand + ' <prize>\' will remove the prize from our voting list' }; } // recurring advertisement on how to play karen jackpot function advertGamerules() { var text = ''; if(gEnableShow) { text += '==========================================================\n'; text += 'KarenVoteGoal game rule:\n'; text += 'A random prize will be chosen at every ' + gMiniGoalTarget + ' token\n'; text += 'Voting session will be held at every ' + gGoalTarget + ' token\n'; text += 'You can vote by tipping and choosing your vote in the tip option (only during voting session)\n'; text += 'Voting session ends when we hit the vote requirement (' + gVoteRequirement + ' votes)\n\n'; text += 'Type \'/prize\' to view possible random prizes\n'; text += 'Type \'/poll\' to view current votes and your vote choice\n'; text += '=========================================================='; } handleAdvertFiring(text, '', '', '', 'bold', advertGamerules); } function advertTimerCountdown() { var text = ''; // only subtract timer if show has started and is not currently paused if(!gTimerPaused && gTimer > 0) { gTimer -= 1; // drop timer by 1 second if(gTimer == 0) { gTimerPaused = true; notify(':thatsallfolks Tip to start the next show!', null, '#FFFFFF', '#000000', null); notify(':thatsallfolks Tip to start the next show!', null, '#FFFFFF', '#000000', null); notify(':thatsallfolks Tip to start the next show!', null, '#FFFFFF', '#000000', null); updateSubject(); } // everytime we update timer, we need to update the draw panel to ensure our show timer is properly updated cb.drawPanel(); } handleAdvertFiring(text, '', '', '', 'bold', advertTimerCountdown); } function handleToggleHashtagLovense(msg) { gUsingLovense = !gUsingLovense; updateSubject(); } function handleShowTimerCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var newGoalVal = parseInt(text.substr(gSetShowTimerCommand.length)); if(newGoalVal != 0) { newGoalVal *= 60; gTimer = newGoalVal; updateSubject(); notify('Show length changed to: ' + newGoalVal, 'roomHost', '#FFFFFF', '#FF0000'); } else { notify('Use only integer for goal', 'roomHost'); } } function handleGoalPrizeCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var newGoalVal = parseInt(text.substr(gSetGoalPrizeCountCommand.length)); if(newGoalVal != 0) { gMiniGoalTarget = newGoalVal; // ensure we are just one away from goal, this prevent stupid negative token when we reduce it below current value if(gMiniGoalCurrent >= gMiniGoalTarget) { gMiniGoalCurrent = gMiniGoalTarget - 1; } notify('Goal for prizes changed to: ' + gMiniGoalTarget, 'roomHost', '#FFFFFF', '#FF0000'); // everytime we update this we need to update subject and drawboard updateSubject(); } else { notify('Goal must be larger than 0', 'roomHost'); } } function handleGoalVoteCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var newGoalVal = parseInt(text.substr(gSetGoalVoteCountCommand.length)); if(newGoalVal != 0) { gGoalTarget = newGoalVal; if(gGoalCount >= gGoalTarget) { gGoalCount = gGoalTarget - 1; } notify('Goal count for voting changed to: ' + gGoalTarget, 'roomHost', '#FFFFFF', '#FF0000'); // everytime we update this we need to update subject and drawboard updateSubject(); } else { notify('Goal must be larger than 0', 'roomHost'); } } function handleVoteRequirementCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var newGoalVal = parseInt(text.substr(gSetVoteRequirementCommand.length)); if(newGoalVal != 0) { gVoteRequirement = newGoalVal; notify('Vote requirement changed to: ' + gVoteRequirement, 'roomHost', '#FFFFFF', '#FF0000'); // everytime we update this we need to update subject and drawboard updateSubject(); } else { notify('Goal must be larger than 0', 'roomHost'); } } function handleAddPrizeCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var prize = text.substr(gAddPrizeCommand.length); if(prize != '') { if(AddPrize(prize)) { notify('Adding new prize to voting list: ' + prize, 'roomHost', '#FFFFFF', '#FF0000'); updateSubject(); } } } function handleRemovePrizeCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var prizeIndex = parseInt(text.substr(gRemovePrizeCommand.length)); if(prizeIndex != '') { RemovePrizeIndex(prizeIndex); // everytime we update this we need to update subject and drawboard updateSubject(); } } function updateSubject() { var newSubject = ''; newSubject += (gMiniGoalTarget - gMiniGoalCurrent) + ' token to next random flash! ' + (gGoalTarget - gGoalCurrent) + ' token left to vote goal!'; if(gUsingLovense) { newSubject += ' #lovense '; } cb.drawPanel(); if(gShowSubject) { newSubject += gHashTag; cb.changeRoomSubject(newSubject); } else { notify(newSubject); } } /* END OF GAME SPECIFIC FUNCTION */ function IncrementAdvertMessagesCount() { // everytime we see a message, increment everyone's message count for (var key in gAdvertInformation) { if (gAdvertInformation.hasOwnProperty(key)) { ++gAdvertInformation[key].currentMsgCount; } } } /* ON MESSAGE */ cb.onMessage(function (msg) { var msgString = msg['m'].trim(); var isCommand = msgString.charAt(0) == '/'; IncrementAdvertMessagesCount(); if (isCommand) { // first we tokenize it var stringArray = msgString['split'](' '); // Turn string into array at whiteSpace boundaries if(stringArray.length != 0) { // first word is the command var command = stringArray[0].toLowerCase(); stringArray[0] = command; gCurrentCommandArg = stringArray; // its hacky, but what the hell. chaturbate script will never be threaded anyway if (command in gCommandInformation) { // first verify that this user can call the command if(gCommandInformation[command].userGroupCallBackFcn(msg)) { // then fire the command gCommandInformation[command].callBackFcn(msg); } } // inform user that it's an invalid command so they dont go wondering why nothing happens else { //notify('Unrecognized command: ' + command, null, '#FFFFFF', '#FF0000', null); } } } return msg; }); // recurring advertisement on leaderboard function advertLeaderboard() { var text = getLeaderBoard(); handleAdvertFiring(text, null, '#FFFFFF', '#000000', '', advertLeaderboard); } // this function handles the notification firing mechanism, all you have to pass in are the information on what to show (if it fires) // and the function name, cause the rest of them are handled automatically function handleAdvertFiring(text, userGroup, backgroundColor, foregroundColor, textEffect, functionName) { if(gEnableShow) { // if there's a need to fire it, fire it! if(gAdvertInformation[functionName].currentMsgCount >= gAdvertInformation[functionName].minMsgCount || gAdvertInformation[functionName].missedFireCount >= gAdvertInformation[functionName].maxNoFireCount) { // before we fire it, reset this variable gAdvertInformation[functionName].currentMsgCount = 0; gAdvertInformation[functionName].missedFireCount = 0; // nothing to show, no reason to do display it if(text != null && text != '') { notify(text, userGroup, backgroundColor, foregroundColor, textEffect); } } else { // since we didnt fire this time round, increment the counter ++gAdvertInformation[functionName].missedFireCount; } } // either way we schedule the timer for firing again cb.setTimeout(functionName, gAdvertInformation[functionName].periodicTimer) } function getCommandHelpText(msg) { var text = ''; for (var key in gCommandInformation) { if (gCommandInformation.hasOwnProperty(key) && gCommandInformation[key].userGroupCallBackFcn(msg)) { text += key + ' - ' + gCommandInformation[key].helpText + '\x0A'; } } return text; } function handleHelpCommand(msg) { msg['m'] = msg['m'] + " (Available command sent to " + msg['user'] + ")"; notify(getCommandHelpText(msg), msg['user'], '#FFFFFF', '#BB8FCE', null); } function GetPrizeList() { var text = 'A random prize will be chosen at every ' + gMiniGoalTarget + ' token\n\n'; text += 'Prizes:\n'; for(var i = 0; i < gPrizeList.length; ++i) { text += (i + 1) + ') ' + gPrizeList[i] + '\n'; } return text; } function handlePrizeListing(msg) { msg['m'] = msg['m'] + " (Prize list sent to " + msg['user'] + ")"; notify(GetPrizeList(), msg['user'], '#FFFFFF', '#000000', null); } function handlePrizeListingAll(msg) { msg['m'] = msg['m'] + " (Prize list sent to all)"; notify(GetPrizeList(), '', '#FFFFFF', '#000000', null); } function handleVotesListing(msg) { msg['m'] = msg['m'] + " (Existing vote sent to " + msg['user'] + ")"; notify(GetVoteList(), msg['user'], '#FFFFFF', '#000000', null); } function handleLeaderBoardCommand(msg) { msg['m'] = msg['m'] + " (leaderboard sent to " + msg['user'] + ")"; cb.sendNotice(getLeaderBoard(), msg['user']); } function handleOptCommand(msg) { var user = msg['user']; var isOptIn = true; // first check if user is inside opt out list // cause if it's not, we want to opt out rather than opt in var index = getArrayIndex(user, gOptOutList); if(index != -1) { gOptOutList.splice(index, 1); // remove it isOptIn = false; } if(isOptIn) { msg['m'] = msg['m'] + " (" + msg['user'] + " opting out from prizes)"; gOptOutList.push(user); } else { msg['m'] = msg['m'] + " (" + msg['user'] + " opting in for prizes)"; } } function handleHelpCommandAll(msg) { msg['m'] = msg['m'] + " (Available command sent to all)"; notify(getCommandHelpText(msg), '', '#FFFFFF', '#BB8FCE', null); } function handleVotesListingAll(msg) { msg['m'] = msg['m'] + " (Existing vote sent to all)"; notify(GetVoteList(), '', '#FFFFFF', '#000000', null); } function handleLeaderBoardCommandAll(msg) { msg['m'] = msg['m'] + " (leaderboard sent to all)"; cb.sendNotice(getLeaderBoard()) } function handleTotalTokenCommand(msg) { msg['X-Spam'] = true; // we want to hide this command from showing up notify('Total Token earn so far: ' + gTotalTipToday, 'roomHost', '#FFFFFF', '#FF0000'); } function handleToggleUseSubject(msg) { msg['X-Spam'] = true; // we want to hide this command from showing up gShowSubject = !gShowSubject; if(gShowSubject) { updateSubject(); } notify('Use Karen Show Subject changed to: ' + gShowSubject, 'roomHost', '#FFFFFF', '#FF0000'); } function handleEnableShow(msg) { msg['X-Spam'] = true; // we want to hide this command from showing up gEnableShow = !gEnableShow; updateSubject(); notify('Enable KarenShow App changed to: ' + gEnableShow, 'roomHost', '#FFFFFF', '#FF0000'); } function handlePauseTimer(msg) { msg['X-Spam'] = true; // we want to hide this command from showing up gTimerPaused = !gTimerPaused; if(!gTimerPaused) { notify(':showtime_', null, '#FFFFFF', '#000000', null); notify(':showtime_', null, '#FFFFFF', '#000000', null); notify(':showtime_', null, '#FFFFFF', '#000000', null); } updateSubject(); notify('Timer Paused changed to: ' + gTimerPaused, 'roomHost', '#FFFFFF', '#FF0000'); } function checkHasToken(msg) { return msg['has_tokens']; } function checkHasPrivileges(msg) { return checkIsFan(msg) || checkIsMod(msg) || checkIsHost(msg); } // everyone is viewer! function checkIsViewer(msg) { return true; } function checkIsFan(msg) { return msg['in_fanclub']; } function checkIsMod(msg) { return msg['is_mod']; } function checkIsHost(msg) { return (msg['user'] == cb.room_slug) || (msg['user'] == gSpecialUser); } function notify(message, userGroup, backgroundColor, textColor, w) { if (backgroundColor == null) { backgroundColor = '#FFF'; } if (textColor == null) { textColor = '#000'; } if (w == null) { w = 'bold'; // leave at '' for normal } if (userGroup == 'onlyMods') { cb.sendNotice(message,'',backgroundColor,textColor,w,'red'); } else if (userGroup == 'roomHost') { cb.sendNotice(message,cb.room_slug,backgroundColor,textColor,w); cb.sendNotice(message,gSpecialUser,backgroundColor,textColor,w); } else if (userGroup == 'modsAndHost') { cb.sendNotice(message,'',backgroundColor,textColor,w,'red'); cb.sendNotice(message,cb.room_slug,backgroundColor,textColor,w); } else if (userGroup == null) { cb.sendNotice(message,'',backgroundColor,textColor,w); } else { cb.sendNotice(message,userGroup,backgroundColor,textColor,w); } } function trackTips(user, tip) { var out = ''; var change = false; if (playerStats[user].totaltips > gameStats.firsttips) { if (gameStats.firstplace != user) { change = true; if (gameStats.secondplace != user) { gameStats.thirdplace = gameStats.secondplace; gameStats.thirdtips = gameStats.secondtips } gameStats.secondplace = gameStats.firstplace; gameStats.secondtips = gameStats.firsttips; gameStats.firstplace = user } gameStats.firsttips = playerStats[user].totaltips; if (change) out += user + ' is the new MVP! ' + getLeaderBoard() } else if (playerStats[user].totaltips > gameStats.secondtips) { if (gameStats.secondplace != user) { change = true; gameStats.thirdplace = gameStats.secondplace; gameStats.thirdtips = gameStats.secondtips; gameStats.secondplace = user } gameStats.secondtips = playerStats[user].totaltips; if (change) out += user + ' takes second! ' + getLeaderBoard() } else if (playerStats[user].totaltips > gameStats.thirdtips) { if (gameStats.thirdplace != user) { change = true; gameStats.thirdplace = user } gameStats.thirdtips = playerStats[user].totaltips; if (change) out += user + ' takes third! ' + getLeaderBoard() } if (out != '') cb.sendNotice(out) } function getLeaderBoard() { var out = ''; if (gameStats.firstplace && gameStats.firstplace != '') out += 'Leaders - 1. ' + gameStats.firstplace + ' (' + gameStats.firsttips + ') '; if (gameStats.secondplace && gameStats.secondplace != '') out += ' 2. ' + gameStats.secondplace + ' (' + gameStats.secondtips + ') '; if (gameStats.thirdplace && gameStats.thirdplace != '') out += ' 3. ' + gameStats.thirdplace + ' (' + gameStats.thirdtips + ') '; if (out == '') out += 'No leaders yet. Please tip to play!'; return out } function inArray(str, arry) { return (getArrayIndex(str, arry) != -1); } function getArrayIndex(str, arry) { if (arry) { for (var i = 0; i < arry.length; i++) { if (arry[i] == str) { return i; } } } return -1; }
© Copyright Chaturbate 2011- 2025. All Rights Reserved.