Bots Home
|
Create an App
VIP-Lounge&TopDonater
Author:
sweethotboy96
Description
Source Code
Launch Bot
Current Users
Created by:
Sweethotboy96
var ModListe=[]; ModListe.push(cb.room_slug); cb.settings_choices = [ { name: 'trName', type: 'str', minLength: 1, maxLength: 16, defaultValue: 'VIP', label: 'Name to be display before every VIP-Lounge message, e.g. "germanmarv@VIP-Lounge: hey guys"'}, { name: 'allowMods',type: 'choice', choice1:'yes', choice2:'no', defaultValue: 'yes', label: 'Allow Mods to add/remove people to/from the List.'}, { name: 'addFans',type: 'choice', choice1:'yes', choice2:'no', defaultValue: 'no', label: 'Automatically add Fan Club Members to the List when they join the Room.'} ]; function radio(msg,usr){ //sends the message msg to everyone on the ModListe in the name of usr. //cb.log('2tr msg by '+user); for (i = 0; i < ModListe.length ;i++){ cb.sendNotice(usr+"@"+cb.settings.trName+": "+ msg , ModListe[i], '#FFFFFF' , '#088A08' , 'bolder'); } //cb.log('3tr msg by '+user); return; } function addtr(usr){ if (cbjs.arrayContains(ModListe, usr)) { return (usr+" is already in VIP-Lounge!"); }else{ ModListe.push(usr); cb.sendNotice('Hello '+ usr +'. Type "/vip" to learn about VIP-Lounge',usr, '#FFFFFF' , '#088A08' , 'bolder' ); return (usr+" added."); } } function deltr(usr){ if (!cbjs.arrayContains(ModListe, usr)) { return (usr+" is not in VIP-Lounge!"); }else{ var indEx = ModListe.indexOf(usr); ModListe.splice(indEx,1); return (usr+" removed."); } } cb.sendNotice('Hello '+cb.room_slug+'. Type "/vip" to learn about '+ cb.settings.trName+ ' (VIP-Lounge), The Original comes from GermanMarv he is here .',cb.room_slug, '#FFFFFF' , '#088A08' , 'bolder'); cb.onEnter(function(user) { //cb.log(user.user+' joined'); if ( user['is_mod'] || (user.in_fanclub && (cb.settings.addFans=='yes') ) ){ radio(addtr(user.user),'system'); return; } }); cb.onLeave(function(user) { //cb.log(user.user+' left'); if (cbjs.arrayContains(ModListe, user['user'])) { radio(deltr(user.user),'system'); return; } }); cb.onMessage(function(message) { cb.log('1'); var istDrauf = (cbjs.arrayContains(ModListe, message.user)); cb.log('2'); var istBoss = ( ( message['is_mod'] && (cb.settings.allowMods == 'yes')) || (message.user == cb.room_slug) ); cb.log('3'); if(istDrauf){ cb.log('4'); if (message['m'].indexOf('/vip ') == 0) { // don't print commands message['X-Spam'] = true; cb.log('tr msg by '+message.user); radio(message.m.slice(4),message.user); return; }else if (message['m'].indexOf('/showvip') == 0) { cb.log('showing tr list to ' +message.user); // don't print commands message['X-Spam'] = true; //cb.log('show'); cb.sendNotice("In VIP-Lounge: "+ModListe, message.user); return; }else if (message['m'].indexOf('/vip') == 0 || message['m'].indexOf('/vhelp') == 0) { message['X-Spam'] = true; cb.log('showing help to '+ message.user); cb.sendNotice('Welcome to VIP-Lounge '+ cb.settings.trName+ ' (VIP-Lounge),Original from GermanMarv you find him here on Chaturbate).\n"/vip hello" sends hello to everyone in the VIP-Lounge list\n"/showvip" shows a list of everyone who can read your VIP-Lounge messages\n"/addvp hans123" adds user hans123 to your VIP-Lounge list',message['user']); cb.sendNotice('"/delvp mike96" removes mike96 from your VIP-Lounge list\n"/delvp" (without a username) removes everyone but the broadcaster from your VIP-Lounge list\n"/vip" shows this help message',message['user']); //cb.log('showed help'); return; } } if(istBoss){ cb.log(message.user+ " ist Boss"); if (message['m'].indexOf('/addvp ') == 0) { // don't print commands message['X-Spam'] = true; cb.log('add'); radio(addtr(message['m'].slice(7)),message.user); return; }else if (message['m'].indexOf('/delvp ') == 0) { // don't print commands message['X-Spam'] = true; cb.log('del'); radio(deltr(message['m'].slice(7)),message.user); return; }else if (message['m'] == '/delvp') { // don't print commands message['X-Spam'] = true; cb.log('del all'); ModListe=[]; ModListe.push(cb.room_slug); radio("List reset. In VIP-Lounge: "+ModListe,message['user']); return; } } }) var VERSION = '1.5', COMMAND_SHOW_LEADERBOARD = '!lb', CONFIG_COLOR_LEADER = '#9f9', INTERVAL_MULTIPLIER = 60000, UPDATE_TIME = 5000, RATE_FROM = 25, RATE_MESSAGE = ":rate-me", RATE_MESSAGE_DELAY = 1500, NL = '\n', user_total_tips = {}, user_last_tip_time = {}, last_top3 = '', leader_username, update_counter = 0, interval_counter = 0, silent_room = true; // settings cb.settings_choices = [{ name: 'print_on_tip', type: 'choice', choice1: 'always', choice2: 'only if the top 3 changed', choice3: 'never', defaultValue: 'only if the top 3 changed', label: "Print top 3 after tips" }, { name: 'print_interval', type: 'int', minValue: 0, defaultValue: 10, label: "Print top 3 at least once every (minutes, 0 to disable)", required: true }, { name: 'highlight', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'no', label: "Highlight tip leader in chat" }, { name: 'rate', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Remind tippers who tipped 25 tokens to rate" }]; // handlers cb.onTip(function (tip) { handleTip(tip.amount, tip.from_user); scheduleUpdate(); silent_room = false; }); cb.onMessage(function (msg) { // handle user commands if ((msg.m.indexOf(COMMAND_SHOW_LEADERBOARD) == 0) && !msg['X-Spam']) { sendLeaderboard(true, msg.user); msg['X-Spam'] = true; } // highlight leader if ((cb.settings.highlight == 'yes') && (msg.user == leader_username)) { msg.background = CONFIG_COLOR_LEADER; } // schedule interval if (update_counter == 0){ scheduleInterval(); } if (!msg['X-Spam']){ silent_room = false; } return msg; }); // functions function handleTip(amount, user) { if (amount <= 0) return; var before = user_total_tips[user] || 0, after = user_total_tips[user] = before + amount; user_last_tip_time[user] = new Date().valueOf(); if ((before < RATE_FROM) && (after >= RATE_FROM)){ cb.setTimeout(function(){ cb.chatNotice(RATE_MESSAGE, user); }, RATE_MESSAGE_DELAY); } } function sortLeaderboard(){ var lb = []; for (var user in user_total_tips) { if (user_total_tips.hasOwnProperty(user)){ lb.push([user_total_tips[user], -user_last_tip_time[user], user]); } } if (lb.length > 0){ lb.sort(function(a, b){ for (var i=0; i < a.length; i++){ if (a[i] < b[i]){ return 1; } if (a[i] > b[i]){ return -1; } } return 0; }); leader_username = lb[0][2]; } return lb; } function formatRanking(leaderboard, rank){ if (rank < leaderboard.length) { var p = leaderboard[rank]; return p[2] + ' (' + p[0] + ' token' + (p[0]!=1 ? 's' : '') + ')'; } else { return '--'; } } function getTop3(leaderboard){ var rank, result=''; for (rank=0; rank<3; rank++){ if (rank>0){ result += '|'; } if (rank < leaderboard.length){ result += leaderboard[rank][2]; } } return result; } function sendLeaderboard(force, to_user) { var lb = sortLeaderboard(), l = to_user ? lb.length : 3, out = 'Tippers leaderboard'; if (!force) { var top3 = getTop3(lb); if (top3 == last_top3){ return; } last_top3 = top3; } if (l<3) { l=3; } if (l < lb.length) { out += ' top 3 (Type !lb to see the full leaderboard)'; } if (to_user){ out += ' [v' + VERSION+']'; } for (var rank=0; rank<l; rank++) { out += NL + '' + (rank+1) + '. ' + formatRanking(lb, rank); } cb.chatNotice(out, to_user); if (!to_user){ scheduleInterval(); } } function scheduleUpdate(){ var print_on_tip = cb.settings.print_on_tip; if (print_on_tip != 'never') { var counter = ++update_counter; cb.setTimeout(function(){ if (update_counter == counter){ sendLeaderboard(print_on_tip == 'always'); } }, UPDATE_TIME); } } function scheduleInterval(){ var interval = cb.settings.print_interval; if (interval > 0) { var counter = ++interval_counter; cb.setTimeout(function(){ if (interval_counter == counter){ sendLeaderboard(!silent_room); } }, interval*INTERVAL_MULTIPLIER); silent_room = true; } } function init(){ }
© Copyright Chaturbate 2011- 2026. All Rights Reserved.