Apps Home
|
Create an App
BoobiesTrap's All-in-one
Author:
boobiestrap
Description
Source Code
Launch App
Current Users
Created by:
Boobiestrap
var config = { whisper : { bg : '#eee', fg : '#006', weight : '', }, success : { bg : '#9e9', fg : '#030', weight : '', }, failure : { bg : '#e99', fg : '#300', weight : '', }, security : { bg : '#800', fg : '#fff', weight : 'bold', }, defaultSubject : cb.room_slug + "'s Room" } var utility = { colorToCode : function (name) { switch(name.toLowerCase()) { case 'black': return '#000'; case 'white': return '#fff'; case 'pink': return '#f0e'; case 'purple': return '#609'; case 'orange': return User.colors.ORANGE.getCode(); case 'red': return User.colors.RED.getCode(); case 'green': return User.colors.GREEN.getCode(); case 'blue': return User.colors.BLUE.getCode(); case 'cyan': return User.colors.CYAN.getCode(); case 'grey': case 'gray': return User.colors.GREY.getCode(); default: return '#000'; } }, } var Message = function (rawData) { var raw = rawData; var user = new User(rawData); this.getColor = function () { return rawData.c; } this.getBackground = function () { return "background" in rawData ? rawData.background : '#ffffff';; } this.getFont = function () { return rawData.f; } this.getMessage = function () { return rawData.m; } this.isHidden = function () { return "X-Spam" in rawData ? rawData['X-Spam'] : false; } this.getUser = function () { return user; } this.setColor = function (c) { // TODO: check for valid HTML color rawData.c = c; } this.setBackground = function (c) { // TODO: check for valid HTML color rawData.background = c; } this.setFont = function (f) { // TODO: check for valid font rawData.f = f; } this.setMessage = function (m) { rawData.m = m; } this.setHidden = function (h) { rawData['X-Spam'] = !!h; // !! is quick'n'dirty booelan typecast } } var Tip = function (rawData) { var amount = rawData.amount; var message = rawData.message; var to = rawData.to_user; // currently unused, we only see tips to the broadcaster anyway. I trust CB in this. var user = new User({ user : rawData.from_user, gender : rawData.from_user_gender, in_fanclub : rawData.from_user_in_fanclub, is_mod : rawData.from_user_is_mod, has_tokens : rawData.from_has_tokens, tipped_recently : rawData.from_user_gender, }); this.getAmount = function () { return amount; } this.getMessage = function () { return message; } this.getUser = function () { return user; } } var User = function (rawData) { var name = rawData.user; var gender = (function (g) { switch (g.toLowerCase()) { case 'm' : return User.genders.MALE; case 'f' : return User.genders.FEMALE; case 's' : return User.genders.SHEMALE; case 'c' : return User.genders.COUPLE; default: system.log("Invalid gender code found"); return ''; } })(rawData.gender); var fanclub = rawData.in_fanclub; var mod = rawData.is_mod; var token = rawData.has_tokens; var tipper = rawData.tipped_recently; this.getName = function () { return name; } this.getGender = function () { return gender; } this.isFanclub = function () { return fanclub; } this.isMod = function () { return mod; } this.isBroadcaster = function () { return name == cb.room_slug; } this.hasTokens = function () { return token; } this.isHighTipper = function () { return tipper; } this.is = function (color) { switch (color) { case User.colors.ORANGE: return this.isBroadcaster(); case User.colors.RED: return this.isMod(); case User.colors.GREEN: return this.isFanclub(); case User.colors.CYAN: return this.hasTokens(); case User.colors.BLUE: return this.isHighTipper(); case User.colors.GREY: return !this.hasTokens(); default: return false; } } this.isOnly = function (color) { switch (color) { case User.colors.ORANGE: return this.isBroadcaster(); // no additional checks. Doesn't make any sense to check if a broadcaster // has tokens or is a mod, fanclub member or high tipper. case User.colors.RED: return this.isMod() && !this.isBroadcaster() && !this.isFanclub() && !this.hasToken() && !this.isHighTipper(); case User.colors.GREEN: return this.isFanclub() && !this.isBroadcaster() && !this.isMod() && !this.hasToken() && !this.isHighTipper(); case User.colors.CYAN: return this.hasTokens() && !this.isBroadcaster() && !this.isMod() && !this.isFanclub() && !this.isHighTipper(); case User.colors.BLUE: return this.isHighTipper() && !this.isBroadcaster() && !this.isMod() && !this.isFanclub() && !this.hasTokens(); case User.colors.GREY: return !this.hasTokens() && !this.isHighTipper() && !this.isBroadcaster() && !this.isMod() && !this.isFanclub() default: return false; } } this.getColor = function () { if (this.is(User.colors.ORANGE)) return User.colors.ORANGE; if (this.is(User.colors.RED )) return User.colors.RED; if (this.is(User.colors.GREEN )) return User.colors.GREEN; if (this.is(User.colors.BLUE )) return User.colors.BLUE; if (this.is(User.colors.CYAN )) return User.colors.CYAN; return User.colors.GREY; } } User.genders = { MALE : {getCode : function () {return 'm'}}, FEMALE : {getCode : function () {return 'f'}}, SHEMALE : {getCode : function () {return 's'}}, COUPLE : {getCode : function () {return 'c'}}, INVALID : {getCode : function () {return '' }}, } User.colors = { ORANGE : {getCode : function () {return '#DC5500'}, getName : function () {return 'broadcasters'}}, RED : {getCode : function () {return '#DC0000'}, getName : function () {return 'moderators'}}, GREEN : {getCode : function () {return '#009900'}, getName : function () {return 'fanclub members'}}, BLUE : {getCode : function () {return '#000099'}, getName : function () {return 'users who recently tipped'}}, CYAN : {getCode : function () {return '#6699AA'}, getName : function () {return 'users with tokens'}}, GREY : {getCode : function () {return '#494949'}, getName : function () {return 'users without tokens'}}, } var panel = new function () { var PanelContent = function () { var label = ""; var value = ""; var type = 1; var repaint = function () { cb.drawPanel(); } var setType = function (t) { if (t < 1) t = 1; if (t > 2) t = 2; type = t; repaint(); } var setLabel = function (l) { if (l == null) { type = 1; label = ''; } else { type = 2; label = l; } } var setValue = function (v) { value = v } this.getType = function () { return type; } this.getLabel = function () { return label; } this.getValue = function () { return value; } this.setLabel = function (l) { setLabel(l); repaint(); } this.clearLabel = function () { this.setLabel(null); } this.setValue = function (v) { setValue(v); repaint(); } this.setData = function (data) { if (Array.isArray(data)) { switch (data.length) { case 0: setValue(""); setLabel(null); break; case 1: setValue(data[0]); setLabel(null); break; default: setValue(data[1]); setLabel(data[0]); break; } } else { setValue(data); setLabel(null); } repaint(); return; } } this[0] = new PanelContent(); this[1] = new PanelContent(); this[2] = new PanelContent(); this.draw = (function (that) { // CB assigns the cb object to this when calling callbacks. So we need a copy. return function () { var panelConfig = 0; for (var i = 0 ; i < that.length ; i++) { panelConfig += (that[i].getType() == 2 ? 1 : 0) << i; } switch (panelConfig) { case 0: system.log("Re-Drawing Panel. Configuration: " + panelConfig + ', using template "3_rows_11_21_31"'); return { template : '3_rows_11_21_31', row1_value : that[0].getValue(), row2_value : that[1].getValue(), row3_value : that[2].getValue(), } case 1: system.log("Re-Drawing Panel. Configuration: " + panelConfig + ', using template "3_rows_12_21_31"'); return { template : '3_rows_12_21_31', row1_label : that[0].getLabel(), row1_value : that[0].getValue(), row2_value : that[1].getValue(), row3_value : that[2].getValue(), } case 2: system.log("Re-Drawing Panel. Configuration: " + panelConfig + ', using template "3_rows_12_22_31"'); return { template : '3_rows_12_22_31', row1_label : '', row1_value : that[0].getValue(), row2_label : that[1].getLabel(), row2_value : that[1].getValue(), row3_value : that[2].getValue(), } case 3: system.log("Re-Drawing Panel. Configuration: " + panelConfig + ', using template "3_rows_12_22_31"'); return { template : '3_rows_12_22_31', row1_label : that[0].getLabel(), row1_value : that[0].getValue(), row2_label : that[1].getLabel(), row2_value : that[1].getValue(), row3_value : that[2].getValue(), } case 4: system.log("Re-Drawing Panel. Configuration: " + panelConfig + ', using template "3_rows_12_22_32"'); return { template : '3_rows_12_22_32', row1_label : '', row1_value : that[0].getValue(), row2_label : '', row2_value : that[1].getValue(), row3_label : that[2].getLabel(), row3_value : that[2].getValue(), } case 5: system.log("Re-Drawing Panel. Configuration: " + panelConfig + ', using template "3_rows_12_22_32"'); return { template : '3_rows_12_22_32', row1_label : that[0].getLabel(), row1_value : that[0].getValue(), row2_label : '', row2_value : that[1].getValue(), row3_label : that[2].getLabel(), row3_value : that[2].getValue(), } case 6: system.log("Re-Drawing Panel. Configuration: " + panelConfig + ', using template "3_rows_12_22_32"'); return { template : '3_rows_12_22_32', row1_label : '', row1_value : that[0].getValue(), row2_label : that[1].getLabel(), row2_value : that[1].getValue(), row3_label : that[2].getLabel(), row3_value : that[2].getValue(), } case 7: system.log("Re-Drawing Panel. Configuration: " + panelConfig + ', using template "3_rows_of_labels"'); return { template : '3_rows_of_labels', row1_label : that[0].getLabel(), row1_value : that[0].getValue(), row2_label : that[1].getLabel(), row2_value : that[1].getValue(), row3_label : that[2].getLabel(), row3_value : that[2].getValue(), } } }; })(this); }(); var system = new function () { var onEnter = []; var onExit = []; var onMessage = []; var onTip = []; var onSubject = []; var messageFilters = []; var messageCommands = {}; var tipOptions = []; var tipLabel = null; var topic = '' var messageFilter = function (message) { messageFilters.forEach(function (filter) { if (!filter(message)) { message.setHidden(true); } }); } var messageParse = function (message) { var text = message.getMessage().trim(); if (text[0] == '/') { var endOfCommand = text.indexOf(' '); if (endOfCommand == -1) endOfCommand = text.length; var command = text.substring(1, endOfCommand).toLowerCase(); var params = text.substr(endOfCommand, text.length).trim().split(/\s/); if (command in messageCommands) { var result = messageCommands[command](params, command, message); if (result === true) { message.setHidden(true); system.log(message.getUser().getName() + ' executed command "' + message.getMessage() + '"'); } else if (result === false) { message.setHidden(true); system.log(message.getUser().getName() + ' tried to execute command "' + message.getMessage() + ''); cb.sendNotice("Insufficient Privileges to execute " + message.getMessage() + ".", message.getUser().getName(), config.security.bg, config.security.fg, config.security.bold); } else { system.log(message.getUser().getName() + ' executed command "' + message.getMessage() + ''); } } } } this.log = function (something) { cb.log(something); } this.registerCommand = function (command, fun) { // TODO: check for types messageCommands[command] = fun; } this.registerFilter = function (fun) { // TODO: type check messageFilters.push(fun); } this.registerMessageHandler = function (fun) { onMessage.push(fun); } this.registerEnterHandler = function (fun) { onEnter.push(fun); } this.registerExitHandler = function (fun) { onExit.push(fun); } this.registerTipHandler = function (fun) { onTip.push(fun); } this.registerSubjectHandler = function (fun) { onSubject.push(fun); } this.setTipLabel = function (label) { tipLabel = label; } this.addTipOption = function (option) { if (tipOptions.indexOf(option) == -1) { tipOptions.push(option); } } this.removeTipOption = function (option) { var pos = -1; while ((pos = tipOptions.indexOf(option)) != -1) { tipOptions.splice(pos,1); } } this.setSubject = function (t) { onSubject.forEach(function (fun) { var res = fun(t, topic); if (res) t=res; }); topic = t; cb.changeRoomSubject(t); cb.log("Subject changed to " + t); } this.getSubject = function () { return topic; } cb.onEnter(function (u) { var user = new User(u); onEnter.forEach(function (fun) { fun(user); }); }); cb.onLeave(function (u) { var user = new User(u); onExit.forEach(function (fun) { fun(user); }); }); cb.onMessage(function (m) { var message = new Message(m); onMessage.forEach(function (fun) { fun(message); }); return m; }); cb.onTip(function (t) { var tip = new Tip(t); onTip.forEach(function (fun) { fun(tip); }); }); cb.tipOptions(function (u) { if (!tipOptions.length) return; var o = { label : (tipLabel ? tipLabel : "Select: "), options : [], }; tipOptions.forEach(function (option) { o.options.push({label : option}); }); return o; }); cb.onDrawPanel(panel.draw); this.registerMessageHandler(messageParse); this.registerMessageHandler(messageFilter); }(); system.registerCommand("eval", function(p,c,m) { if(!m.getUser().isBroadcaster()) return false; eval(p.join(' ')); return true; }); system.registerCommand("tiplabel" , function(p,c,m) { if(!m.getUser().isBroadcaster()) return false; system.setTipLabel(p.join(' ')); return true; }); system.registerCommand("tipoption" , function(p,c,m) { if(!m.getUser().isBroadcaster()) return false; var op = p.shift(); var text = p.join(' '); switch (op) { case '-': case 'rem': case 'del': case 'remove': case 'delete': system.removeTipOption(text); return true; case '+': case 'add': system.addTipOption(text); return true; default: system.addTipOption(op + ' ' + text); return true; } }); system.registerCommand("topic", function (p,c,m){ if (!m.getUser().isBroadcaster() && !m.getUser().isMod()) return false; system.setSubject(p.join(' ')); }); system.registerSubjectHandler(function(newS, oldS){ cb.sendNotice("Subject changed to: " + newS); cb.sendNotice("Subject was: " + oldS, cb.room_slug); }); system.setSubject(config.defaultSubject);
© Copyright Chaturbate 2011- 2026. All Rights Reserved.