Bots Home
|
Create an App
yhyh
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: {}, 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); }, onMessage: function() {}, onEnter: function() {}, }; } function addUser(user){ room.users[user] = { msgs: [], tips: [], notes: [], total: 0, isMod: false, isFan: false, isBlue: false, isGrey: false, isMute: false } } var room = { users : {}, list : {blue : [], grey : [], secret : []}, greys : {chat : false, gifs : false}, } var greyList = room.list.grey; var greyTitle = 'Grey word list'; var blueList = room.list.blue; var blueTitle = 'General word list'; var secretList = room.list.secret; var secretTitle = 'Private word list'; var blocked = []; var allowed = []; var replacelist = []; var greySpam; var greyChat; var greyGifs; var modPower; var swapWord; var replaceWords; var hideMessages; var messages = {}; var subs = {}; var reps = []; cb.settings_choices = [{ name: "greychat", type: "choice", choice1: "Yes", choice2: "No", defaultValue: "Yes", label: "Allow grey members to chat?" }, { name: "greygifs", type: "choice", choice1: "Yes", choice2: "No", defaultValue: "No", label: "Allow grey members to post images?" }, { name: "greyspam", type: "choice", choice1: "Yes", choice2: "No", defaultValue: "Yes", label: "Block spam bots? (Please, turn this on if you allow greys to chat)" }, { name: "greywords", type: "str", defaultValue: "pussy, baby, where do you live, daddy, cock", label: "Grey words & phrases -- List any words or phrases (separated by commas) that Grey members are not allowed to say [Optional]", required: false }, { name: "bluewords", type: "str", defaultValue: "slut, bitch, cunt, whore", label: "Public words & phrases -- List any words or phrases (separated by commas) that Blue and Grey members are not allowed to say [Optional]", required: false }, { name: "privatewords", type: "str", defaultValue: "", label: "Private words & phrases -- List any words or phrases (separated by commas) that NOBODY is allowed to say. This includes FANCLUB and MODERATORS [Optional]", required: false }, { name: "hide_or_replace", type: "choice", choice1: "Hide", choice2: "Replace", defaultValue: "Replace", label: "Hide the entire message from chat or Replace the offending words with something else (Note: If a message contains words/phrases from your Private list, the message will not appear in chat regardless of this setting)" }, { name: "general_replacement", type: "str", defaultValue: ":smile,____,<censored>,[sorry],...,[deleted]", label: "Replacements for words & phrases on the grey and blue lists. (Note: if you leave this blank, offending messages will be hidden instead of words being replaced) [Optional]", required: false }, { name: "replacements", type: "str", defaultValue: "ugly|beautiful, mmm|i'm a cow, m|#, hard|flacid, dumb|smart", label: "To replace specific words or phrases with something else, list them here (separated by commas) like this: ORIGINAL|REPLACEMENT, ORIGINAL PHRASE|REPLACEMENT PHRASE, ... [Optional]", required: false }, { name: "which_users", type: "choice", choice1: "Grey members", choice2: "Grey and Blue members", defaultValue: "Grey and Blue members", label: "Which members will have words replaced? (Note: this setting only matters if you chose Replace. If you chose Hide, this setting has no effect)" }, { name: "modpower", type: "choice", choice1: "Yes", choice2: "No", defaultValue: "Yes", label: "Allow moderators to use commands? (Note: Moderators are never allowed access to your private word list)" } ]; if (testing) { cb.settings_choices.forEach(function(setting) { cb.settings[setting.name] = setting.defaultValue; }); } //Start(); //echo(cb.settings); function echo(a, b, c, d, e) { cb.sendNotice(a, b, c, d, e); } cb.onMessage(function(msg) { if(testing){ msg = { user:'somedude', has_tokens:true, is_mod:false, in_fanclub:false, gender:'m', m:'mmmmm hey there you dumbass ugly slut. you wanna see my hard cock?' } } var user = msg.user; var gender = msg.gender; var m = msg.m.replace(/\s+/g, " ").trim(); var isHost = user == cb.room_slug; var isFan = msg.in_fanclub; var isBlue = msg.has_tokens; var isGrey = !isBlue; var command = false; var isMod = false; var cmd, arg; var notice; var words; storeValue(messages, user, msg.m); if (msg.is_mod && modPower) isMod = true; if (m.charAt(0) === "/") command = true; if (command) { isSpam(msg); if (isHost || isMod) { cmd = getCmd(m); arg = getArgs(m); if (cmd === "help") displayHelp(user); if (cmd === "cc") clearChat(); if (cmd === "notice") sendNotice(msg.m) if (cmd === "addgrey") addtoGrey(m, user); if (cmd === "addblue") addtoBlue(m, user); if (cmd === "delgrey") delGrey(m, user); if (cmd === "delblue") delBlue(m, user); if (cmd === "replace") addtoSubs(m, user); if (cmd === "sublist") listSubs(user); if (cmd === "greychat") { greyChat = !greyChat; notice = "Grey chat is now: " + (greyChat ? "On" : "Off"); cb.sendNotice(notice, user, "", "", "bold"); if (isMod) { cb.sendNotice(notice, cb.room_slug, "", "", "bold"); } } if (cmd === "greygifs") { greyGifs = !greyGifs; notice = "Grey gifs are: " + (greyGifs ? "Allowed" : "Not allowed"); cb.sendNotice(notice, user, "", "", "bold"); if (isMod) { cb.sendNotice(notice, cb.room_slug, "", "", "bold"); } } if (cmd === "greylist") { displayList(greyList, "Grey word list", user); } if (cmd === "list") { displayList(blueList, "General word list", user); } } if (isHost) { if (cmd in messages) { messages[cmd].forEach(function(item) { cb.sendNotice(cmd + ": " + item, user); }); } if (cmd === "modpower") { modPower = !modPower; notice = "Mod access: " + (modPower ? "On" : "Off"); cb.sendNotice(notice, cb.room_slug, "", "", "bold"); } if (cmd === "mylist") { displayList(secretList, "Private word list", cb.room_slug); } } } if (!isHost) { if (hasWords(secretList, m)) { isSpam(msg); } if (!isHost && !isMod && !isFan) { if (isGrey) { if (greyChat) { if (greySpam && gender === "f") { isSpam(msg); } if (!greyGifs && isGraphic(m)) { isSpam(msg); } if (hasWords(greyList, m) || hasWords(blueList, m) || hasWords(reps, m)) { if (hasWords(reps, m)) { m = wordReplace(reps, m); } if (hasWords(greyList, m)) { if (replacelist.length > 0) { m = replaceRandom(greyList, m); } else { isSpam(msg); } } if (hasWords(blueList, m)) { if (replacelist.length > 0) { m = replaceRandom(blueList, m); } else { isSpam(msg); } } msg.m = m; } } } if (isBlue) { if (hasWords(blueList, m) || hasWords(reps, m)) { if (hasWords(reps, m)) { m = wordReplace(reps, m); } if (hasWords(blueList, m)) { if (replacelist.length > 0) { m = replaceRandom(blueList, m); } else { isSpam(msg); } } msg.m = m; } } } } return msg; }); //echo(msg.m) function addtoBlue(str, user){greyList addWordsToList(str, blueList, user); displayList(blueList, blueTitle, user); } function addtoGrey(str, user){ addWordsToList(str, greyList, user); displayList(blueList, greyTitle, user); } function addWordsToList(str, list){ loadSettings(getString(str), list); } function delGrey(str, user){ getArgs(str).forEach(function(item) { arrayRemove(greyList, item); }); displayList(greyList, greyTitle, user); } function delBlue(str, user){ getArgs(str).forEach(function(item) { arrayRemove(blueList, item); }); displayList(blueList, blueTitle, user); } function sendNotice(str){ var notice = getString(str); cb.sendNotice(notice, "", "", "", "bold"); } function addtoSubs(str, user){ loadReplacements(getString(str)); for (var rep in subs) { if (subs.hasOwnProperty(rep)) { cb.sendNotice(rep + "|" + subs[rep], user); } } } function listSubs(user){ for (var custom in subs) { if (subs.hasOwnProperty(custom)) { cb.sendNotice(custom + "|" + subs[custom], user); } } } function displayHelp(user) { var notice = "Command List\n"; notice += "/list -- View the General word list\n"; notice += "/add [words] -- Add words to the General word list\n"; notice += "/del [words] -- Remove words from the General word list\n"; notice += "/greylist -- View the Grey word list\n"; notice += "/addgrey [words] -- Add words to the Grey word list\n"; notice += "/delgrey [words] -- Remove words from the Grey word list\n"; notice += "/replace [OLD|NEW] -- add new word replacements. Example: /replace big|small, will you marry me|lets just be friends, up|down"; notice += "/custom -- Display a list of all the [OLD|NEW] replacements you created"; notice += "/notice [words] -- Display a bold notice in chat\n"; notice += "/cc -- Clear the chat of all messages\n"; notice += "/greychat -- Toggle grey chat on or off\n"; notice += "/greygifs -- Toggle grey gifs on or off\n"; if (cb.room_slug) { notice += "/modpower -- Toggle moderator access to bot commands on or off\n"; notice += "/mylist -- View your Private word list (only you can see it)\n"; notice += "/[username] -- Simply type a / followed by a member's username to view everything that member has written in chat.\n"; notice += "For example: To see all of spiderman's messages you would type /spiderman"; } cb.sendNotice(notice, user); setTimeout(function() { cb.sendNotice("", user, "#FFFFFF", "#FFFFFF"); }, 10); var blah = "When using commands, omit the brackets [ ]. They are meant as a visual aid and nothing else.\n"; blah += "When add or removing multiple items from a list, remember to always separate the items with a comma\n"; blah += "This allows you to specify whole phrases as well as individual words"; setTimeout(function() { cb.sendNotice(blah, user); }, 20); } function storeValue(obj, prop, val) { if (prop in obj) { obj[prop].push(val); } else { obj[prop] = [val]; } } function random(max) { return Math.floor(Math.random() * (Math.floor(max) + 1)); } function getCmd(message) { return message.split(" ")[0].substring(1); } function getArgs(message) { var array = []; var len = getCmd(message).length + 1; var args = message.substring(len).trim(); if (!isEmpty(args)) { args.split(",").forEach(function(item) { array.push(item.trim()); }); } return array; } function getString(message) { return message.substring(getCmd(message).length + 1).trim(); } function clearChat() { var i = 0; var notice = ""; for (; i <= 200; i++) { notice += "\n"; } cb.sendNotice(notice, "", "#FFFFFF", "#FFFFFF"); } function hasWords(array, message) { for (var i in array) { if (array.hasOwnProperty(i)) { var words = array[i]; if (message.includes(words)) { return true; } } } return false; } function isGraphic(message) { var re = new RegExp(/:[a-zA-Z0-9_\-]{2,}/g); return re.test(message); } function isSpam(obj) { obj["X-Spam"] = true; } function isEmpty(setting) { if (setting) { setting = setting.trim(); } if (setting === undefined || setting === null || setting === "") { return true; } else { return false; } } function parseString(str) { str = str.replace(/\s+/g, " "); str = str.replace(/\s*,+\s*/g, ","); str = str.replace(/^,*|,*$/g, ""); str = str.trim().split(","); return str; } function loadSettings(settings, array) { var temp = parseString(settings); var i = 0; for (; i < temp.length; i++) { var word = temp[i].replace(/[!@#$%^&;*)(]+/g, "").trim(); if (word.length > 0 && !array.includes(word)) { array.push(word.toLowerCase()); } } } function loadReplacements(str) { str.split(",").forEach(function(item) { var prop = item.trim().split("|")[0]; var val = item.trim().split("|")[1]; if (!(prop in subs)) { setValue(subs, prop, val); reps.push(prop); } }); } function Start() { greySpam = cb.settings.greyspam == "Yes"; greyChat = cb.settings.greychat == "Yes"; greyGifs = cb.settings.greygifs == "Yes"; modPower = cb.settings.modpower == "Yes"; replaceWords = cb.settings.hide_or_replace == "Replace"; if (!isEmpty(cb.settings.general_replacement)) { loadSettings(cb.settings.general_replacement, replacelist); } if (!isEmpty(cb.settings.greywords)) { loadSettings(cb.settings.greywords, greyList); } if (!isEmpty(cb.settings.bluewords)) { loadSettings(cb.settings.bluewords, blueList); } if (!isEmpty(cb.settings.privatewords)) { loadSettings(cb.settings.privatewords, secretList); } if (!isEmpty(cb.settings.replacements)) { loadReplacements(cb.settings.replacements); } } function arrayRemove(array, item) { var i = array.indexOf(item); while (i > -1) { array.splice(i, 1); i = array.indexOf(item); } } function displayList(array, title, user) { if (user === undefined) { user = ""; } var list = title; for (var i = 0; i < array.length; i++) { list += "\n" + array[i]; } cb.sendNotice(list, user); } function setValue(obj, prop, val) { obj[prop] = val; } function replaceRandom(array, message) { array.forEach(function(word) { while (message.includes(word)) { var nice = replacelist[random(replacelist.length - 1)]; message = message.replace(word, nice); } }); return message; } function wordReplace(array, message) { array.forEach(function(word) { for (word in subs) { if (subs.hasOwnProperty(word)) { while (message.includes(word)) { var nice = subs[word]; message = message.replace(word, nice); } } } }); return message; } Start();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.