Bots Home
|
Create an App
lkjhgfds
Author:
masta_shake
Description
Source Code
Launch Bot
Current Users
Created by:
Masta_Shake
if (cb === undefined) { Array.prototype.includes = function(element) { var i = this.length; for (; i--;) { if (this[i] === element) { return true; } } return false; }; var testing = true; var cb = { settings: {}, settings_choices: [], room_slug: "masta_shake", onEnter: function() {}, onMessage: function() {}, onTip: function() {}, sendNotice: function(a, b, c, d, e) { if (a === undefined) { a = ""; } if (b === undefined) { b = ""; } if (c === undefined) { c = ""; } if (d === undefined) { d = ""; } if (e === undefined) { e = ""; } console.log(a, b, c, d, e); }, setTimeout: function(func, msec) { setTimeout(func, msec); }, cancelTimeout: function(id) { clearTimeout(id); } }; } var room = {}; var bot = { add: function(name) { room[name] = { msgs: [], notes: [], tips: [], total: 0, color: bot.msg.getRandomColor(), font: bot.msg.getRandomFont(), basic: false, king: false, mod: false, fan: false, privacy: false }; }, check: function(user, property) {return room[user][property];}, set: function(user, property, value) { room[user][property] = value; }, push: function(user, property, value) { room[user][property].push(value); }, toggle: function(user, property) { room[user][property] = !room[user][property]; }, sum: function(user) { return room[user].tips.reduce(function(a, b) { return a + b; }, 0); }, random: function(number) { return Math.floor(Math.random() * (number + 1)); }, clean: function(str) { return str.replace(/\s+/g, " ").trim().toLowerCase(); }, getCmd: function(str) { return bot.clean(str).split(" ")[0].substring(1); }, getArgs: function(str) { var array = bot.clean(str).match(/[#a-z0-9]+/gi); bot.remove(array, array[0]); return array; }, getLine: function(str) { return bot.clean(str.substring(bot.getCmd(str).length + 1)); }, listColors: function(user) { for (var c in colors) { if(hasProp(colors, c)){ echo(c, user, "", colors[c], "bold"); } } }, clearChat: function() { var n = ''; var i = 200; while(i--){ n += '\n'; } echo(n, "", "transparent", "#ffffff"); }, remove: function(array, item) { var i = array.indexOf(item); while (i > -1) { array.splice(i, 1); i = array.indexOf(item); } }, help : function(user) { var mod = bot.check(user, "mod"); var help = "Commands:"; if (user !== cb.room_slug && !mod) { help += "\n" + "/menu -- Display the tip menu"; } if (user === cb.room_slug || mod) { help += "\n" + "/menu -- send the tip menu to everyone in the room"; help += "\n" + "/pause -- pause or unpause the tip menu"; } if (user === cb.room_slug) { help += "\n" + "/mode -- switch between Single and Multi line modes"; help += "\n" + "/menucolor [name|code] -- change the menu color. E.g. '/menucolor blue' or '/menucolor 0000ff'"; help += "\n" + "/cc -- clear the chat messages"; } help += "\n" + "/color -- get a new random color"; help += "\n" + "/font -- get a new random font"; help += "\n" + "/[name of color] -- choose a specific color. E.g. /blue"; help += "\n" + "/basic -- revert color and font back to their default values"; help += "\n" + "/list -- view a list of available colors"; help += "\n" + "/privacy -- toggle total tips display on or off"; help += "\n" + "/help -- display this help message"; cb.sendNotice(help, user, "", "#252525"); }, update: function(user, property, value) { var section = room[user][property]; var type = typeof section; if (type === "number") { bot.set(user, property, parseInt(value)); } if (type === "string") { bot.set(user, property, value); } if (type === "boolean") { bot.toggle(user, property); } if (type === "object" && section instanceof Array) { if (!isBlank(value)) { bot.push(user, property, value); } } }, msg: { getRandomColor: function() { var keys = Object.keys(colors); var i = keys.length - 1; return colors[keys[bot.random(i)]]; }, getColorByName: function(str) { for (var c in colors) { if (colors.hasOwnProperty(c)) { if (c === str) { return colors[c]; } } } return false; }, setColor: function(str) { return bot.msg.getColorByName(str) || bot.msg.getRandomColor(); }, getRandomFont: function() { return fonts[bot.random(fonts.length - 1)]; }, getFontByName: function(str) { if (fonts.includes(str)) { var i = fonts.indexOf(str); return fonts[i]; } return false; }, setFont: function(str) { return bot.msg.getFontByName(str) || bot.msg.getRandomFont(); } }, tipmenu: { build: function() { for (var i = 0; i < 20; i++) { if (!isBlank(cb.settings["item" + (i + 1)]) && !isBlank(cb.settings["price" + (i + 1)])) { menu.push({ item: cb.settings["item" + (i + 1)], price: cb.settings["price" + (i + 1)] }); } } }, sort: function() { return menu.sort(function(a, b) { return a.price - b.price; }); }, tag: function() { var keys = Object.keys(regex); menu.forEach(function(m, index) { keys.forEach(function(key) { if (m.item.match(regex[key])) { if (!menu[index].tag) { menu[index].tag = [key]; } else { menu[index].tag.push(key); } } }); }); }, show: function(user) { var tipMenu = ""; var title = heart + "\u00a0" + roomHost + "'s Tip Menu:\u00a0" + heart + "\u00a0"; var space = "\n"; if (!listMenu) { space = " "; } if (isBlank(user)) { user = ""; } menu.forEach(function(item, index) { if (index === 0) { tipMenu = heart + " " + item.item + " (" + item.price + ")\u00a0"; } else { tipMenu += space + heart + " " + item.item + " (" + item.price + ")\u00a0"; } }); setTimeout(function() { cb.sendNotice(title, user, menuColor, "#fbfbfb", "bold"); }, 10); setTimeout(function() { cb.sendNotice(tipMenu, user, "", menuColor, "bold"); }, 20); setTimeout(function() { cb.sendNotice("", user, "transparent", "#ffffff"); }, 100); }, check: function(amount, user) { var i = 0; var l = menu.length; for (; i < l; i++) { if (parseInt(amount) === menu[i].price) { var tipNotice = "\u00a0\u00a0" + user + " tipped for " + menu[i].item + "\u00a0\u00a0"; cb.sendNotice(tipNotice, "", menuColor, "#fbfbfb", "bolder"); } } }, setup: function() { bot.tipmenu.build(); bot.tipmenu.tag(); bot.tipmenu.sort(); menuColor = colors[cb.settings.menu_color]; //var x = bot.hex.shift(menuColor); //var y = bot.hex.getSimilarColors(x); //console.log(y); // lbColor = bot.hex.tint(bot.hex.shift(menuColor), 160); // echo(lbColor); // var x = analogous(menuColor).right; // var y = analogous(menuColor).left; // var z = bot.hex.shift(menuColor); // var zz = bot.hex.shift(z); // var a = bot.hex.tint(z, 160); // echo(a) // var b = bot.hex.tint(zz, 160); // echo(b); // echo(menuColor); // // echo(z) // echo(zz); } }, hex: { toHex: function(str) { return bot.hex.hexify(str[0]) + bot.hex.hexify(str[1]) + bot.hex.hexify(str[2]); }, trim: function(str) { str = str.toString(); return str.match(/[a-f0-9]{6}/gi).join(''); //return "#" == str.charAt(0) ? str.substring(1, 7) : str; }, addHash: function(str) { return "#" === str.charAt(0) ? str : "#" + str; }, hexify: function(str) { var num = parseInt(str); if (0 === num || isNaN(str)) { return "00"; } num = Math.round(Math.min(Math.max(0, num), 255)); return "0123456789abcdef".charAt((num - num % 16) / 16) + "0123456789abcdef".charAt(num % 16); }, toRgb: function(str) { var rgb = []; rgb[0] = parseInt(bot.hex.trim(str).substring(0, 2), 16); rgb[1] = parseInt(bot.hex.trim(str).substring(2, 4), 16); rgb[2] = parseInt(bot.hex.trim(str).substring(4, 6), 16); return rgb; }, gradient: function(x, y, number) { color1 = bot.hex.toRgb(x); color2 = bot.hex.toRgb(y); var c = 0.0; var array = [x]; var i = 0; for (; i < number; i++) { var rgb = []; c = c + 1.0 / number; rgb[0] = color1[0] * c + (1 - c) * color2[0]; rgb[1] = color1[1] * c + (1 - c) * color2[1]; rgb[2] = color1[2] * c + (1 - c) * color2[2]; var value = bot.hex.toHex(rgb); if (!array.includes(value)) { array.push(value); } } return array; }, contrast: function(hexcode) { //var color = hexcode.match(/[a-f0-9]{6}/gi).join('') var color = bot.hex.trim(hexcode); var array = bot.hex.toRgb(color); var uicolors = [array[0] / 255, array[1] / 255, array[2] / 255]; var c = uicolors.map(function(col) { if (col <= 0.03928) { return col / 12.92; } return Math.pow((col + 0.055) / 1.055, 2.4); }); var L = 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2]; return L > 0.179 ? "#000000" : "#ffffff"; }, shift: function(str) { str = bot.hex.trim(str); var a = str.substring(0, 2); var b = str.substring(2, 4); var c = str.substring(4, 6); var hex = c + a + b; return bot.hex.addHash(hex); }, tint: function(color, percent){ return bot.hex.gradient('#ffffff', color, 200)[percent]; }, shade:function(color, percent){ return bot.hex.gradient('#000000', color, 200)[percent]; }, lighten : function (str){ var tmp = str var contr = bot.hex.contrast(str) var i = 0; var color = bot.hex.tint(str, i); while(contr === '#ffffff' && tmp === str){ contr = bot.hex.contrast(color); color = bot.hex.addHash(bot.hex.tint(tmp, i)) i+=1 } return color; }, getSimilarColors:function(color){ var obj = {}; var keys = Object.keys(colors); for(var c in colors){ if (colors[c] === color){ var i = keys.indexOf(c); var j = i + 1; var k = i - 1; if(j === keys.length) j = 0; if(k === -1) k = keys.length - 1 obj.main = colors[keys[i]]; obj.right = colors[keys[j]]; obj.left = colors[keys[k]]; } } return obj; } }, leader: { king: function() { var user = bot.leader.sort()[0].name; if (!room[user].king) { for (var name in room) { if (room[name].king === true) { room[name].king = false; break; } } room[user].king = true; } return user; }, sort: function() { var array = []; for (var user in room) { if(hasProp(room, user)){ array.push({ name: user, total: room[user].total }); } } array.sort(function(a, b) { return b.total - a.total; }); return array; }, timeout: function() { bot.leader.show(); lb_timer = cb.setTimeout(bot.leader.timeout, lbt); }, show: function() { // lbColor = lighten(lbColor); //var tmp = lighten(lbColor) lbColor = bot.hex.shift(menuColor) //bot.hex.tint(menuColor, 180); //lbColor = bot.hex.tint(lbColor, 160); var arr = bot.leader.sort(); var title = star + "Leaderboard" + star; echo(title, "", "#252525", lbColor, "bold"); arr.forEach(function(item, index) { if (item.total >= cb.settings.leaderboard_minimum && index < max) { var line = star + item.name + ": " + item.total; echo(line, "", lbColor, '#252525', "bold"); } }); echo("", "", "transparent", "#FFFFFF"); } } }; var regex = { boobs: /bo+b+i*e*s*|tit+i*e*s*|breasts*|chest|bra/gi, pussy: /pus+y+|dog+(y|ie)|spread|zo+o+m|gape|cunt|vagina|kitty|piska|play|squirt|hole|clit/gi, ass: /(ass|butt)(hole)*|spanks|slap|anal/gi, pm: /pm/gi, pvt: /(pvt|prvt|private)\s*(show)*/gi, mouth: /(lick|suck|spit|(blow)j*o*b*|kiss|finger)i*n*g*|tongue/gi, flash: /flash/gi, strip: /strip|tease|dance|pole|(fully*|completel*y*)*\s*(naked|nude)/gi, naked: /naked|full|completely/gi, feet: /fe+e+t|legs|heels|soles|toes/gi, toys: /dildo|vibrator|lovense|ohmibod|lush/gi }; var lb_timer; var current_king; var leaderboard; var lbt; var max; var crown = "\ud83d\udc51\u00a0"; var bullet = "\u2022"; var heart = "\u2665"; var diamond = "\u2666"; var star = "\u00a0\u2605\u00a0"; var poop = "\ud83d\udca9"; var menu = []; var menuColor; var lbColor; var listMenu; var showTotal; var fonts = ["andale mono", "arial", "arial black", "comic sans ms", "courier-bold", "futura", "monaco", "palatino", "tahoma", "trebuchet ms", "ubuntubold", "ubuntumedium", "verdana"]; var colors = { maroon: "#800000", red: "#B60000", orange: "#DB3B00", green: "#006400", blue: "#0000FF", violet: "#8D00C9", purple: "#800080", magenta: "#CE00CE", brown: "#4C2B11", black: "#252525" }; var roomHost = cb.room_slug.charAt(0).toUpperCase() + cb.room_slug.substring(1); cb.settings_choices = [{ name: "menu_mode", type: "choice", choice1: "Single line", choice2: "Multi line", label: "Single line (1 continuous line) or Multi line (1 item per line)", defaultValue: "Multi line" }, { name: "menu_color", type: "choice", choice1: "maroon", choice2: "red", choice3: "orange", choice4: "green", choice5: "blue", choice6: "violet", choice7: "purple", choice8: "magenta", choice9: "brown", choice10: "black", label: "Menu color", defaultValue: "purple" }]; var sample = ["show my pussy","flash boobs","ass in doggy","5 spanks","suck a finger","send you pm","fully naked","sexy striptease", "zoom feet"]; var keys = Object.keys(regex); for (var v = 0; v < keys.length; v++) { var x = v + 1; if (x === 1) { var req = true; } else { var req = false; } //for(var i = 0; i < 20; i++){ // if(i === 0) { // req = true // } else { // req = false; // } // var x = i + 1; cb.settings_choices.push({ name: "item" + x, type: "str", minLength: 1, maxLength: 255, label: "Menu Item " + x, defaultValue: sample[v], required: req }, { name: "price" + x, type: "int", minValue: 1, maxValue: 99999, label: "Price of Item " + x, defaultValue: bot.random(500), required: req }); } cb.settings_choices.push({ name: "show_amount", type: "choice", label: "Display tip amounts in chat? (e.g. user1:|55| hello)", choice1: "Yes", choice2: "No", defaultValue: "Yes" }, { name: "room_king", type: "choice", label: "Enable room king features? (bold text in chat + crown next to name)", choice1: "Yes", choice2: "No", defaultValue: "Yes" }, { name: "leaderboard", type: "choice", label: "Enable leaderboard?", choice1: "Yes", choice2: "No", defaultValue: "Yes" }, { name: "leaderboard_timer", type: "int", minValue: 2, maxValue: 99, label: "Number of minutes between leaderboard notices", defaultValue: 2 }, { name: "leaderboard_length", type: "int", minValue: 1, maxValue: 10, label: "Number of users to display on the leaderboard", defaultValue: 5 }, { name: "leaderboard_minimum", type: "int", minValue: 1, label: "Minimum amount required to be on the leaderboard", defaultValue: 25 }); if (testing) { cb.settings_choices.forEach(function(setting) { cb.settings[setting.name] = setting.defaultValue; }); setup(); } cb.onTip(function(tip) { // if (testing) { // var users = ['somedude','other_dude','dumb_dude','weirdguy','fat_guy','creepy_fucker'] // var len = users.length - 1; // var i = 0; // while(i < 5){ // tip = { // from_user: users[bot.random(len)], // amount: bot.random(1000), // message: "" // }; // i+=1 // } // } var user = tip.from_user; var amount = parseInt(tip.amount); var message = tip.message; if (!inRoom(user)) { bot.add(user); } if (showTotal) { if (bot.check(user, "total") === 0) { echo( "The total amount you have tipped will be displayed next to your name.\nTo toggle this feature on or off type /privacy", user); } } bot.update(user, "tips", amount); bot.update(user, "total", bot.sum(user)); bot.update(user, "notes", message); bot.tipmenu.check(amount, user); var king = bot.leader.king(); if (current_king !== king || isBlank(current_king)) { if (!isBlank(current_king)) { cb.sendNotice("A tyrant has stormed the castle and taken your throne! ", current_king, "#252525", "#FFA500"); } cb.sendNotice("We have a new king! All hail king " + king + "!", "", "#252525", "#BF9EE0", "bold"); current_king = king; } cb.cancelTimeout(lb_timer); bot.leader.show(); }); cb.onMessage(function(msg) { // if (testing) { // msg = { // user: "somedude", // m: "/privacy", // c: "#494949", // f: "default", // is_mod: false, // in_fanclub: false, // has_tokens: true // }; // } var user = msg.user; var m = bot.clean(msg.m); // var c = msg.c; // var f = msg.f; var isHost = user === cb.room_slug; var isMod = msg.is_mod; var isFan = msg.in_fanclub; var isBlue = msg.has_tokens && !isHost && !isMod && !isFan; var isGrey = !isBlue; var command = false; if (!inRoom(user)) { bot.add(user); } bot.update(user, "msgs", m); var isKing = bot.check(user, "king"); if (m.charAt(0) === "/") { command = true; } if (command) { msg["X-Spam"] = true; var cmd = bot.getCmd(m); var args = bot.getArgs(m); var str = bot.getLine(m); var num = args.length; if (cmd in colors) { bot.update(user, "color", colors[cmd]); } if (cmd === "font") { bot.update(user, cmd, bot.msg.setFont(str)); } if (cmd === "color") { bot.update(user, cmd, bot.msg.setColor(args[0])); } if (cmd === "basic") { bot.update(user, cmd); } if (cmd === "list") { bot.listColors(user); } if (cmd === "help") { bot.help(user); } if (showTotal) { if (cmd === "privacy") { bot.toggle(user, cmd); } } if (!isHost && !isMod) { if (cmd === "menu") { bot.tipmenu.show(); } } if (isHost) { if (cmd === "menucolor") { menuColor = bot.msg.setColor(args[0]); bot.tipmenu.show(user); } if (cmd === "menu") { bot.tipmenu.show(); } if (cmd === "mode") { listMenu = !listMenu; bot.tipmenu.show(user); } if (cmd === "cc") { bot.clearChat(); } } } if (msg.c === "#494949" && msg.f === "default" && !bot.check(user, "basic")) { if (isBlank(bot.check(user, "color"))) { bot.update(user, "color", bot.msg.getRandomColor()); } if (isBlank(bot.check(user, "font"))) { bot.update(user, "font", bot.msg.getRandomFont()); } msg.c = bot.check(user, "color"); msg.f = bot.check(user, "font"); } if (isKing) { msg.m = crown + msg.m; } if (showTotal && !bot.check(user, "privacy")) { var amount = bot.check(user, "total"); if (amount > 0) { msg.m = "|" + amount + "| " + msg.m; } } return msg; }); //if(!testing) setup(); //function showHelp(user) { // var mod = bot.check(user, "mod"); // var help = "Commands:"; // if (user !== cb.room_slug && !mod) { // help += "\n" + "/menu -- Display the tip menu"; // } // if (user === cb.room_slug || mod) { // help += "\n" + "/menu -- send the tip menu to everyone in the room"; // help += "\n" + "/pause -- pause or unpause the tip menu"; // } // if (user === cb.room_slug) { // help += "\n" + "/mode -- switch between Single and Multi line modes"; // help += "\n" + "/menucolor [name|code] -- change the menu color. E.g. '/menucolor blue' or '/menucolor 0000ff'"; // help += "\n" + "/cc -- clear the chat messages"; // } // help += "\n" + "/color -- get a new random color"; // help += "\n" + "/font -- get a new random font"; // help += "\n" + "/[name of color] -- choose a specific color. E.g. /blue"; // help += "\n" + "/basic -- revert color and font back to their default values"; // help += "\n" + "/list -- view a list of available colors"; // help += "\n" + "/privacy -- toggle total tips display on or off"; // help += "\n" + "/help -- display this help message"; // cb.sendNotice(help, user, "", "#252525"); //} function setup() { // menuColor = colors[cb.settings.menu_color]; // lbColor = analogous(menuColor); // var x = lbColor.match(/[a-f0-9]{6}/gi).join(''); // setTimeout(function(){ // var y = bot.hex.lighten(x); // console.log(y) // }, 10000); // listMenu = cb.settings.menu_mode === "Multi line"; showTotal = cb.settings.show_amount === "Yes"; leaderboard = cb.settings.leaderboard === "Yes"; max = cb.settings.leaderboard_length; lbt = cb.settings.leaderboard_timer * 60000; bot.tipmenu.setup(); bot.tipmenu.show(); } function hasProp(obj,key){return obj.hasOwnProperty(key);} function inRoom(user) {return user in room;} function isBlank(str) {return str === undefined || str === null || str === "";} function isHex(str) {return /#?[a-f0-9]{6}$/gi.test(str);} function echo(a, b, c, d, e) {cb.sendNotice(a, b, c, d, e);} //function analogous(color){ // var obj = {}; // var keys = Object.keys(colors); // for(var c in colors){ // if (colors[c] === color){ // var i = keys.indexOf(c); // var j = i + 1; // var k = i - 1; // if(j === keys.length) j = 0; // if(k === -1) k = keys.length - 1 // var main = colors[keys[i]]; // var light1 = colors[keys[j]]; // var light2 = colors[keys[k]]; // obj.center = main; // obj.right = light1; // obj.left = light2; // return obj; // //break // //console.log(main, light1, light2); // } // // } //} //function lighten(str){ // var tmp = str // var contrast = bot.hex.contrast(str) // var i = 1; // var color = bot.hex.tint(str, i); // while(contrast === '#ffffff'){ // contrast = bot.hex.contrast(color); // // echo(contrast) // color = bot.hex.addHash(bot.hex.tint(tmp, i)) // i+=1 // } // return color; //} // // //function darken(str){ // var tmp = str // var contrast = bot.hex.contrast(str); // var i = 0; // var color = bot.hex.shade(str, i); // while(contrast === '#000000'){ // contrast = bot.hex.contrast(color); // color = bot.hex.addHash(bot.hex.shade(tmp, i)) // i+=1 // } // return color; //} // // var x = room.colors.darken(main); // var y = room.colors.darken(light1); // var z = room.colors.darken(light2); // console.log(x, y, z)
© Copyright Chaturbate 2011- 2024. All Rights Reserved.