Bots Home
|
Create an App
TurbleBot
Author:
turbletest
Description
Source Code
Launch Bot
Current Users
Created by:
Turbletest
/** * author: turblebits */ // all commands should start with "/" const cmdPrefix = "/"; // followed by a command alias. Optionally, this may be // followed by 1 or more spaces, then command args const cmdRegex = /^\/([^ ]+)([ ]*)(.*)/i; var configuration = { beautyWords : ["beautiful", "gorgeous", "so pretty", "wonderful", "so attractive", "my dream girl", "amazing", "the cutest girl I've ever met", "cute af", "the best camgirl", "... wow... I just have no words for your amazingness", "my favorite person in the world :)", "ABSOLUTELY ADORBS", "almost as cool as that turblebits guy", "just a stellar person overall", "babycat's owner! I love her", "super creative", "so funny and entertaining", "my idol", " <3 SO COOL <3"], quiet_list: [], allowed_greys: [], grey_mode: "closed", gods : [cb.room_slug, "turblebits", "bottleboots", "donut_power"], automatic_replies: [{ label: "nipple tattoo question", condition: "n[i|e]+p+.*t[a|o]+t.*[?]", reply: "My nipple tattoos were too fast to hurt much, " + "though some of my larger and more detailed tattoos were painful." },{ label: "turble flattery", condition: "turble.*(great|amazing|awesome|best)+", reply: "yes he certainly is!" },{ label:"spelling of tongue", condition: "tounge", reply: "tongue*" },{ label:"spelling of deepthroat", condition: "deeptroath", reply: "deepthroat*" }], profanity_replacements: [ { naughty: /fuck/gi, nice: "fork" }, { naughty: /shit/gi, nice: "stuff" }, { naughty: /cock/gi, nice: "pinky toe" }, { naughty: /dick/gi, nice: "pinky toe" }, { naughty: /retarded/gi, nice: "impressive" }, { naughty: /cunt/gi, nice: "gentlewoman" }, { naughty: /asshole/gi, nice: "personality" }, { naughty: /butthole/gi, nice: "personality" }, { naughty: /cumming/gi, nice: "sneezing" }, { naughty: /cum/gi, nice: "sneeze" }, { naughty: /pussy/gi, nice: "elbow" }, { naughty: /puss/gi, nice: "elbow" }, { naughty: /foreskin/gi, nice: "weenie sweater" }, { naughty: /anal/gi, nice: "emotional" }, { naughty: /slut/gi, nice: "goddess" }, { naughty: /bitch/gi, nice: "bench" }, { naughty: /whore/gi, nice: "queen" }, { naughty: /trump/gi, nice: "cheetoh" }, { naughty: /tits/gi, nice: "GPA" }, { naughty: /boobs/gi, nice: "GPA" }, { naughty: /nickelback/gi, nice: ["the greatest band ever", "a chorus of angels", "pure awesomeness", "the illustrious chad kroeger", "quarter-less-two-dimes-returned"]} ], passphrase: "blumpkin" }; // 100ms delay before sending notices to ensure the notice appears // *after* the triggering event const delayedNotice = function() { setTimeout(() => { cb.chatNotice(...arguments)}, 100); } //The mapping of aliases to operations is performed during initialization // based on the aliases field of each operation const aliasMap = {}; // set of actual operations that can be performed. Many of these represent // specific chat commands (those with "execute"), but they may also represent // more general CB operations (e.g. ability to chat) const operations = { help : { doc : "Print this help message.", usage: "/help", usableBy: "godsAndMods", aliases: ["h"], argsRegex: null, execute: function(msg) { let helpText = "Turblebot commands available:"; for(var opName in operations) { let operation = operations[opName]; // if(!checkAccess(msg, operation)) { // continue; // } helpText += "\n" + cmdPrefix+opName; let aliases = operation.aliases; if(aliases) { for(var i = 0; i < aliases.length; i++) { helpText += ", " + cmdPrefix + aliases[i]; } } helpText += " : " + operation.doc; if(operation.usage) { helpText += "--"; helpText += "usage: " + operation.usage; } helpText+= " |" + (operation.usableBy === "godsAndMods"? "(Gods and mods)": "(Gods only)"); } delayedNotice(helpText, msg.user); } }, whisper : { doc:"Send a private notice to another user.", usage:"/whisper {user} {message}", usableBy: "godsAndMods", aliases: ["w"], argsRegex: /^([^ ]+) (.*)/i, execute: function(msg, user, message) { let noticeToTarget = "whisper from " + msg.user + ": " + message; let noticeToSender = "You whispered " + user + ": " + message; delayedNotice(noticeToTarget, user); delayedNotice(noticeToSender, msg.user); } }, say : { doc:"Send a notice to all users.", usage:"/say {message}", usableBy: "godsAndMods", aliases: ["s", "shout"], argsRegex: /^(.*)/i, execute: function(msg, message) { delayedNotice(message); } }, quiet: { doc:"Limit a user so all their chat is converted into praise for jas", usage:"/quiet {user}", usableBy: "godsOnly", aliases: ["q"], argsRegex: /^(.*)/i, execute: function(msg, user) { if(user === cb.room_slug) { delayedNotice(msg.user + " just tried to quiet " + cb.room_slug +" -_- ") return; } configuration.quiet_list.push(user); delayedNotice(user + " has been added to the quiet list", msg.user); if(cb.room_slug !== msg.user) { delayedNotice(user + " has been added to the quiet list", cb.room_slug); } } }, loud: { doc:"Un-quiet a user so they may speak freely", usage:"/loud {user}", usableBy: "godsAndMods", aliases: ["l"], argsRegex: /^(.*)/i, execute: function(msg, user) { cbjs.arrayRemove(configuration.quiet_list, user); delayedNotice(user + " has been removed from the quiet list", msg.user); if(cb.room_slug !== msg.user) { delayedNotice(user + " has been removed from the quiet list", cb.room_slug); } } }, quietlist: { doc:"Show a list of users who are currently quieted", usage:"/quietlist", usableBy: "godsAndMods", aliases: ["ql"], argsRegex: null, execute: function(msg) { delayedNotice("quiet list:" + configuration.quiet_list, msg.user); } }, gods: { doc:"Show a list of gods", usage:"/gods", usableBy: "godsAndMods", aliases: ["g"], argsRegex: null, execute: function(msg) { delayedNotice("Gods:" + configuration.gods, msg.user); } }, greymode: { doc:"Set the permitted communication level for greys to open (greys can chat freely), gated (greys must pass a test before chatting), or closed (greys may not chat).", usage:"/greymode {mode}", usableBy: "godsAndMods", aliases: ["gm"], argsRegex: /^(.*)/i, execute: function(msg, mode) { configuration.grey_mode = mode; delayedNotice("Grey chat has been set to " + mode); } }, allowedgreys: { doc:"Show a list of grey users that have been permitted to chat by the greygate.", usage:"/allowedgreys", usableBy: "godsAndMods", aliases: ["ag"], argsRegex: null, execute: function(msg) { delayedNotice("allowed greys:" + configuration.allowed_greys, msg.user); } }, } const parseCommand = function(text) { if(!text || text.length === 0 || text.charAt(0) !== cmdPrefix) { return null; } let parts = text.match(cmdRegex); if(!parts) { return null; } let aliasName = parts[1].toLowerCase(); let operationName = aliasMap[aliasName]; if(!operationName) { throw new Error("unrecognized command alias: " + aliasName); } let operation = operations[operationName]; let unparsedArgs = parts[3]; let args = []; if(unparsedArgs && !operation.argsRegex) { throw new Error("Unexpected args passed for command: " + operation + ". Args:" + unparsedArgs); } if(unparsedArgs && operation.argsRegex) { let argsParts = unparsedArgs.match(operation.argsRegex); if(argsParts) { argsParts.shift(); args = argsParts; } else { throw new Error("unrecognized args for command:" + operation + ". Args: " + unparsedArgs); } } return { operation: operation, opName: operationName, args: args }; } const deny = function(opName) { throw new Error("Sorry, you are not authorized to perform that operation: " + opName); } const getGroupsByUser = function(user) { if(configuration.users && configuration.users[user]) { return configuration.users[user].groups; } return []; }; const checkAccess = function(msg, op) { if(configuration.gods.includes(msg.user)) { return true; } if(op.usableBy =="godsAndMods" && msg.is_mod) { return true; } return false; }; cb.onMessage(function(msg) { try { let cmd = parseCommand(msg.m); if(cmd) { msg['X-Spam'] = true; if(!checkAccess(msg, cmd.operation)) { deny(cmd.opName); } cmd.operation.execute(msg, ...cmd.args); } } catch(e) { msg['X-Spam'] = true; delayedNotice(e.message, msg.user); return msg; } if(!msg.is_mod && !msg.in_fanclub && !configuration.gods.includes(msg.user)) { if(configuration.quiet_list.includes(msg.user)) { delayedNotice(" you have been put in quiet mode, " + " so your message has been replaced with words of encouragement for jas :). " + " You can tip 100 tokens to be un-quieted, but try to behave! ", msg.user); let beautyWords = configuration.beautyWords; var beautyWord = beautyWords[Math.floor(Math.random() * beautyWords.length)]; msg.m = "You're " + beautyWord + ", jas!"; } } let passphrase = configuration.passphrase; let allowedGreys = configuration.allowed_greys; let greyMode = configuration.grey_mode; let isGrey = !msg.has_tokens; if(greyMode === "gated" && isGrey) { if(msg.m.includes(passphrase)&&!allowedGreys.includes(msg.user)) { cb.sendNotice("Permitting user "+msg.user+" to chat even if grey.") allowedGreys.push(msg.user); } if(!allowedGreys.includes(msg.user)) { msg['X-Spam'] = true; cb.sendNotice("To reduce bot abuse, users without tokens may only send messages " + " after sending a message containing the secret passphrase:"+passphrase, msg.user); } } else if(isGrey && greyMode === "closed") { msg['X-Spam'] = true; cb.sendNotice("Grey users are not currently permitted to chat.", msg.user); } if(configuration && configuration.automatic_replies) { autoReplies = configuration.automatic_replies; for(var i=0; i<autoReplies.length; i++) { if(msg.m.match(new RegExp(autoReplies[i].condition,"i"))) { delayedNotice(autoReplies[i].reply); } } } if(configuration && configuration.profanity_replacements) { profanityFilters = configuration.profanity_replacements; for(var i=0; i<profanityFilters.length; i++) { niceWord = ""; if(Array.isArray(profanityFilters[i].nice)) { niceWord = profanityFilters[i].nice[Math.floor(Math.random() * profanityFilters[i].nice.length)]; } else { niceWord = profanityFilters[i].nice; } msg.m = msg.m.replace(profanityFilters[i].naughty, niceWord); } } cb.drawPanel(); return msg; }); cb.onTip(function(tip) { if(tip.amount>=1000) { delayedNotice("Splendid! :turbletitty2"); } else if(tip.amount>=100) { delayedNotice("Tasty! :jasbread"); } }); const initializeAliases = function() { for(var opName in operations) { operation = operations[opName]; aliasMap[opName] = opName; let aliases = operation.aliases; for(var i = 0; i < aliases.length; i++) { aliasMap[aliases[i]] = opName; } } } const init = function() { initializeAliases(); delayedNotice("Bot activated"); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.