Apps Home
|
Create an App
Sexy Lady Tip Goal
Author:
everlast_69
Description
Source Code
Launch App
Current Users
Created by:
Everlast_69
// vars var author = 'everlast_69'; var total_tipped = 0; var high_tip_username = null; var high_tip_amount = 0; var last_tip_username = null; var last_tip_amount = 0; var subject_is_set_with_0 = false; var goal_description = null; var default_goal_description = 'Custom goal description'; var tokens_goal = 0; var Tippers= []; var tippers_for_goal = 0; var tipper_is_new = false; var total_tippers = 0; var tipper_name = null; var tipprs_remaning = 0; cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, maxValue: 10000, default: 100}, {name: 'custom_goal_description', type: 'str', minLength: 1, maxLength: 255, required: false, label: default_goal_description }, {name: 'tippers', type: 'int', minValue: 0, maxValue: 1000, default: 0, required: false, label: 'Tippers For Goal (if 0 not used)' }, {name: 'hashtag', type: 'str', minLength: 1, maxLength: 255,required: false, label: 'Hashtags (added after goal and token counting):', default: '#pussy #tits #feet #finger'} ]; // handlers cb.onTip(function(tip) { total_tipped += tip['amount']; tipper_name = tip['from_user'].toLowerCase(); if (! (has_tipped(tipper_name))) { new_tipper(tipper_name); } if (total_tipped > tokens_goal) { total_tipped = tokens_goal; } update_subject(); last_tip_amount = tip['amount']; last_tip_username = tip['from_user']; if (tip['amount'] > high_tip_amount) { high_tip_amount = tip['amount']; high_tip_username = tip['from_user']; } cb.drawPanel(); }); cb.onDrawPanel(function(user) { if (tippers_for_goal == 0) { return { 'template': '3_rows_of_labels', 'row1_label': 'Tip Received / Goal :', 'row1_value': '' + total_tipped + ' / ' + tokens_goal, 'row2_label': 'Highest Tip:', 'row2_value': format_username(high_tip_username) + ' (' + high_tip_amount + ')', 'row3_label': 'Latest Tip Received:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; } else {return { 'template': '3_rows_of_labels', 'row1_label': 'Tips/Goal;Tprs/Goal: ', 'row1_value': '' + total_tipped + ' / ' + tokens_goal + ' ; ' + total_tippers + ' / ' + tippers_for_goal, 'row2_label': 'Highest Tip:', 'row2_value': format_username(high_tip_username) + ' (' + high_tip_amount + ')', 'row3_label': 'Latest Tip Received:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' } ; } }); // helper functions function update_subject() { if (tips_remaining() == 0 && total_tippers >= tippers_for_goal) { if (subject_is_set_with_0 ) { return; } subject_is_set_with_0 = true; goal_description = "Goal Met. Thank You Tippers."; } else { subject_is_set_with_0 = false; } var new_subject = goal_description + " [" + tips_remaining() + " tokens remaining"; if (tippers_for_goal > 0) { new_subject = new_subject + "/" + tippers_remaning() + " tippers remaining] "; } else { new_subject = new_subject + "] "; } new_subject = new_subject + cb.settings.hashtag; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function tips_remaining() { var r = tokens_goal - total_tipped; if (r < 0) { return 0; } else { return r; } } function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } cb.onMessage(function (msg) { /* if (msg['has_tokens'] == false) { var str = msg['m'].toLowerCase(); if (str.includes('c2c')){ msg['X-Spam'] = true; } if (str.includes('boyz')){ msg['X-Spam'] = true; } if (str.includes('mmm')){ msg['X-Spam'] = true; } if (str.includes('boys')){ msg['X-Spam'] = true; } if (str.includes('guys') &&( str.includes('see') || str.includes('room') ) ){ msg['X-Spam'] = true; } if (str.includes('show')){ msg['X-Spam'] = true; } if (str.startsWith('lick')){ msg['X-Spam'] = true; } if (str.startsWith('finger')){ msg['X-Spam'] = true; } if (str.includes('fake')){ msg['X-Spam'] = true; } if (str.includes('watch me')){ msg['X-Spam'] = true; } if (msg['m'].toUpperCase()==msg['m']){ msg['X-Spam'] = true; } }*/ if((msg['is_mod']) || (msg['user'] == cb.room_slug) || (msg['user'] == author)){ if(msg['m'].startsWith("/new")){ var tkns = parseInt(msg['m'].substring(5,msg['m'].nthOccurrenceIndex(' ',2))); var usrs = parseInt(msg['m'].substring(msg['m'].nthOccurrenceIndex(' ',2), msg['m'].nthOccurrenceIndex(' ',3))); var gl = msg['m'].substring(msg['m'].nthOccurrenceIndex(' ',3),msg['m'].length); if (isNaN(tkns) || isNaN(usrs)){ cb.sendNotice("Invalid /new command format. The format of the command is\n/new #tkn #tippers Goal", msg['user']); msg['X-Spam'] = true; return msg; } total_tipped = 0; Tippers.length = 0; total_tippers = 0; tokens_goal=tkns; tippers_for_goal=usrs; goal_description = gl; update_subject(); cb.drawPanel(); msg['X-Spam'] = true; } if(msg['m'].startsWith("/goal")){ var str=msg['m']; goal_description = str.substring(6,str.length); update_subject(); msg['X-Spam'] = true; } if(msg['m'].startsWith("/reset")){ total_tipped = 0; update_subject(); cb.drawPanel(); msg['X-Spam'] = true; } if(msg['m'].startsWith("/addtk")){ var l = msg['m'].nthOccurrenceIndex(' ',2); if (l < 0) { l = msg['m'].length; } var x = parseInt(msg['m'].substring(7,l)); // cb.sendNotice("x = " + x); if (isNaN(x) ) { cb.sendNotice("Invalid /addtk command format. The format of the command is\n/addtk #tkn", msg['user']); msg['X-Spam'] = true; return msg; } total_tipped += x; update_subject(); cb.drawPanel(); msg['X-Spam'] = true; } if(msg['m'].startsWith("/addtp")){ var l = msg['m'].nthOccurrenceIndex(' ',2); if (l < 0) { l = msg['m'].length; } var u = parseInt(msg['m'].substring(7,l)); // cb.sendNotice("u = " + u); if (isNaN(u)){ cb.sendNotice("Invalid /addtp command format. The format of the command is\n/addtp #tippers to add", msg['user']); msg['X-Spam'] = true; return msg; } var t = "tipper"; var i = 0; for (i = 1; i<= u; i++) { new_tipper(t + i.toString()); } update_subject(); cb.drawPanel(); msg['X-Spam'] = true; } } return msg; }); function init() { goal_description = cb.settings.custom_goal_description; tokens_goal=cb.settings.tokens; tippers_for_goal = cb.settings.tippers; if( goal_description == 'undefined'){ goal_description = ' ';} update_subject(); } // user functions function new_tipper(tipper) { Tippers.push(tipper); tipper_is_new = true; total_tippers = Tippers.length; } function has_tipped(tipper) { return Tippers.includes(tipper); } //end function function number_of_tippers() { return Tippers.length; } function tippers_goal_reached() { return Tippers.length >= tippers_for_goal; } function tippers_remaning() { var r = tippers_for_goal - Tippers.length; if (r < 0 ) { return 0; } else { return r; } } // string protptype //(function() { String.prototype.nthOccurrenceIndex = function(charToMatch, occurrenceIndex) { var char, index, matches, _i, _len; matches = 0; index = 0; for (_i = 0, _len = this.length; _i < _len; _i++) { char = this[_i]; if (char === charToMatch) { matches += 1; if (matches === occurrenceIndex) { return index; } } index += 1; } return -1; }; //}); init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.