Bots Home
|
Create an App
goat style
Author:
metadude
Description
Source Code
Launch Bot
Current Users
Created by:
Metadude
// vars var times_goal_reached = 0; var last_time_goal_reached = null; var current_goal_tipped = 0; var set_tokens_command = '!settok'; var set_reached_command = '!setreached'; cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, default: 100}, {name: 'goal_description', type: 'str', minLength: 1, maxLength: 255}, {name:'Level1', type:'str', minLength:1, maxLength:255, label:'Level #1'}, {name:'Level2', type:'str', minLength:1, maxLength:255, label:'Level #2 (optional)', required:false}, {name:'Level3', type:'str', minLength:1, maxLength:255, label:'Level #3 (optional)', required:false}, {name:'Level4', type:'str', minLength:1, maxLength:255, label:'Level #4 (optional)', required:false}, {name:'Level5', type:'str', minLength:1, maxLength:255, label:'Level #5 (optional)', required:false}, {name:'Level6', type:'str', minLength:1, maxLength:255, label:'Level #6 (optional)', required:false}, {name:'Level7', type:'str', minLength:1, maxLength:255, label:'Level #7 (optional)', required:false}, {name:'Level8', type:'str', minLength:1, maxLength:255, label:'Level #8 (optional)', required:false}, {name:'Level9', type:'str', minLength:1, maxLength:255, label:'Level #9 (optional)', required:false}, {name:'Level10', type:'str', minLength:1, maxLength:255, label:'Level #10 (optional)', required:false}, {name:'Level11', type:'str', minLength:1, maxLength:255, label:'Random Level (optional)', required:false}, {name:'advertisement_wait_time', type:'choice', label:'Notification Time (in minutes)', choice1:5, choice2:10, choice3:15, choice4:20, choice5:25, choice6:30, choice7:45, choice8:60, defaultValue:15} ]; // handlers cb.onTip(function(tip) { current_goal_tipped += tip['amount'] if (current_goal_tipped >= cb.settings.tokens) { goalReached(tip['from_user']); } update_subject(); cb.drawPanel(); }); cb.onDrawPanel(function(user) { if (times_goal_reached == 0) { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Hit Goal For:', 'row2_value': '' + times_goal_reached + ' times', 'row3_label': 'Last Reached:', 'row3_value': 'Never' }; } else { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Hit Goal For:', 'row2_value': '' + times_goal_reached + ' times', 'row3_label': 'Last Reached:', 'row3_value': '' + Math.floor(((new Date()).getTime() - last_time_goal_reached.getTime()) / 60000) + ' minutes ago' }; } }); cb.onMessage(function (msg) { if (msg['m'][0] == '!') { if (msg['user'] == cb.room_slug) { if (startsWith(msg['m'], set_tokens_command)) { msg['X-Spam'] = true; var number = msg['m'].slice(set_tokens_command.length); times_goal_reached = Math.floor(number / cb.settings.tokens); current_goal_tipped = number % cb.settings.tokens; last_time_goal_reached = new Date(); cb.drawPanel(); cb.chatNotice('The tokens received has been updated!', msg['user']); } else if (startsWith(msg['m'], set_reached_command)) { msg['X-Spam'] = true; var number = msg['m'].slice(set_reached_command.length); times_goal_reached = number; last_time_goal_reached = new Date(); current_goal_tipped = 0; cb.drawPanel(); cb.chatNotice('The number of times reached has been updated!', msg['user']); } } } }); // Functions function refresh() { cb.log("Refresh called"); cb.setTimeout(refresh, 20000); cb.drawPanel(); } function update_subject() { var new_subject = cb.settings.goal_description + " [" + tips_remaining() + " tokens remaining]"; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function goalReached(userName) { last_time_goal_reached = new Date(); var curr_times_reached = Math.floor(current_goal_tipped / cb.settings.tokens); for (var i = 0; i < curr_times_reached; i++) { times_goal_reached++; current_goal_tipped -= cb.settings.tokens; cb.chatNotice("Goal was reached for the " + getNumberString(times_goal_reached) + " time!"); cb.chatNotice('The user ' + userName + ' has reached the goal.', cb.room_slug, "#FEF9CD", "#1A1AD7", "bold"); } } function getNumberString(number) { var numberString = null; var lastChar = String(number).charAt(String(number).length - 1); if ((lastChar == '1') && ((number % 100) != 11)) { numberString = number + "st"; } else if ((lastChar == '2') && ((number % 100) != 12)) { numberString = number + "nd"; } else if ((lastChar == '3') && ((number % 100) != 13)) { numberString = number + "rd"; } else { numberString = "" + number + "th"; } return (numberString); } function tips_remaining() { var r = cb.settings.tokens - current_goal_tipped; if (r < 0) { return 0; } else { return r; } } function startsWith(source, str) { return source.substring(0, str.length) === str; } var meanBroadcasters = ['missilex']; cb.onEnter(function(user) { if(meanBroadcasters.indexOf(cb.room_slug) < 0) { cb.sendNotice('Welcome to my room, ' + user['user'] + '. MY LOVENSE LUSH VIBRATOR IS SET TO REACT TO YOUR TIPS. THERE ARE 10 LEVELS OF INTENSITY OR RANDOMLY CHOOSE A LEVEL FROM 1-11', user['user'], '#DBFFDB', '', 'bold'); displayLevels(user); } }); function displayLevels(user) { var username = ''; if(user) username = user['user']; var notices = '###### Vibrator Level ######'; for(var i=1; i<=10;i++) { if(cb.settings['Level' + i]) notices += '\nLevel #'+ i +': ' + cb.settings['Level'+i]; } notices += '\n######################'; cb.sendNotice(notices, username, '#E6FFFF', '#003399', 'bold'); if(!user || user == null) cb.setTimeout(displayLevels, cb.settings.advertisement_wait_time * 60000); } function init() { if(meanBroadcasters.indexOf(cb.room_slug) < 0) displayLevels(); update_subject(); } init(); cb.setTimeout(refresh, 20000);
© Copyright Chaturbate 2011- 2024. All Rights Reserved.