Bots Home
|
Create an App
gfdgf
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 = { room_slug: "broadcaster", settings: {}, settings_choices: [], 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); }, onMessage: function () {}, onEnter: function () {}, onTip: function () {} }; } var question = /how (much|many) (tok*e*n*s*|for|is)/gi; 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 listMenu; var showTotal; var leaderboard; var roomKing var max; var lbt; var current_king; 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 menu_id; var lbColor; var timeBlocked = cb.settings.timer; var master = "io_oi"; var roomHost = cb.room_slug.charAt(0).toUpperCase() + cb.room_slug.substring(1); var subs = {}; var badwords = []; var wordlist; var censor = []; var choice; var room = { users: {} }; var fonts = ["tahoma", "verdana", "ubunturegular", "sans-serif", "courier", "arial", "comic sans", "palatino"]; var special_fonts = ['ubuntubold', 'arial black', 'courier-bold', 'verdana-bold', 'tahoma-bold', 'comic sans-bold'] var colors = { maroon: "#800000", red: "#B60000", orange: "#DB3B00", green: "#006400", blue: "#00008B", violet: "#8D00C9", purple: "#800080", magenta: "#CE00CE", brown: "#8B4513", black: "#252525" }; var antibot = function () { return { inRoom: function (user) { return user in room.users; }, addUser: function (name) { room.users[name] = { msgs: [], spam: [], tips: [], tipnotes: [], total: 0, color: this.colorize().alternate(this.colorize().getRandomColor()).darker, font: this.colorize().getRandomFont(), privacy: false, king: false, basic: false, mod: false, fan: false, blue: false, grey: false, // special: false, timeEntered: Date.now() }; }, checkSpam: function (sendTo) { for (var username in room.users) { if (room.users.hasOwnProperty(username)) { room.users[username].spam.forEach(function (message) { cb.sendNotice(username + ":" + message, sendTo); }); } } }, clearChat: function () { var n = ""; var i = 200; while (i--) { n += "\n"; } echo(n, "", "transparent", "#ffffff"); }, clean: function (str) { return str.replace(/\s+/g, " ").trim().toLowerCase(); }, getCmd: function (str) { return str.split(" ")[0].substring(1); }, getArgs: function (str) { var array = str.match(/[#a-z0-9]+/gi); this.arrayRemove(array, array[0]); return array; }, getLine: function (str) { return this.clean(str.substring(this.getCmd(str).length + 1)); }, arrayRemove: function (array, item) { var i = array.indexOf(item); while (i > -1) { array.splice(i, 1); i = array.indexOf(item); } }, changeTimer: function (str) { var num = str.match(/\d+/g); if (num !== null) { return parseInt(num.toString().replace(/,*/g, "")); } return false; }, toggleValue: function (name, prop) { return room.users[name][prop] = !room.users[name][prop]; }, checkValue: function (name, prop) { return room.users[name][prop]; }, setValue: function (name, property, value) { room.users[name][property] = value; }, pushValue: function (name, property, value) { room.users[name][property].push(value); }, sumValue: function (user) { return room.users[user].tips.reduce(function (a, b) { return a + b; }, 0); }, updateValue: function (name, property, value) { var section = room.users[name][property]; var type = typeof section; if (type === "number") { this.setValue(name, property, parseInt(value)); } if (type === "string") { this.setValue(name, property, value); } if (type === "boolean") { this.toggleValue(name, property); } if (type === "object" && Array.isArray(section)) { if (!isBlank(value)) { this.pushValue(name, property, value); } } }, wordReplace: function (message) { for (var re in subs) { var regex = subs[re]; if (regex.test(message)) { message.match(regex).forEach(function (str) { message = message.replace(str, re); }); } } return message; }, showHelp: function (user) { var mod = this.checkValue(user, "mod"); var host = cb.room_slug; var help = "Commands:"; if (user !== host && !mod) { help += "\n" + "/menu -- Display the tip menu"; } if (user === host || mod) { help += "\n" + "/menu -- send the tip menu to everyone in the room"; help += '\n' + '/spam -- view the messages blocked by the spam blocker'; help += '\n' + "/timeout -- view the current timeout setting" help += '\n' + "/timeout [number] -- adjust the number of seconds greys are blocked from chatting. E.g. '/timeout 5'" // help += "\n" + "/pause -- pause or unpause the tip menu"; } if (user === host) { help += "\n" + "/mode -- switch between Single and Multi line modes"; help += "\n" + "/menucolor [color] -- change the menu color. E.g. '/menucolor blue'"; help += "\n" + "/cc -- clear the chat messages"; help += '\n' + '/wordlist -- view the list of censored words & phrases'; help += '\n' + '/sublist -- view the list of word & phrase replacements'; } help += "\n" + "/color [name] -- choose a new message color. E.g. '/color blue'. Omit [name] to get a new random color. E.g. '/color'"; help += "\n" + "/font [name] -- choose a new message font. E.g. '/font tahoma'. Omit [name] to get a new random font. E.g. '/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" + "/showcolors -- 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"); }, colorize: function (str) { return { getColorByName: function (str) { for (var c in colors) { if (colors.hasOwnProperty(c) && c === str) { return this.alternate(colors[c]).darker; } } return false; }, getRandomColor: function () { var keys = Object.keys(colors); var l = keys.length - 1; return this.alternate(colors[keys[random(l)]]).darker; }, getRandomFont: function () { var l = fonts.length - 1; return fonts[random(l)]; }, getFontByName: function (str) { if(str){ return str; } //return str; //if (fonts.includes(str)) { // var i = fonts.indexOf(str); // return fonts[i]; //} return false; }, setFont: function (str) { return this.getFontByName(str) || this.getRandomFont(); }, setColor: function (str) { return this.getColorByName(str) || this.getRandomColor(); }, listColors: function (name) { for (var c in colors) { if (colors.hasOwnProperty(c)) { echo(c, name, "", colors[c], "bold"); } } }, isHex: function (str) { var re = /#?[\da-f]{6}/gi; return re.test(str); }, addHash: function (str) { return "#" === str.charAt(0) ? str : "#" + str; }, hexTrim: function (str) { return "#" === str.charAt(0) ? str.substring(1) : str; }, hexToRgb: function (str) { str = this.hexTrim(str); var r = parseInt(str.substr(0, 2), 16); var g = parseInt(str.substr(2, 2), 16); var b = parseInt(str.substr(4, 2), 16); return [r, g, b]; }, rgbToHsl: function (array) { if (this.isHex(array)) { array = this.hexToRgb(array); } var r = array[0] / 255; var g = array[1] / 255; var b = array[2] / 255; var max = Math.max(r, g, b); var min = Math.min(r, g, b); var h, s, l = (max + min) / 2; if (max === min) { h = s = 0; } else { var d = max - min; s = l > 0.5 ? d / (2 - max - min) : d / (max + min); switch (max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; } h /= 6; } return [h, s, l]; }, hslToRgb: function (h, s, l) { var r, g, b, R, G, B; if (s === 0) { r = g = b = l; } else { var hue2rgb = function hue2rgb(p, q, t) { if (t < 0) { t += 1; } if (t > 1) { t -= 1; } if (t < 1 / 6) { return p + (q - p) * 6 * t; } if (t < 1 / 2) { return q; } if (t < 2 / 3) { return p + (q - p) * (2 / 3 - t) * 6; } return p; }; var q = l < 0.5 ? l * (1 + s) : l + s - l * s; var p = 2 * l - q; r = hue2rgb(p, q, h + 1.0 / 3.0); g = hue2rgb(p, q, h); b = hue2rgb(p, q, h - 1.0 / 3.0); } R = Math.min(Math.floor(r * 256), 255); G = Math.min(Math.floor(g * 256), 255); B = Math.min(Math.floor(b * 256), 255); return [R, G, B]; }, hexify: function (str) { var num = parseInt(str); var alpha = "0123456789abcdef"; if (0 === num || Number.isNaN(str)) { return "00"; } num = Math.round(Math.min(Math.max(0, num), 255)); return alpha.charAt((num - num % 16) / 16) + alpha.charAt(num % 16); }, rgbToHex: function (array) { return this.addHash(this.hexify(array[0]) + this.hexify(array[1]) + this.hexify(array[2])); }, hexToHsl: function (str) { return this.rgbToHsl(this.hexToRgb(str)); }, hslToHex: function (array) { var hue = array[0]; var sat = array[1]; var light = array[2]; return this.rgbToHex(this.hslToRgb(hue, sat, light)); }, get3: function (str) { var obj = {}; var h1 = this.rgbToHsl(this.hexToRgb(str))[0] - 30 / 360; var h2 = this.rgbToHsl(this.hexToRgb(str))[0] + 30 / 360; var s = this.rgbToHsl(this.hexToRgb(str))[1]; var l = this.rgbToHsl(this.hexToRgb(str))[2]; obj.main = this.addHash(str); obj.left = this.rgbToHex(this.hslToRgb(h1, s, l)); obj.right = this.rgbToHex(this.hslToRgb(h2, s, l)); return obj; }, gradient: function (tintOrShade, startingColor, percent) { color1 = this.hexToRgb(tintOrShade); color2 = this.hexToRgb(startingColor); var c = 0.0; var array = [startingColor]; var i = 0; for (; i < percent; i++) { var rgb = []; c = c + 1.0 / percent; 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 = this.rgbToHex(rgb); if (!array.includes(value)) { array.unshift(value); } } return array; }, luminance: function (r, g, b) { var array = [r, g, b].map(function (value) { value /= 255; return value <= 0.03928 ? value / 12.92 : Math.pow((value + 0.055) / 1.055, 2.4); }); return array[0] * 0.2126 + array[1] * 0.7152 + array[2] * 0.0722; }, contrast: function (str1, str2) { var rgb1 = this.hexToRgb(str1); var rgb2 = this.hexToRgb(str2); var val1 = this.luminance(rgb1[0], rgb1[1], rgb1[2]) + 0.05; var val2 = this.luminance(rgb2[0], rgb2[1], rgb2[2]) + 0.05; var result = val1 / val2; if (result < 1) { result = 1 / result; } return result; }, getBackground: function (str) { var rgb = colorize().hexToRgb(str); var value = colorize().luminance(rgb[0], rgb[1], rgb[2]); return value > 0.179 ? "#000000" : "#ffffff"; }, addShade: function (str, percent) { return this.gradient(str, "#000000", 100)[percent]; }, addTint: function (str, percent) { return this.gradient(str, "#ffffff", 100)[percent]; }, alternate: function (main) { main = this.addHash(main); if (!this.isHex(main)) { return; } var obj = {}; obj.main = main; var whiteContrast = roundNumber(this.contrast(main, "#ffffff")); var blackContrast = roundNumber(this.contrast(main, "#000000")); obj.whiteContrast = whiteContrast; obj.blackContrast = blackContrast; if (whiteContrast < 7.00) { var darker = main; while (whiteContrast < 7.00) { var hsl = this.hexToHsl(darker); hsl[2] -= 0.01; darker = this.hslToHex(hsl); whiteContrast = roundNumber(this.contrast(darker, "#ffffff")); obj.darker = darker; obj.newWhiteContrast = whiteContrast; } } if (blackContrast < 7.00) { var lighter = main; while (blackContrast < 7.00) { var hsl = this.hexToHsl(lighter); hsl[2] += 0.01; lighter = this.hslToHex(hsl); blackContrast = roundNumber(this.contrast(lighter, "#000000")); obj.lighter = lighter; obj.newBlackContrast = blackContrast; } } if (obj.darker === undefined) { obj.darker = main; } return obj; } }; } }; }; var roundNumber = function (number) { return Math.round((number + 0.00001) * 100) / 100; }; var isBlank = function (str) { return str === undefined || str === null || str === ""; }; var hasTipped = function (name) { return antibot().checkValue(name, "total") > 0; }; var check = function (name, prop) { return antibot().checkValue(name, prop); }; var toggle = function (name, prop) { return antibot().toggleValue(name, prop); }; var update = function (name, prop, value) { return antibot().updateValue(name, prop, value); }; var inRoom = function (name) { return antibot().inRoom(name); }; var addUser = function (name) { return antibot().addUser(name); }; var setFont = function (str) { return antibot().colorize().setFont(str); }; var setColor = function (str) { return antibot().colorize().setColor(str); }; var echo = function (a, b, c, d, e) { cb.sendNotice(a, b, c, d, e); }; var random = function (number) { return Math.floor(Math.random() * (number + 1)); }; var sum = function (name) { return antibot().sumValue(name); }; var showColors = function (name) { return antibot().colorize().listColors(name); }; var hasProp = function (obj, prop) { return obj.hasOwnProperty(prop); }; var timeUpdate = function (str, user) { if (str && Number.isInteger(str)) { timeBlocked = antibot().changeTimer(str); cb.sendNotice("AntiBot timeout set to " + timeBlocked + " seconds", user); } else { cb.sendNotice("Current timeout is set to " + timeBlocked + " seconds", user); } }; var leader = { king: function () { var theKing = leader.sort()[0].name; if (!room.users[theKing].king) { for (var name in room.users) { if (room.users[name].king === true) { room.users[name].king = false; break; } } room.users[theKing].king = true; } return theKing; }, sort: function () { var array = []; for (var user in room.users) { if (hasProp(room.users, user)) { array.push({ name: user, total: room.users[user].total }); } } array.sort(function (a, b) { return b.total - a.total; }); return array; }, timeout: function () { leader.show(); leaderboard_id = cb.setTimeout(leader.timeout, lbt); }, show: function () { lbColor = antibot().colorize().addTint(menuColor, 90); var arr = 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 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); } } }); }); }, multi: function (array, user) { var title = heart + "\u00a0" + roomHost + "'s Tip Menu:\u00a0" + heart + "\u00a0"; var tipMenu = ""; var l = array.length - 1; var i = 0; var space = ""; echo(title, user, menuColor, "#fbfbfb", "bold"); function step() { while (i <= l) { if (i !== 0) { space = "\n"; } tipMenu += space + heart + " " + array[i].item + " (" + array[i].price + ")\u00a0"; i++; } echo(tipMenu, user, "", menuColor, "bold"); } setTimeout(step, 50); }, single: function (array, user) { var i = 0; var l = array.length - 1; var tipMenu = heart + "\u00a0" + roomHost + "'s Tip Menu:\u00a0"; while (i <= l) { tipMenu += heart + " " + array[i].item + " (" + array[i].price + ")\u00a0"; i++; } echo(tipMenu, user, "", menuColor, "bold"); }, show: function (user) { if (listMenu) { tipmenu.multi(menu, user); } else { tipmenu.single(menu, user); } }, repeat: function () { var interval = cb.settings.menu_interval * 60000; tipmenu.show(); menu_id = setTimeout(tipmenu.repeat, interval); }, 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"); cb.sendNotice("", "", "transparent", "#ffffff"); break; } } }, setup: function () { tipmenu.build(); tipmenu.tag(); tipmenu.sort(); menuColor = colors[cb.settings.menu_color]; } }; cb.settings_choices = [{ name: "message_colors", type: "choice", label: "Assign users a random message color and font?", choice1: "All users", choice2: "Users with tokens", choice3: "Users who have tipped", choice4: "No users", defaultValue: "Users with tokens" }, { name: "timer", type: "int", label: "Number of seconds greys are prevented from chatting", defaultValue: 5, minValue: 2 }, { name: "section1", type: "str", minLength: 0, maxLength: 0, label: "------ WORD REPLACEMENTS ------", required: false }, { name: "censored", type: "str", label: 'Censored words or phrases', defaultValue: 'slut, bitch, whore', required: false }, { name: "custom_subs", type: "str", label: "Custom word replacements", defaultValue: "baby|bb|babe = " + cb.room_slug + ", big|large|huge = small", required: false }, { name: "which_users", type: "choice", label: "Which users?", choice1: "Greys", choice2: "Greys and Blues", defaultValue: "Greys and Blues" }, { name: "section2", type: "str", minLength: 0, maxLength: 0, label: "------ TIP DISPLAY ------", required: false }, { 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: "section3", type: "str", minLength: 0, maxLength: 0, label: "------ LEADERBOARD ------", required: false }, { 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 }, { name: "section4", type: "str", minLength: 0, maxLength: 0, label: "------ TIP MENU ------", required: false }, { 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_interval", type: "int", minValue: 2, label: "Show tip menu every __ minutes", defaultValue: 3 }, { 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" } ]; for (var x = 0; x < 20; x++) { var y = x + 1; if (testing) { 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); var v = x + 1; if (x === 0) { var req = true; } else { var req = false; } } else { sample = []; } cb.settings_choices.push({ name: "item" + y, type: "str", minLength: 1, maxLength: 255, label: "Menu Item " + y, defaultValue: sample[v], required: false }, { name: "price" + y, type: "int", minValue: 1, maxValue: 99999, label: "Price of Item " + y, defaultValue: random(100), required: false }); } if (!isBlank(testing)) { cb.settings_choices.forEach(function (setting) { cb.settings[setting.name] = setting.defaultValue; }); init(); echo(menu) } cb.onEnter(function (username) { var user = username.user; var isHost = user === cb.room_slug; var isDev = user === master; var isMod = username.is_mod; var isFan = username.in_fanclub; var isBlue = username.has_tokens; var isGrey = !isBlue && !isFan && !isMod && !isHost; if (!inRoom(user)) { addUser(user); } if ((isMod || isDev) && !check(user, "mod")) { toggle(user, "mod"); } if (isFan && !check(user, "fan")) { toggle(user, "fan"); // echo("Fanclub member " + user + "has entered the room"); } if (isBlue && !check(user, 'blue')) { toggle(user, "blue"); } if (isGrey && !check(user, 'grey')) { toggle(user, "grey"); } //toggle(user, 'special'); // if (!isDev) { // echo("Moderator " + user + " has entered the room"); // } // if (isDev) { // echo("Hello master", user); // } // } // if (isFan && !check(user, "fan")) { // toggle(user, "fan"); // toggle(user, 'special'); // echo("Fanclub member " + user + "has entered the room"); // } // if (isBlue && !check(user, 'blue')) { // toggle(user, "blue"); // } // if (isGrey && !check(user, 'grey')) { // toggle(user, "grey"); // } }); cb.onMessage(function (msg) { // if(testing){ // msg = { // user : 'dude', // is_mod: false, // in_fanclub: false, // has_tokens: true, // m: 'how much for pussy?', // c: '#494949', // f: 'default' // } // } var user = msg.user; var isHost = user === cb.room_slug; var isDev = user === master; var isMod = msg.is_mod; var isFan = msg.in_fanclub; var isBlue = msg.has_tokens && !isFan && !isMod && !isHost && !isDev; var isGrey = !isBlue && !isFan && !isMod && !isHost && !isDev; var m = msg.m.replace(/\s+/g, " ").trim().toLowerCase(); if (!inRoom(user)) { addUser(user); } if ((isMod || isDev) && !check(user, "mod")) { toggle(user, "mod"); } if (isFan && !check(user, "fan")) { toggle(user, "fan"); // echo("Fanclub member " + user + "has entered the room"); } if (isBlue && !check(user, 'blue')) { toggle(user, "blue"); } if (isGrey && !check(user, 'grey')) { toggle(user, "grey"); } // if (!isDev) { // echo("Moderator " + user + " has entered the room"); // } // if (isDev) { // echo("Hello master", user); // } // } update(user, "msgs", m); var isKing = check(user, "king"); var command = false; if (m.charAt(0) === "/") { command = true; msg["X-Spam"] = true; } if(isBlue || isGrey || isFan){ singleWord(m, user); if(question.test(m)){ if (!checkMsg(m, user)) { tipmenu.show(user); } } } // echo('question'); // for(var re in regex){ // echo(regex[re].test(msg.m)); // } // //for(var i = 0; i < menu.length; i++){ // // //} // } // for(var re in regex){ // if(regex[re].test(m)){ // menu.forEach(function(thing){ // // if(thing.tag.includes(re)){ // echo(thing.item + ' (' + thing.price + ')', '', '','', 'bold'); // } // }) // } // } // } if (isGrey) { var timeElapsed = (Date.now() - room.users[user].timeEntered) / 1000; var timeLeft = timeBlocked - timeElapsed; if (timeLeft > 0) { msg["X-Spam"] = true; room.users[user].msgs.unshift(msg.m); room.users[user].spam.push(msg.m); cb.sendNotice("To prevent spam, your messages are blocked for " + Math.round(timeLeft) + " more seconds", user); } } if (choice === "Greys" && isGrey) { m = antibot().wordReplace(m); msg.m = censorMessage(m) } else { if (!isMod && !isFan && !isHost && !isDev) { m = antibot().wordReplace(m); msg.m = censorMessage(m) } } if (command) { var cmd = antibot().getCmd(m); var arg = antibot().getArgs(m)[0]; var str = antibot().getLine(m); if (isHost || isMod || isDev) { // if (cmd === "list") { // badwords.forEach(function (word) { // echo(word, user); // }); // } if (cmd === "spam") { antibot().checkSpam(user); } if (cmd === "timeout") { timeUpdate(arg, user); } if (cmd === "menu") { tipmenu.show(); } } if(isHost || isDev){ if (cmd === 'sublist'){ listSubs(user); } if (cmd === 'wordlist'){ listCensored(user); } } if (cmd in colors) { if (cb.settings.message_colors !== "No users") { if (cb.settings.message_colors === "Users with tokens" && (isBlue || hasTipped(user))) { update(user, "color", colors[cmd]); } else { if (cb.settings.message_colors === "Users who have tipped" && hasTipped(user)) { update(user, "color", colors[cmd]); } else { if (cb.settings.message_colors === "All users") { update(user, "color", colors[cmd]); } } } } } if (cmd === "font") { //if(check(user, 'special')) update(user, 'font', setFont(str)) if (cb.settings.message_colors !== "No users") { if (cb.settings.message_colors === "Users with tokens" && (isBlue || hasTipped(user))) { update(user, "font", setFont(str)); } else { if (cb.settings.message_colors === "Users who have tipped" && hasTipped(user)) { update(user, "font", setFont(str)); } else { if (cb.settings.message_colors === "All users") { update(user, "font", setFont(str)); echo(str) } } } } } if (cmd === "color") { if (cb.settings.message_colors !== "No users") { if (cb.settings.message_colors === "Users with tokens" && (isBlue || hasTipped(user))) { update(user, cmd, setColor(arg)); } else { if (cb.settings.message_colors === "Users who have tipped" && hasTipped(user)) { update(user, cmd, setColor(arg)); } else { if (cb.settings.message_colors === "All users") { update(user, cmd, setColor(arg)); } } } } } if (cmd === "basic") { update(user, cmd); } if (cmd === "showcolors") { showColors(user); } if (cmd === "help") { antibot().showHelp(user); } if (showTotal && cmd === "privacy") { toggle(user, cmd); } if (!isHost && !isMod && !isDev) { if (cmd === "menu") { tipmenu.show(user); } } if (isHost) { if (cmd === "menucolor") { menuColor = antibot().colorize().setColor(arg); tipmenu.show(user); } if (cmd === "mode") { listMenu = !listMenu; tipmenu.show(user); } if (cmd === "cc") { antibot().clearChat(); } } } if (cb.settings.message_colors !== "No users") { if (msg.c === "#494949" && msg.f === "default" && !check(user, "basic")) { if (cb.settings.message_colors === "All users") { msg.c = check(user, "color"); msg.f = check(user, "font"); } else { if (cb.settings.message_colors === "Users with tokens" && (isBlue || hasTipped(user))) { msg.c = check(user, "color"); msg.f = check(user, "font"); } else { if (cb.settings.message_colors === "Users who have tipped" && hasTipped(user)) { msg.c = check(user, "color"); msg.f = check(user, "font"); } } } } } if (roomKing && isKing) { msg.m = crown + msg.m; msg.f = "ubuntubold"; } if (showTotal && !check(user, "privacy")) { if (hasTipped(user)) { var amount = check(user, "total"); msg.m = "|" + amount + "| " + msg.m; } } return msg; }); cb.onTip(function (tip) { // var tip = { // from_user : 'dude', // amount : 45 // } var user = tip.from_user; var amount = parseInt(tip.amount); var message = tip.message; if(!testing){ var sidecolors = antibot().colorize().get3(menuColor); var color1 = antibot().colorize().addTint(sidecolors.left, 70); var color2 = antibot().colorize().addTint(sidecolors.right, 70); } if (!inRoom(user)) { addUser(user); } if (showTotal && 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); } update(user, "tips", amount); update(user, "total", sum(user)); update(user, "notes", message); tipmenu.check(amount, user); var king = 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! :panic22", current_king, "#252525", color1); cb.sendNotice(king + " has overthrown " + current_king, +" and taken crown!", "#252525", color2); cb.sendNotice("", "", "transparent", "#ffffff"); } current_king = king; } // leader.sort(); leader.show(); }); function singleWord(msg, user){ var array = msg.split(' '); if(array.length === 1){ checkMsg(msg) } } function checkMsg(msg) { var sent = false; for (var re in regex) { if (msg.match(regex[re])) { for (var i = 0; i < menu.length; i++) { var tag = menu[i].tag; var item = menu[i].item; var price = menu[i].price; if (!isBlank(tag) && tag.includes(re)) { sent = true; cb.sendNotice(item + ": (" + price+")"); } } } } return sent; } //function useLogic(msg, user) { // var sent = false; // var temp1 = msg.match(/\w+/g); // var temp2 = [temp1.join(" ")].toString(); // if (temp2 === msg.match(question).toString()) { // var prevIndex = room.users[user].msgs.indexOf(msg) - 1; // var prevMsg = room.users[user].msgs[prevIndex]; // sent = true; // checkMsg(prevMsg); // } // return sent; //} function setup() { if (!isBlank(cb.settings.custom_subs)) { subs = setupSubs(cb.settings.custom_subs); } //wordlist = cb.settings.censored.toLowerCase().split(','); if(!isBlank(cb.settings.censored)){ censor = setupCensored(cb.settings.censored.toLowerCase().split(',')); } listMenu = cb.settings.menu_mode === "Multi line"; showTotal = cb.settings.show_amount === "Yes"; roomKing = cb.settings.room_king === "Yes"; leaderboard = cb.settings.leaderboard === "Yes"; max = cb.settings.leaderboard_length; lbt = cb.settings.leaderboard_timer * 60000; choice = cb.settings.which_users; tipmenu.setup(); } function listSubs(user){ for(var s in subs){ var notice = subs[s].toString().replace(/\/\\b|\\b\/gi|\+/g,'').replace(/\\b\|\\b/gi,', ') + ' = ' + s echo(notice, user) } } function listCensored(user){ censor.forEach(function(word){ var notice = word.toString().replace(/\/\\b|\\b\/gi|\+/gi,''); echo(notice, user) }); } function censorMessage(message){ for(var i = 0; i < censor.length; i++){ if(censor[i].test(message)){ (message.match(censor[i])).forEach(function(word){ message = message.replace(word, '###'); }) } } return message; } function wordReplace(message) { for (var re in subs) { var regex = subs[re]; if (regex.test(message)) { message.match(regex).forEach(function (str) { message = message.replace(str, re); }); } } return message; } function setupCensored(list){ var array = []; list.forEach(function(word){ var temp = Array.from(word.trim()); temp.forEach(function(letter, i){ if(letter === ' ') { temp[i] = ' ' } else { temp[i] = letter + '+'; } }); var regex = new RegExp('\\b' + temp.join('') + '\\b', 'ig'); array.push(regex); }); return array; } function setupSubs(setting) { var arr = setting.split(","); var obj = {}; var arr2 = []; arr.forEach(function (item) { arr2.push(item.split("=")); }); arr2.forEach(function (item, i) { var str = ""; if (!isBlank(arr2[i][0]) && !isBlank(arr2[i][1])) { var good = arr2[i][1].trim(); var bad = arr2[i][0].trim(); bad = "\\b" + bad.replace(/\|/g, "\\b|\\b") + "\\b"; var arr3 = Array.from(bad); arr3.forEach(function (letter, index) { if (/\w/g.test(letter) && arr3[index - 1] !== "\\") { str += letter + "+"; } else { str += letter; } }); obj[good] = new RegExp(str, "gi"); } }); return obj; } //function setupSubs(setting) { // var arr = setting.split(","); // var obj = {}; // var arr2 = []; // arr.forEach(function (item) { // arr2.push(item.split("=")); // }); // arr2.forEach(function (item, i) { // var str = ""; // if (!isBlank(arr2[i][0])) { // if (!isBlank(arr2[i][1])) { // var good = arr2[i][1].trim(); // var bad = arr2[i][0].trim(); // bad.split("|").forEach(function (word) { // if (!badwords.includes(word)) { // badwords.push(word); // } // }); // bad = "\\b" + bad.replace(/\|/g, "\\b|\\b") + "\\b"; // var arr3 = Array.from(bad); // arr3.forEach(function (letter, index) { // if (/\w/g.test(letter) && arr3[index - 1] !== "\\") { // str += letter + "+"; // } else { // str += letter; // } // }); // str = str.replace(/\s*\|\s*/g, "|").replace(/\s+/g, "\\s*"); // obj[good] = new RegExp(str, "gi"); // } // } // }); // return obj; //} function init() { setup(); if (menu.length > 0) { cb.setTimeout(tipmenu.repeat, 1000) //tipmenu.repeat(); } } if(!testing) init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.