Apps Home
|
Create an App
Bid App
Author:
natacha_55
Description
Source Code
Launch App
Current Users
Created by:
Natacha_55
/******************************************************* * Title: * * By: * * Author: * Thumbsup: * * Version: 1.000 (11.03.2019) * Build: .001 *******************************************************/ cb.settings_choices = [ {name: 'lbl_1',type: 'choice',choice1: '',choice2: '',defaultValue: '',label: "----------------------------- TIPMENU SECTION -----------------------------",required: false}, {name: 'tm_1',type: 'str',minLength: 3,maxLength: 255,defaultValue: "",label: "TipMenu 1 (e.g : Action-25 ) ",required: false}, {name: 'tm_2',type: 'str',minLength: 3,maxLength: 255,defaultValue: "",label: "TipMenu 2 (e.g : Action-25 ) ",required: false}, {name: 'tm_3',type: 'str',minLength: 3,maxLength: 255,defaultValue: "",label: "TipMenu 3 (e.g : Action-25 ) ",required: false}, {name: 'tm_4',type: 'str',minLength: 3,maxLength: 255,defaultValue: "",label: "TipMenu 4 (e.g : Action-25 ) ",required: false}, {name: 'tm_5',type: 'str',minLength: 3,maxLength: 255,defaultValue: "",label: "TipMenu 5 (e.g : Action-25 ) ",required: false}, {name: 'tm_6',type: 'str',minLength: 3,maxLength: 255,defaultValue: "",label: "TipMenu 6 (e.g : Action-25 ) ",required: false}, {name: 'tm_7',type: 'str',minLength: 3,maxLength: 255,defaultValue: "",label: "TipMenu 7 (e.g : Action-25 ) ",required: false}, {name: 'tm_8',type: 'str',minLength: 3,maxLength: 255,defaultValue: "",label: "TipMenu 8 (e.g : Action-25 ) ",required: false}, {name: 'tm_9',type: 'str',minLength: 3,maxLength: 255,defaultValue: "",label: "TipMenu 9 (e.g : Action-25 ) ",required: false}, {name: 'tm_10',type: 'str',minLength: 3,maxLength: 255,defaultValue: "",label: "TipMenu 10 (e.g : Action-25 ) ",required: false} ]; var tool = { indexOf : function(s, a, b){ var i; if (typeof b === 'undefined'){b = '';} for(i = 0; i < a.length; i += 1){ if((b ? a[i][b] : a[i]) === s){return i;} } return -1; }, CleanFromUser : function(tip){ Tip.amount = tip.amount; Tip.message = tip.message; Tip.to_user = tip.to_user; Tip.user = tip.from_user; Tip.in_fanclub = tip.from_user_in_fanclub; Tip.has_tokens = tip.from_user_has_tokens; Tip.is_mod = tip.from_user_is_mod; Tip.tipped_recently = tip.from_user_tipped_recently; Tip.tipped_alot_recently = tip.from_user_tipped_alot_recently; Tip.tipped_tons_recently = tip.from_user_tipped_tons_recently; Tip.gender = tip.from_user_gender; return Tip; } } var time = { GetDate : function(timestamp = false){ if(!timestamp){ d = new Date(); return d.getTime(); } else{ d = new Date(timestamp); return d.getHours()+'H'+d.getMinutes(); } }, GetTimeSpent : function(timestamp = false){ if(timestamp){dif = Math.floor((this.GetDate() - timestamp) / 1000 );} else{dif = Math.floor((this.GetDate() - this.start) / 1000 );} if(dif >= 0 && dif < 60){ ts = dif+'s'; } else if(dif >= 60 && dif < 3600){ min = Math.floor(dif/60); sec = Math.floor(dif%60); ts = min+'m'+sec+'s'; } else{ hour = Math.round(dif/3600); min = Math.floor((dif%3600)/60); sec = Math.floor((dif%3600)%60); ts = hour+'h'+min+'m'+sec+'s'; } return ts; } } var color = { fail : {c:'#be0000',b:'#e4b2b2',w:'bold'}, win : {c:'#6fa007',b:'#ceeb90',w:'bold'}, info : {c:'#01375c',b:'#bfd9eb',w:'bold'}, info_title : {c:'#01375c',b:'#1481cc',w:'bold'}, warning : {c:'#6b5a00',b:'#ffeb83',w:'bold'}, simple : {c:'#888888',b:'',w:''}, tip : {c:'#000033',b:'#ffff33',w:'bold'}, whisp_send : {c:'#888888',b:'#f5f5f5',w:''}, whisp_receive : {c:'#888888',b:'#f1d7f5',w:''}, gry : "#EBEBEB", brz : "#747474", slv : "#505050", gld : "#D1C214", plt : "#515269", dmd : "#8A3B7A", fan : "#1D8F2A", mod : "#B91313", hot : "#f18226", } var rank = { //rank.list => [group],[color],[rank],[lbl],[mini],[maxi] list : [], Add : function(group,color,rank,lbl,mini,maxi){ this.list.push({group:group,color:color,rank:rank,label:lbl,mini:mini,maxi:maxi}); }, Chk : function(group){ return tool.indexOf(group,this.list,'group'); }, Init : function(){ this.Add("$gry",color.gry,"[GRY]","Grey",0,0); this.Add("$brz",color.brz,"[BRZ]","Bronze",1,49); this.Add("$slv",color.slv,"[SLV]","Silver",50,99); this.Add("$gld",color.gld,"[GLD]","Gold",100,499); this.Add("$plt",color.plt,"[PLT]","Platinium",500,999); this.Add("$dmd",color.dmd,"[DMD]","Diamond",1000,99999); this.Add("$fan",color.fan,"[FAN]","Fan",0,99999); this.Add("$mod",color.mod,"[MOD]","Moderator",0,99999); this.Add("$hot",color.hot,"[HOT]","Broadcaster",0,99999); }, GetList : function(sep = false){ ret = ''; if(!sep){sep = '|';} for(i=0;i<this.list.length;i++){ if(i>0){ ret += sep; } ret += this.list[i].group; } return ret; } } var usr = { //user.list => [user],[tip],[nb_tip],[amount],[win],[lvl],[mess],[cmd],[first],[last] list : [], Get : function(user,silence = false){ if(silence == false){ id_user = tool.indexOf(user.user,this.list,'user'); } else{ id_user = tool.indexOf(user,this.list,'user'); } if(id_user == -1 && silence == false){ this.Add(user.user,this.Chk(user)); id_user = tool.indexOf(user.user,this.list,'user'); } return id_user; }, Chk : function(user){ lvl = 0; if(user.in_fanclub == true){lvl = 6;} if(user.is_mod == true){lvl = 7;} if(user.user == cb.room_slug){lvl = 8;} return lvl; }, Add : function(username,lvl){ //usr.list[x]].tip => [date],[amount],[action],[msg],[total],[rank] tip = []; this.list.push({user:username,tip:tip,nb_tip:0,amount:0,win:0,lvl:lvl,msg:0,cmd:0,first:time.GetDate(),last:time.GetDate()}); }, Update : function(id_user,type,tip = false,action = false){ if(type == 'msg'){ this.list[id_user].msg++; } else if(type == 'lvl'){ this.list[id_user].lvl = tip; } else if(type == 'cmd'){ this.list[id_user].msg++; } else if(type == 'win'){ this.list[id_user].win++; } else if(type == 'tip'){ this.list[id_user].nb_tip++; this.list[id_user].amount += parseInt(tip.amount); this.list[id_user].tip.push({date:time.GetDate(),amount:parseInt(tip.amount),action:action,msg:tip.message,total:this.list[id_user].amount,rank:rank.list[this.list[id_user].lvl].rank}); if(this.list[id_user].amount > rank.list[this.list[id_user].lvl].maxi){ r = 0; for(i =0;i < rank.list.length;i++){ if(this.list[id_user].amount > rank.list[i].maxi){ r = i+1; } } this.Update(id_user,'lvl',r); not = 'Congratulations ! you are now in '+rank.list[r].rank+' rank ! '; send.Notice(not,'win',this.list[id_user].user,''); } } this.list[id_user].last = time.GetDate(); }, RankList : function(id_rank){ tab = []; for(i = 0;i < this.list.length;i++){ if(this.list[i].lvl == id_rank){ tab.push({id_user:i}); } } return tab; }, Leader : function(){ }, Board : function(){ } } var Btip = { // Tip.list [user],[action],[amount],[rank],[date] list : [], totaltip : 0, nbtip : 0, nbtipper : 0, Get : function(){ }, Add : function(tip,id_user){ id_action = action.Get(tip.amount); if(id_action > -1){ act = action.list[id_action].action; not = usr.list[id_user].user+' has tip for : '+act; send.Notice(not,'tip'); action.Update(id_action); } else{ act = 'Just Tip'; } this.totaltip = this.totaltip + tip.amount; this.nbtip++; usr.Update(id_user,'tip',tip,act); if(tool.indexOf(usr.list[id_user].user,this.list,'user') == -1){this.nbtipper++;} this.list.push({user:usr.list[id_user].user,action:act,amount:tip.amount,rank:rank.list[usr.list[id_user].lvl].rank,date:time.GetDate()}); }, Board : function(){ }, List : function(){ } } var action ={ // action.list => [action],[amount],[nb],[last] list : [], Get : function(amount){ amount = parseInt(amount); if(this.list.length == 0){ this.Init(); id_action = tool.indexOf(amount,this.list,'amount'); } id_action = tool.indexOf(amount,this.list,'amount'); return id_action; }, Add : function(action,amount){ this.list.push({action:action,amount:parseInt(amount),nb:0,last:''}); }, Update : function(id_action){ this.list[id_action].nb++; this.list[id_action].last = time.GetDate(); }, Send : function(id_user,command,to = false){ if(this.list.length == 0){ this.Init(); } if(this.list.length > 0){ not = ''; for(i = 0;i < this.list.length;i++){ not += this.list[i].action+'( '+this.list[i].amount+' )'; if(i < (this.list.length -1)){ not += '|'; } } if(to != false){ to_id_user = usr.Get(to,true); id_rank = rank.Chk(to); if(id_rank > -1){ rankuser = usr.RankList(id_rank); if(rankuser.length > 0){ for(i = 0;i < rankuser.length;i++){ send.Notice('::: TIPMENU : ','info_title',usr.list[rankuser[i].id_user].user); send.Notice(not,'info',usr.list[rankuser[i].id_user].user); } send.Notice('Tipmenu was sent to '+rankuser.length+' user(s) in '+rank.list[id_rank].label+' group.','warning',usr.list[id_user].user); } else{ send.Notice('Nope, ther is nobody in '+to+' group.','warning',usr.list[id_user].user); } } else if(to_id_user > -1){ send.Notice('::: TIPMENU : ','info_title',usr.list[to_id_user].user); send.Notice(not,'info',usr.list[to_id_user].user); } else{ send.Notice('Nope, '+to+' isn\'t in userlist.','warning',usr.list[id_user].user); } } else{ if(command == '/tipmenusend'){ send.Notice('::: TIPMENU : ','info_title'); send.Notice(not,'info'); } else{ send.Notice('::: TIPMENU : ','info_title',usr.list[id_user].user); send.Notice(not,'info',usr.list[id_user].user); } } } else{ not = 'Nope, tipmenu is empty ... '; send.Notice(not,'warning',usr.list[id_user].user); } }, Init : function(){ for(i = 1;i <= 10;i++){ if(cb.settings['tm_'+i] != ''){ if(cb.settings['tm_'+i].indexOf('-') > -1){ tab = cb.settings['tm_'+i].split('-'); this.Add(tab[0],tab[1]); } } } } } var bid = { list : [], Get : function(){ }, Add : function(){ }, Start : function(){ }, Stop : function(){ }, Board : function(){ } } var cmd = { // cmd.list => [command],[lvl],[helper],[nb],[last] list : [], Get : function(id_user,msg){ if(this.list.length == 0){ this.Init(); } todo = this.Parser(msg); id_command = this.Chk(todo.command,id_user); if(id_command !== false){ if(todo.command == '/help'){ this.Help(id_user); } else if(todo.command == '/tipmenu'){ action.Send(id_user,todo.command); } else if(todo.command == '/tipmenusend'){ action.Send(id_user,todo.command,todo.arg[1]); } } }, Add : function(command,lvl,helper){ this.list.push({command:command,lvl:lvl,helper:helper}); }, Update : function(id_command){ }, Parser : function(msg){ res = {}; res.arg = []; if(msg.indexOf('&')){ tab = msg.split('&'); res.command = tab[0]; for(i= 1;i < tab.length;i++){ res.arg[i] = tab[i]; } } else{ res.command = msg; } return res; }, Chk : function(command,id_user,silence = false){ id_command = tool.indexOf(command,this.list,'command'); if(id_command > -1){ if(this.list[id_command].lvl <= usr.list[id_user].lvl){ ret = id_command ; } else{ if(silence == false){ not = 'You don\'t have permission to use '+command+', type /help for commands list.'; send.Notice(not,'warning',usr.list[id_user].user); } ret = false; } } else{ if(silence == false){ not = command+' isn\'t a valid command, type /help for commands list.'; send.Notice(not,'warning',usr.list[id_user].user); } ret = false; } return ret; }, Help : function(id_user){ if(this.list.length > 0){ not = ''; for(i = 0;i < this.list.length;i++){ not += 'This is all available commands in '+rank.list[usr.list[id_user].lvl].label+' rank :\n'; id_command = this.Chk(this.list[i].command,id_user,true); if(id_command !== false){ not += '-------------------------------\n'; not += '::.'+this.list[id_command].command+'.::\n'; not += '-------------------------------\n'; not += this.list[id_command].helper; } } send.Notice('::: HELP :','info_title',usr.list[id_user].user); send.Notice(not,'info',usr.list[id_user].user); } else{ not = 'Nope, there is no available commands for your rank.'; send.Notice(not,'warning',usr.list[id_user].user); } }, Init : function(){ // /HELP help = 'Displays the list of available commands for your rank.'; this.Add('/help',0,help); // /TIPMENU help = 'Allows you to view the list of actions and their amount.'; this.Add('/tipmenu',0,help); // /TIPMENUSEND help = 'Allows you to send the Tipmenu to user or group or all.\n'; help += ' - /tipmenusend -> for send to all\n'; help += ' - /tipmenusend&$group -> for send to group ( '+rank.GetList('/')+' )\n'; help += ' - /tipmenusend&user -> for send to user'; this.Add('/tipmenusend',7,help); // / } } var send = { list : [], Notice : function(msg,style,to,group){ if(!to){to = ''}; if(!group){group = '';} cb.sendNotice(msg,to,color[style].b,color[style].c,color[style].w,group); }, Message : function(msg,id_user){ if(usr.list[id_user].lvl > 0){ usr.Update(id_user,'msg'); msg.c = rank.list[usr.list[id_user].lvl].color; msg.m = rank.list[usr.list[id_user].lvl].rank + msg.m; } else{ msg.m = ''; msg['X-Spam'] = true; not = 'For posting messages, tip 1 Token and upgrade to Bronze rank [BRZ].'; this.Notice(not,'warning',usr.list[id_user].user); } return msg; } } // EVENTS GRABBER cb.onEnter(function(user){ /* user: user who entered the room in_fanclub: is the user in the broadcaster’s fan club has_tokens: does the user have at least 1 token is_mod: is the user a moderator tipped_recently: is the user a “dark blue”? tipped_alot_recently: is the user a “purple”? tipped_tons_recently: is the user a “dark purple”? gender: “m” (male), “f” (female), “s” (trans), or “c” (couple) */ id_user = usr.Get(user); }); cb.onMessage(function(msg){ /* c: message color m: the message text user: username of message sender f: message font in_fanclub: is the user in the broadcasters fan club has_tokens: does the user have at least 1 token is_mod: is the user a moderator tipped_recently: is the user a “dark blue”? tipped_alot_recently: is the user a “purple”? tipped_tons_recently: is the user a “dark purple”? gender: “m” (male), “f” (female), “s” (trans), or “c” (couple) */ id_user = usr.Get(msg); if(msg.m[0] == '/'){ cmd.Get(id_user,msg.m); } else{ send.Message(msg,id_user); } }); cb.onTip(function(tip){ /* amount: amount of tip message: message in tip to_user: user who received tip from_user: user who sent tip from_user_in_fanclub: is the user in the broadcasters fan club from_user_has_tokens: does the user have at least 1 token from_user_is_mod: is the user a moderator from_user_tipped_recently: is the user a “dark blue”? from_user_tipped_alot_recently: is the user a “purple”? from_user_tipped_tons_recently: is the user a “dark purple”? from_user_gender: “m” (male), “f” (female), “s” (trans), or “c” (couple) */ id_user = usr.Get(tool.CleanFromUser(tip)); Btip.Add(tip,id_user); }); cb.onLeave(function(user){ /* user: user who left the room in_fanclub: is the user in the broadcaster’s fan club has_tokens: does the user have at least 1 token is_mod: is the user a moderator tipped_recently: is the user a “dark blue”? tipped_alot_recently: is the user a “purple”? tipped_tons_recently: is the user a “dark purple”? gender: “m” (male), “f” (female), “s” (trans), or “c” (couple) */ id_user = usr.Get(user); }); // INIT APP rank.Init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.