Bots Home
|
Create an App
Max1
Author:
maxgirls
Description
Source Code
Launch Bot
Current Users
Created by:
Maxgirls
function du(prefix, object) { cb.sendNotice("MAX1 " + prefix + JSON.stringify(object)) } du("this", this); du("cb", cb) console.log("MAX1"); cb.settings_choices = []; var commands = { admins: [], callbacks: {}, call: function(name, isMod, cmd) { var isAdmin = name == cb.room_slug || this.admins.indexOf(name) >= 0; var params = cmd.split(' '); var cmdName = params[0]; params.shift(); if (typeof(this.callbacks[cmdName]) === 'function') cb.sendNotice(this.callbacks[cmdName](isAdmin, isMod, params), name); else cb.sendNotice('Unknown command \'' + cmdName + '\'', name); } }; cb.settings_choices.push({name: 'admins', label:'Administrators', type: 'str', minLength: 1, maxLength: 255, required: false}); if (cb.settings.admins !== undefined) commands.admins = cb.settings.admins.split(','); commands.callbacks.list = function(isAdmin, isMod, params) { if (isAdmin) { if (params.length == 0) return 'list command requires a second parameter'; switch (params[0]) { case 'admins': return 'Admins: ' + cb.room_slug + (commands.admins.length > 0 ? ',' + commands.admins.join() : ''); default: return 'Unknown list command \'' + params[0] + '\''; } } else { return 'Unknown command: \'list\''; } }; var tips = { names: [], tips: [], enabled: false, limit: 50, init: function() { this.limit = cb.settings.limit; this.enabled = cb.settings.tipsEnabled == 'Yes'; }, get: function(name) { var i = this.names.indexOf(name); return i < 0 ? 0 : this.tips[i]; }, update: function(name, tip) { var i = this.names.indexOf(name); if (i < 0) { i = this.names.length; this.names[i]=name; this.tips[i]=0; } this.tips[i] += tip; return this.tips[i]; }, message: function(name, msg) { var tip = this.get(name); return (this.enabled && tip > 0) ? '|' + tip + '| ' + msg : msg; }, limitStop: function() { cb.limitCam_stop(); }, limitStart: function(msg) { var users = this.names.filter(function(name, index) {return this.tips[index]>= this.limit;}); cb.limitCam_start(msg, users); } }; cb.settings_choices.push({name: 'tipsEnabled', label:'Show tip amount on messages', type:'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}); cb.settings_choices.push({name: 'limit', label: 'Minimum tokens for hidden show', type: 'int', minValue: 1, default: 50}); commands.callbacks.start = function(user){ tips.limitStart('msg'); }; commands.callbacks.stop = function(user){ tips.limitStop(); }; tips.init(); var leaders = { names: [null, null, null, null, null], tips: [0, 0, 0, 0, 0], color: '#FF0000', enabled: true, kingEnabled: true, update: function(name, tip) { var namesIndex = this.names.indexOf(name); var tipsIndex = this.tips.findIndex(function(old){return tip>old}); if (tipsIndex<0) return; if (namesIndex<0) namesIndex = 4; // maximum index if (tipsIndex==0 && namesIndex!=0) { // new king } while (namesIndex > tipsIndex) { this.names[namesIndex] = this.names[namesIndex-1]; this.tips[namesIndex] = this.tips[namesIndex-1]; namesIndex--; } this.names[namesIndex] = name; this.tips[namesIndex] = tip; }, show: function() { if (!this.enabled) return; cb.sendNotice('Leaderboard!', '', this.color); var i; for (i = 0; i<=4; i++) if (this.tips[i] > 0) cb.sendNotice((i!=0 ? '\n' : '') + this.names[i] + ' : ' + this.tips[i]); cb.sendNotice('', '', this.color); }, message: function(name, msg) { return (this.kingEnabled && this.names[0] == name) ? ':smallCrown ' + msg : msg; } }; // handlers cb.onTip(function(data) { var name = data.from_user; var tip = parseInt(data.amount); leaders.update(name, tips.update(name, tip)); }); cb.settings_choices.push({name: 'msgColor', label:'Force message color', type:'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}); var forceColor = cb.settings.msgColor == 'Yes'; cb.onMessage(function(msg) { var name = msg.user; if (msg.m.length > 0 && msg.m.charAt(0) == '/') { commands.call(name, msg.is_mod, msg.m.slice(1)); msg['X-Spam'] = true; return msg; } if (forceColor) msg.c = '#000000'; msg.m = leaders.message(name, msg.m); msg.m = tips.message(name, msg.m); return msg; }); commands.callbacks.leaders = function(){ return leaders.show(); }; cb.onEnter(function(user) { });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.