Bots Home
|
Create an App
Tips
Author:
spaceball3
Description
Source Code
Launch Bot
Current Users
Created by:
Spaceball3
/********************************************************************************* Author: Wesley **********************************************************************************/ //Chaturbate API calls cb.settings_choices = [ {name:'room_subject', 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:'}, {name: 'goal_1_tokens', label: 'Goal 1 Token Amount', type: 'int', minValue: 1, defaultValue: 200}, {name: 'goal_1_description', label: 'Goal 1 Description', type: 'str', minLength: 1, maxLength: 255}, {name: 'goal_2_tokens', label: 'Goal 2 Token Amount', type: 'int', minValue: 1, defaultValue: 200, required: false}, {name: 'goal_2_description', label: 'Goal 2 Description', type: 'str', minLength: 0, maxLength: 255, required: false}, {name: 'goal_3_tokens', label: 'Goal 3 Token Amount', type: 'int', minValue: 1, defaultValue: 200, required: false}, {name: 'goal_3_description', label: 'Goal 3 Description', type: 'str', minLength: 0, maxLength: 255, required: false}, {name: 'goal_4_tokens', label: 'Goal 4 Token Amount', type: 'int', minValue: 1, defaultValue: 200, required: false}, {name: 'goal_4_description', label: 'Goal 4 Description', type: 'str', minLength: 0, maxLength: 255, required: false}, {name: 'goal_5_tokens', label: 'Goal 5 Token Amount', type: 'int', minValue: 1, defaultValue: 200, required: false}, {name: 'goal_5_description', label: 'Goal 5 Description', type: 'str', minLength: 0, maxLength: 255, required: false}, {name: 'finality_message', label: 'Final Goal Met Subject', type: 'str', minLength: 1, maxLength: 255, defaultValue: 'OMG! You make me Cum! Thanks to all tippers!'}, ]; // vars var isItGoing = 0; var startGoalMet = 0; var tipJar = 0; var totalTipped = 0; var currentTotalTipped = 0; var subject_is_final = false; var current_goal = 1; var final_goal_met = false; var showOrNot = ""; var startApp = new Date(); var startAt = cb.settings.get_it_going; 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; var roomSubject = cb.settings.room_subject; var multiGoalSubject = roomSubject + ' [Goal ' + current_goal + ': ' + getCurrentGoalDescription() + ' - ' + tips_remaining() + ' tk left] '; var keepItGoingSubject = '[Tip ' + startAt + ' to start the show]'; 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: " + totalTipped,x); } function updateRoomSubject() { cb.changeRoomSubject(multiGoalSubject + ' ' + keepItGoingSubject); } function resetApp() { tipJar = 0; isItGoing = 0; keepItGoingSubject = "[ Jar empty - Please Fuck me More ]"; updateRoomSubject(); } 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: " + totalTipped + "\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); } function getCurrentGoalDescription() { return cb.settings['goal_' + current_goal + '_description']; } function getCurrentGoalAmount() { return cb.settings['goal_' + current_goal + '_tokens']; } function checkFinality() { if (getCurrentGoalAmount() <= 0 || getCurrentGoalDescription() === "" || current_goal === 6) { final_goal_met = true; } } function tips_remaining() { var r = getCurrentGoalAmount() - currentTotalTipped; return (r < 0) ? 0 : r; } function format_username(val) { return (val === null) ? "--" : val.substring(0, 12); } function update_goals() { if (final_goal_met) { roomSubject = cb.settings.finality_message; multiGoalSubject = roomSubject; subject_is_final = true; } else { multiGoalSubject = roomSubject + ' [Goal ' + current_goal + ': ' + getCurrentGoalDescription() + ' - ' + tips_remaining() + ' tk left] '; } updateRoomSubject(); } cb.onDrawPanel(function(user) { var panel = {}; panel.template = '3_rows_of_labels'; if (final_goal_met) { panel.row3_label = 'Goal ' + (current_goal-1) + ':'; panel.row3_value = 'FINAL GOAL MET'; } else { panel.row3_label = 'Goal ' + current_goal + ':'; panel.row3_value = currentTotalTipped + ' / ' + getCurrentGoalAmount() + ' (' + tips_remaining() + ' left)'; } if (user == cb.room_slug) { if (isItGoing == 1) { showOrNot = "Show is On"; } else { showOrNot = "STOP SHOW!!"; } panel.row1_label ='Keep It Going:'; panel.row1_value = showOrNot; panel.row2_label = 'Tip Jar:'; panel.row2_value = tipJar; return panel; } else { if(isItGoing == 1) { panel.row1_label = 'Keep It Going:'; panel.row1_value = 'Don\'t Let It Empty'; panel.row2_label = 'Tip Jar:'; panel.row2_value = tipJar; return panel; } else if (isItGoing == 0 && startGoalMet == 1) { var toGo = startAt - tipJar; panel.row1_label = 'Let\'s Get Going:'; panel.row1_value = 'Start Tipping'; panel.row2_label = 'Tip Jar:'; panel.row2_value = tipJar; return panel; } else { var toGo = startAt - tipJar; panel.row1_label = 'Let\'s Get Going:'; panel.row1_value = 'Start Tipping'; panel.row2_label = 'Still Need:'; panel.row2_value = toGo + ' tokens to start'; return panel; } } }); cb.onTip(function (tip) { tipJar += parseInt(tip['amount']); totalTipped += parseInt(tip['amount']); currentTotalTipped += parseInt(tip['amount']); if(isItGoing == 0 && startGoalMet ==0) { if(tipJar >= startAt) { isItGoing = 1; startGoalMet = 1; keepItGoingSubject = '[ :fuckyeah- Fuck me More - Don\'t Let the Tip Jar Empty ]'; } else { keepItGoingSubject = '[Tip ' + (startAt-totalTipped) + ' to start the show]'; } } else if (isItGoing == 0 && startGoalMet == 1){ isItGoing = 1; startGoalMet = 1; keepItGoingSubject = '[ Keep Me Wet - Don\'t Let the Tip Jar Empty ]'; } checkTip(tip['from_user'],tip['amount']); while (currentTotalTipped >= getCurrentGoalAmount()) { currentTotalTipped = currentTotalTipped - getCurrentGoalAmount(); current_goal++; checkFinality(); } update_goals(); 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 (bigTipLocation >= 0) { if (msg['user'] == topTipper[bigTipLocation].username) { msg['background'] = '#ccff00'; } } return msg; }); function init() { update_goals(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.