Apps Home
|
Create an App
Tipjar8-18-20
Author:
ceromus
Description
Source Code
Launch App
Current Users
Created by:
Ceromus
/********************************************************************************* Author: ACOOLA Title: Keep It Going Description: If the tips keep coming it, the broadcaster can keep the show going! Change Log: v1.0 - 2012-12-15: Initial Release. Set Tip Jar, Reduce Speed, Reduce By v1.1 - 2012-12-16: Added Room Subject Line Option Broadcaster panel stats added, including Total Tips Room Subject changes depending on Tip Jar v1.2 - 2012-12-16: Added 'help' and 'stats' Broadcaster/Mod ability to change Emptying Tip Jar speed v1.3 - 2012-12-19: Removed Initial goal limit reset If tip jar empties, app doesn't go back to Initial Goal v1.4 - 2013-01-03: Added Extra controls (Fastest, Slowest, Pause, Resume) Developer chat color set to help user/mods with app v1.5 - 2013-01-30: Changed last tipper to big tipper. Created array of tippers to see how much each person tipped. **********************************************************************************/ var isItGoing = 0; var goalMet = 0; var tipJar = 0; var totalTip = 0; var showOrNot = ""; var roomName = cb.settings.room_name; var startApp = new Date(); var startAt = cb.settings.get_it_going; //var lastTipper = ''; var reduceTJ = cb.settings.reduce_tip_jar * 1000; var reduceBy = cb.settings.reduce_tips_by; var resumeShow = reduceBy; var bigTipper = "--"; var bigTip = 0; var bigTipLocation = -1; var topTipper = new Array(); var ttLength = 0; cb.changeRoomSubject(roomName + ' [Start Tipping]'); cb.setTimeout(checkJar, reduceTJ); cb.chatNotice("Type '/stats' to see statistics."); cb.chatNotice("Broadcasters and Mods: Type '/help' to see additional functions."); function checkJar() { if(isItGoing == 1) { if(tipJar>0) { tipJar=tipJar-reduceBy; if(tipJar<0) { resetApp(); } } else { resetApp(); } } cb.setTimeout(checkJar, reduceTJ); cb.drawPanel(); } function checkTip(u,t) { var exists = 0; var location = 0; for (i=0;i<topTipper.length;i++){ if(topTipper[i].username == u) { exists = 1; location = i; } } if (exists == 1) { topTipper[location].amount += t; } else { var tipper=new Object(); tipper.username=u; tipper.amount=t; topTipper[ttLength] = tipper; ttLength++; } for (i=0;i<topTipper.length;i++){ if(topTipper[i].amount > bigTip) { bigTip = topTipper[i].amount; bigTipLocation = i; } } bigTipper = topTipper[bigTipLocation].username + "(" + topTipper[bigTipLocation].amount + ")"; } function printTokens(x) { cb.chatNotice("*** Keep It Going - Tokens Earned by User ***",x); for (i=0;i<topTipper.length;i++) { cb.chatNotice(topTipper[i].username + " (" + topTipper[i].amount + ")",x); } cb.chatNotice("Total Tips: " + totalTip,x); } function resetApp() { tipJar = 0; isItGoing = 0; cb.changeRoomSubject(roomName + " - [Show Stopping - Start Tipping to start it again]"); } function chageTimer(x) { if (x == 'Faster') { if (reduceTJ > 1000) { reduceTJ -= 1000; } } else if (x=='Slower') { if (reduceTJ < 60000) { reduceTJ += 1000; } } else if (x=='Fastest') { reduceTJ = 1000; } else if (x=='Slowest') { reduceTJ = 60000; } else if (x=='Pause') { reduceBy=0; } else if (x=='Resume') { reduceBy=resumeShow; } } function printHelp(x) { var help = "*** Keep It Going App - Help ***\n"; help += "If 'Show Is On' is in the Keep It Going Status, start your show\n"; help += "If 'STOP SHOW!!' is in the Keep It Going Status, stop your show\n"; help += "You can control how quickly the Tip Jar empties:\n"; help += "Type '/faster' to speed up emptying the Tip Jar\n"; help += "Type '/slower' to slow down emptying the Tip Jar\n"; help += "Type '/fastest' to set emptying Tip Jar Rate to 1 sec\n"; help += "Type '/slowest' to set emptying Tip Jar Rate to 60 secs\n"; help += "Type '/resume' to resume Tip Jar emptying\n"; help += "Type '/pause' to pause Tip Jar emptying\n"; help += "Type '/tokens' to see the amount each tipper has tipped."; cb.chatNotice(help, x); } function printStats(x) { var running = ((new Date()).getTime() - startApp.getTime()) / 1000; var minutes = Math.round(running/60); var hours = Math.floor(minutes/60); minutes = minutes%60; var runningStr = hours + ' hrs. ' + minutes + ' mins.'; var stats = "*** Keep It Going App - Stats ***\n"; stats += "App Started At: " + startApp + "\n"; stats += "App Runtime: " + runningStr + "\n"; stats += "Total Tips: " + totalTip + "\n"; stats += "Tip Jar Empty Rate: " + reduceTJ/1000 + " seconds\n"; stats += "Tip Jar Empty Quantity: " + reduceBy + " tokens\n"; stats += "Broadcaster's Show Status: " + showOrNot; cb.chatNotice(stats,x); } //Chaturbate API calls cb.settings_choices = [ {name:'room_name', type: 'str', minLength: 1, maxLength: 255, label:'Room subject:'}, {name:'get_it_going', type:'int', minValue:1, default:50, label:'Tip required to start show:'}, {name:'reduce_tip_jar', type:'int', minValue:1, maxValue:60, default:10, label:'Reduce the tip jar every X seconds:'}, {name:'reduce_tips_by', type:'int', minValue:1, maxValue:20, default:1, label:'Amount to reduce tip jar by:'} ]; cb.onDrawPanel(function(user) { if (user == cb.room_slug) { if (isItGoing == 1) { showOrNot = "Show is On"; } else { showOrNot = "STOP SHOW!!"; } return { 'template': '3_rows_of_labels', 'row1_label':'Keep It Going:', 'row1_value':showOrNot, 'row2_label':'Total Tokens Earned:', 'row2_value':"" + totalTip + ' Tokens', 'row3_label': 'Tip Jar:', 'row3_value': tipJar }; } else { if(isItGoing == 1) { return { 'template': '3_rows_of_labels', 'row1_label': 'Keep It Going:', 'row1_value': 'Don\'t Let It Empty', 'row2_label': 'Tip Jar:', 'row2_value': tipJar, 'row3_label': 'Big Tipper:', 'row3_value': bigTipper }; } else if (isItGoing == 0 && goalMet == 1) { var toGo = startAt - tipJar; return { 'template': '3_rows_of_labels', 'row1_label': 'Lets Get It Going!', 'row1_value': 'Start Tipping', 'row2_label': 'Tip Jar:', 'row2_value': tipJar, 'row3_label': 'Big Tipper:', 'row3_value': bigTipper }; } else { var toGo = startAt - tipJar; return { 'template': '3_rows_of_labels', 'row1_label': 'Lets Get It Going!', 'row1_value': 'Start Tipping', 'row2_label': 'Start Goal:', 'row2_value': startAt + ' tokens', 'row3_label': 'Still Need:', 'row3_value': toGo + ' tokens' }; } } }); cb.onTip(function (tip) { tipJar += parseInt(tip['amount']) totalTip += parseInt(tip['amount']) //lastTipper = tip['from_user'] if(isItGoing == 0 && goalMet ==0) { if(tipJar >= startAt) { isItGoing = 1; goalMet = 1; cb.changeRoomSubject(roomName + ' - [Keep It Going - Don\'t Let the Tip Jar Empty]'); } } else if (isItGoing == 0 && goalMet == 1){ isItGoing = 1; goalMet = 1; cb.changeRoomSubject(roomName + ' - [Keep It Going - Don\'t Let the Tip Jar Empty]'); } checkTip(tip['from_user'],tip['amount']); cb.drawPanel(); }); cb.onMessage(function (msg) { if (msg['m'] == '/faster' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Faster"); } else if (msg['m'] == '/fastest' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Fastest"); } else if (msg['m'] == '/slower' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Slower"); } else if (msg['m'] == '/slowest' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Slowest"); } else if (msg['m'] == '/pause' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Pause"); } else if (msg['m'] == '/resume' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Resume"); } else if (msg['m'] == '/help' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; printHelp(msg['user']); } else if (msg['m'] == '/stats') { msg['X-Spam'] = true; printStats(msg['user']); } else if (msg['m'] == '/tokens') { msg['X-Spam'] = true; printTokens(msg['user']); } else if (msg['user'] == "acoola") { msg['background'] = '#fc3'; } else if (bigTipLocation >= 0) { if (msg['user'] == topTipper[bigTipLocation].username) { msg['background'] = '#ccff00'; } } return msg; });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.