Bots Home
|
Create an App
bbftitle
Author:
bbftest
Description
Source Code
Launch Bot
Current Users
Created by:
Bbftest
//Set up choices on the launch page cb.settings_choices = [ {name: 'rank1', type: 'str', label: 'Rank 1 Title', default: 'Lover :heart5'}, {name: 'r1users', type: 'str', label: 'Rank 1 Users (user1,user2, ...)'}, {name: 'r1cost', type: 'str', label: 'Rank 1 Cost', default: '['}, {name: 'rank2', type: 'str', label: 'Rank 2 Title', default: 'King :crown02'}, {name: 'r2users', type: 'str', label: 'Rank 2 Users (user1,user2, ...)'}, {name: 'r2cost', type: 'str', label: 'Rank 2 Cost'}, {name: 'rank3', type: 'str', label: 'Rank 3 Title', default: ':crown01 Hero'}, {name: 'r3users', type: 'str', label: 'Rank 3 Users (user1,user2, ...)'}, {name: 'r3cost', type: 'str', label: 'Rank 3 Cost'}, {name: 'rank4', type: 'str', label: 'Rank 4 Title', default: ' :crown01 SuperHero'}, {name: 'r4users', type: 'str', label: 'Rank 4 Users (user1,user2, ...)'}, {name: 'r4cost', type: 'str', label: 'Rank 4 Cost'}, {name: 'rank5', type: 'str', label: 'Rank 5 Title', default: 'TipGod'}, {name: 'r5users', type: 'str', label: 'Rank 5 Users (user1,user2, ...)'}, {name: 'r5cost', type: 'str', label: 'Rank 5 Cost'}, {name: 'leftsep', type: 'str', label: 'Left separator:', default: '[', required: false}, {name: 'rightsep', type: 'str', label: 'Right separator:', default: ']', required: false}, {name: 'showtip', type: 'choice', label: 'Display tips:', choice1: 'yes',choice2:'no',default: 'yes'}, {name: 'tipsep', type: 'str', label: 'Tip separator (only applies if the user has a title and yes is selected above)', default: '|'}, {name: 'kingtitle', type: 'str', label: 'Custom title for highest tipper (disabled if left blank):',default: 'Tip King', required: false}, {name: 'showcrown', type: 'choice', label: 'Show crown for highest tipper:', choice1: 'yes',choice2:'no',default: 'yes'} ]; var userbase={}; var highest_tip=0; var king; addTitles(cb.settings.r1users, cb.settings.rank1); addTitles(cb.settings.r2users, cb.settings.rank2); addTitles(cb.settings.r3users, cb.settings.rank3); addTitles(cb.settings.r4users, cb.settings.rank4); addTitles(cb.settings.r5users, cb.settings.rank5); cb.onMessage(function (msg) { var user=msg['user']; var message=msg['m']; var addin='', title='', tipsep='',tips='',crown=''; if (user==cb.room_slug) { if (message=='/getlist') { sendList(); msg['X-Spam']=true; return; } } if (user in userbase) { if ('title' in userbase[user]) title=userbase[user]['title']; if (cb.settings.showtip && 'tips' in userbase[user]) { tips=userbase[user].tips; if ('tips' in userbase[user]) { tips=userbase[user]['tips']; if (title != '') tipsep=' '+cb.settings.tipsep+' '; } } if (user==king && cb.settings.kingtitle != '') { title=cb.settings.kingtitle; if (cb.settings.showcrown=='yes') crown=':crownheart ' } var addin=cb.settings.leftsep+' '+title+tipsep+tips+' '+cb.settings.rightsep; msg['m']=addin+' '+message; } msg['m']=crown+msg['m']; return msg; }); cb.onTip(function (tip) { var tipper=tip['from_user']; var amount=tip['amount']; var kingtitle=cb.settings.kingtitle; if (tipper in userbase) { if ('tips' in userbase[tipper]) userbase[tipper]['tips']+=amount; else userbase[tipper]['tips']=amount; } else { userbase[tipper]={'tips':amount}; } if (kingtitle != '' && userbase[tipper]['tips'] > highest_tip) { highest_tip=userbase[tipper]['tips']; if (tipper != king) cb.sendNotice(tipper+' is now '+kingtitle+'!'); king=tipper; } }); function sendList() { // var list=''; // copybase=clone(userbase); // while (Object.keys(copybase).length>0) { // for (user in copybase) break; // search_title=copybase[user]['title']; // for (user2 in copybase) { // title2=copybase[user2]['title']; // if (title2==search_title) { // list=list+user2+":"; // delete copybase[user2]; // } // } // list=list.substring(0,list.length-1); //trim last colon // list=list+'@'+search_title+','; // } // list=list.substring(0,list.length-1); //trim last comma // cb.sendNotice('(Sent to room owner - '+cb.room_slug+') List of users with their titles including ones added in this session: '+list,cb.room_slug); } function addData(user,property,data) { cb.sendNotice(property); if (user in userbase) userbase[user][property]=data; else { userbase[user]={}; userbase[user][property]=data; } } function addTitles(input, rank) { var entries=String(input).split(','); for (i in entries) { addData(entries[i].trim(),"title",rank); } } function clone(obj) { var target = {}; for (var i in obj) { if (obj.hasOwnProperty(i)) { target[i] = obj[i]; } } return target; }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.