Bots Home
|
Create an App
testuser2017
Author:
testuser2017
Description
Source Code
Launch Bot
Current Users
Created by:
Testuser2017
// Title: Made It Rain // Author: Stix (jhamerstix@myself.com) // Original Script Authors: jalbre // Version: 3.0 (04/05/2017) // Description: Make it Rain with color in chat var total_tipped = 0; var i; var cbColor = cb.settings.rain_color; var VERSION = 'Leader Board Top 3 Tippers', COMMAND_SHOW_LEADERBOARD = '!lb', INTERVAL_MULTIPLIER = 60000, UPDATE_TIME = 5000, RATE_FROM = 25, RATE_MESSAGE = "Remember to rate :ratesatisfied and also :followtag", RATE_MESSAGE_DELAY = 3000, NL = '\n', user_total_tips = {}, user_last_tip_time = {}, last_top3 = '', leader_username, update_counter = 0, interval_counter = 0, silent_room = true; cb.settings_choices = [ {name: 'min_tokens', type: 'int', minValue: 1, maxValue: 10000, defaultValue: 150, label: "How Many Tokens to Make It Rain?"}, {name: 'print_interval', type: 'int', minValue: 0, defaultValue: 15, label: "When to Show Leader Board (minutes, 0 to disable)", required: true}, {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: 'rate', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Remind tippers who tipped 25 tokens to rate"}, {name: 'rain_amount', type: 'int', minValue: 1, maxValue: 50, defaultValue: 25, label: "How Many Lines of Rain?"}, {name: 'ad_time', type: 'choice', choice1:'5', choice2:'10', choice3:'15', choice4:'20', defaultValue:'15', label: 'Remind Users To Make It Rain (every 15 minutes is default)'}, {name: 'rain_color', type: 'choice', choice1:'Aqua', choice2:'Aquamarine', choice3:'Black', choice4:'Blue', choice5:'BlueViolet', choice6:'Chartreuse', choice7:'CornflowerBlue', choice8:'Cyan', choice9:'DarkBlue', choice10:'DarkCyan', choice11:'DarkGreen', choice12:'DarkOrange', choice13:'DarkOrchid', choice14:'DarkTurquoise', choice15:'DeepPink', choice16:'DodgerBlue', choice17:'ForestGreen', choice18:'Gold', choice19:'Green', choice20:'GreenYellow', choice21:'LawnGreen', choice22:'Lime', choice23:'LimeGreen', choice24:'Magenta', choice25:'Red', choice26:'RoyalBlue', choice27:'SpringGreen', choice28:'Turquoise', choice29:'Yellow', choice30:'Randomize Colors', defaultValue: 'Randomize Colors', label: 'Rain Color'} ]; var colorPalette = { Aqua: "#00FFFF", Aquamarine: "#7FFFD4", Black: "#000000", Blue: "#0000FF", BlueViolet: "#8A2BE2", Chartreuse: "#7FFF00", CornflowerBlue: "#6495ED", Cyan: "#00FFFF", DarkBlue: "#00008B", DarkCyan: "#008B8B", DarkGreen: "#006400", DarkOrange: "#FF8C00", DarkOrchid: "#9932CC", DarkTurquoise: "#00CED1", DeepPink: "#FF1493", DodgerBlue: "#1E90FF", ForestGreen: "#228B22", Gold: "#FFD700", Green: "#008000", GreenYellow: "#ADFF2F", LawnGreen: "#7CFC00", Lime: "#00FF00", LimeGreen: "#32CD32", Magenta: "#FF00FF", Red: "#FF0000", RoyalBlue: "#4169E1", SpringGreen: "#00FF7F", Turquoise: "#40E0D0", Yellow: "#FFFF00" }; function rHex() { return '#000000'.replace(/0/g,function(){return (~~(Math.random()*16)).toString(16);}); } cb.onTip(function (tip) { handleTip(tip.amount, tip.from_user); scheduleUpdate(); silent_room = false; var color; if(cbColor != "Randomize Colors"){ color = colorPalette[cbColor]; } else if (cbColor = "Randomize Colors"){ color = rHex(); } total_tipped = parseInt(tip['amount']); if(total_tipped >= cb.settings.min_tokens) { cb.sendNotice("$$$ " + tip['from_user'] + " made it rain! $$$", '', '', color, 'bolder'); for(i=0;i<cb.settings.rain_amount;i++) { var dollars = Math.ceil(Math.random() * 21); var msg = ''; while(dollars) { msg += "$"; dollars--; } cb.sendNotice(msg, '', '', color, 'bolder'); } cb.sendNotice(tip['from_user'] + " Tipped " + total_tipped + " For This Rain!", '', '#000000', '#00ff00', 'bolder'); cb.sendNotice(" :thanks2 " + tip['from_user'] + " For Tipping :mclap :blowkiss", '', '#FFFFFF', '#ff0000', 'bolder'); cb.log(tip['from_user'] + " Tipped " + total_tipped); } }); // 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.sendNotice(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 = 'Todays Top 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 Leader Board)'; } if (to_user){ out += ' [' + VERSION+']'; } for (var rank=0; rank<l; rank++) { out += NL + '' + (rank+1) + '. ' + formatRanking(lb, rank); } cb.sendNotice(out, to_user, '#FFFFFF', '#000000', 'bold'); 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; } } cb.onMessage(function (msg) { // Sends the Leader Board to user that requested it if ((msg.m.indexOf(COMMAND_SHOW_LEADERBOARD) == 0) && !msg['X-Spam']) { sendLeaderboard(true, msg.user); msg['X-Spam'] = true; } return msg; }); // schedule interval if (update_counter == 0) { scheduleInterval(); } function roomNotify() { var cbTime = cb.settings.ad_time; var ad_time; if (cbTime == "5") { ad_time = "300000"; } else if (cbTime == "10") { ad_time = "600000"; } else if (cbTime == "15") { ad_time = "900000"; } else if (cbTime == "20") { ad_time = "1200000"; } cb.sendNotice(" :rainingluv Tip " + cb.settings.min_tokens + " To Make It Rain :raintkn", '', '#FFFFFF', '#FF0000', 'bold'); cb.setTimeout(roomNotify, ad_time) } function init() { roomNotify(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.