Apps Home
|
Create an App
Demo App
Author:
test_black_can0n
Description
Source Code
Launch App
Current Users
Created by:
Test_Black_Can0n
var times_goal_reached=0,last_time_goal_reached=null,current_goal_tipped=0,set_tokens_command="!settok",set_reached_command="!setreached";function getNumberString(e){var t=String(e).charAt(String(e).length-1);return"1"==t&&e%100!=11?e+"st":"2"==t&&e%100!=12?e+"nd":"3"==t&&e%100!=13?e+"rd":e+"th"}function startsWith(e,t){return e.substring(0,t.length)===t}function update_subject(){var e=cb.settings.goal_description+" ["+tips_remaining()+" tokens remaining]";cb.log("Changing subject to: "+e),cb.changeRoomSubject(e)}function goalReached(e){last_time_goal_reached=new Date;for(var t=Math.floor(current_goal_tipped/cb.settings.tokens),a=0;a<t;a++)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 "+e+" has reached the goal.",cb.room_slug,"#FEF9CD","#1A1AD7","bold")}function tips_remaining(){var e=cb.settings.tokens-current_goal_tipped;return e<0?0:e}function refresh(){cb.log("Refresh called"),cb.setTimeout(refresh,2e4),cb.drawPanel()}function init(){update_subject()}cb.onDrawPanel(function(e){return cb.log(e),0==times_goal_reached?{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"}:{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())/6e4)+" minutes ago"}}),cb.settings_choices=[{name:"tokens",type:"int",minValue:1,default:100},{name:"goal_description",type:"str",minLength:1,maxLength:255}],cb.onMessage(function(e){let t;"!"==e.m[0]&&e.user==cb.room_slug&&(startsWith(e.m,set_tokens_command)?(e["X-Spam"]=!0,t=e.m.slice(set_tokens_command.length),times_goal_reached=Math.floor(t/cb.settings.tokens),current_goal_tipped=t%cb.settings.tokens,last_time_goal_reached=new Date,cb.drawPanel(),cb.chatNotice("The tokens received has been updated!",e.user)):startsWith(e.m,set_reached_command)&&(e["X-Spam"]=!0,t=e.m.slice(set_reached_command.length),times_goal_reached=t,last_time_goal_reached=new Date,current_goal_tipped=0,cb.drawPanel(),cb.chatNotice("The number of times reached has been updated!",e.user)))}),cb.onTip(function(e){(current_goal_tipped+=e.amount)>=cb.settings.tokens&&goalReached(e.from_user),update_subject(),cb.drawPanel()}),init(),cb.setTimeout(refresh,2e4);
© Copyright Chaturbate 2011- 2024. All Rights Reserved.