Apps Home
|
Create an App
TestAppFrostyjack
Author:
frostyjack101
Description
Source Code
Launch App
Current Users
Created by:
Frostyjack101
// Session variables var roomSubject = 'My Super Sexy Room'; var roomTags = ''; var modsCanRunCommands = false; // End session variables // Settings exposed to the user to choose from //cb.settings_choices = [ // {name:'roomSubject', type:'string', defultValue:roomSubject, label: 'Starting room subject'}, // {name:'listOfTags', type:'string', defultValue:'', label: 'Starting room tags'} //]; // End settings // COMMAND FRAMEWORK var commandList = { 'SetRoomSubject': setRoomSubject, 'SetRoomTags': setRoomTags, 'ToggleModCommandAbility' : flipModsCanRunCommands, 'LaunchKeepItGoing' : processKeepItGoing }; function setRoomSubject(tableOfSubjectWords) { roomSubject = tableOfSubjectWords.join(' '); cb.changeRoomSubject(roomSubject + ' ' + roomTags); } function setRoomTags(tableOfTags) { roomTags = tableOfTags.join(' '); cb.changeRoomSubject(roomSubject + ' ' + roomTags); } function flipModsCanRunCommands() { modsCanRunCommands = !modsCanRunCommands; cb.sendNotice('Mods can run commands: ' + modsCanRunCommands, cb.room_slug); } function processKeepItGoing(optionalArguments = null) { if (optionalArguments != null && optionalArguments.length == 3) { var tipThresholdToStart = optionalArguments[0]; var tipReduction = optionalArguments[1]; var tipReductionTime = optionalArguments[2]; keepItGoing(tipThresholdToStart, tipReduction, tipReductionTime); } else { keepItGoing(null,null,null); } } function processAdminCommand(adminCommand) { cb.sendNotice("Attempting Command", cb.room_slug); var argumentTable = adminCommand.split(' '); var currentCommand = argumentTable[0]; cb.sendNotice("Resolved Command" + currentCommand, cb.room_slug); if (commandList.hasOwnProperty(currentCommand)) { if (argumentTable.length > 1) { argumentTable.splice(0, 1); cb.sendNotice("Arguments Found: " + argumentTable.toString(), cb.room_slug); cb.sendNotice("Processing Command", cb.room_slug); commandList[currentCommand](argumentTable); } else { cb.sendNotice("No Arguments Found", cb.room_slug); cb.sendNotice("Processing Command", cb.room_slug); commandList[currentCommand](); } } } // END COMMAND FRAMEWORK // KEEP IT GOING FRAMEWORK var tipJar = 0; var increment = 0; var threshold = 0; var incrementTime = 0; var started = null; var keepItGoingRunning = false; function startDrawPanel(initiate) { if (!initiate) { cb.onDrawPanel(); cb.drawPanel() } else { cb.onDrawPanel(function(user) { var goingOrNot = (started != null); return { 'template': '3_rows_of_labels', 'row1_label': 'Tip Jar:', 'row1_value': tipJar, 'row2_label': 'Show Start Goal:', 'row2_value': threshold, 'row3_label': 'Show Is Going:', 'row3_value': goingOrNot }; }); cb.drawPanel() } } function keepItGoingIncrement() { tipJar = Math.max(tipJar - increment, 0); cb.drawPanel() started = cb.setTimeout(keepItGoingIncrement, incrementTime) } function keepItGoing (tipThresholdToStart, tipReduction, tipReductionTime) { if (started != null || tipThresholdToStart == null || tipThresholdToStart == undefined) { cb.sendNotice("Terminating [Keep It Going]"); cb.cancelTimeout(started); keepItGoingRunning = false; started = null; tipjar = 0; threshold = 0; increment = 0; startDrawPanel(false); } else if (tipThresholdToStart != null && tipThresholdToStart != undefined) { cb.sendNotice("Initializing [Keep It Going]"); cb.sendNotice("Threshold: " + tipThresholdToStart, cb.room_slug); cb.sendNotice("Reduction: " + tipReduction, cb.room_slug); cb.sendNotice("Reduction Time: " + tipReductionTime, cb.room_slug); tipJar = 0; threshold = tipThresholdToStart; increment = tipReduction; incrementTime = tipReductionTime * 1000; started = null; keepItGoingRunning = true; startDrawPanel(true); } } cb.onTip(function (tip) { if (keepItGoingRunning) { tipJar += parseInt(tip.amount); if (tipJar >= threshold && started == null) { cb.sendNotice("Threshold met! Starting show :)"); started = cb.setTimeout(keepItGoingIncrement, incrementTime) } cb.drawPanel() } }); // END KEEP IT GOING FRAMEWORK // This event fires each time a message is sent to the chat // Message is an object containing information about the sent message // Must return the message object, but can modify it here before it gets to the chat cb.onMessage(function (message) { if (message.has_tokens != true && !message.is_mod ) { message.m = ''; message['X-Spam'] = true; cb.sendNotice('You need at least one token to send messages', message.user, '', '', 'bolder'); } else if ((message.user == cb.room_slug || (message.is_mod && modsCanRunCommands)) && message.m[0] == '~') { processAdminCommand(message.m.substring(1)); message.m = ''; message['X-Spam'] = true; } return message; }); cb.onEnter(function(user) { cb.chatNotice('Welcome ' + user['user'] + '!'); });
© Copyright Chaturbate 2011- 2025. All Rights Reserved.