Bots Home
|
Create an App
Anna's Bot
Author:
cryptojunkie
Description
Source Code
Launch Bot
Current Users
Created by:
Cryptojunkie
// Variable declaration var hasGreetedArray = new Array(); var strikes = new Array(); var silenced = new Array(); var hasBeenWarned = new Array(); // Chat color variables var curCol = "050000"; var curMsg = 0; // Settings stuff cb.settings_choices = [ {name:'stutter_message', type:'str', minLength:1, maxLength:99, defaultValue:"I'm sorry Mistress, I didn't want to respect your wishes.", label: "Message of the Silenced"}, {name:'rotate', type:'int', minValue:0, maxValue: 25, defaultValue:10, label:'How many messages until black -> red (and red -> black) [0 to remove rotations]'} ]; // Set Chaturbate class event functions // START cb.onEnter(function(user) { // I mean, mistress calling herself mistress is a bit out there, might want to avoid it. if (user['user'] == cb.room_slug) { hasGreetedArray.push(user['user']); } // Check if a noobie is around if (!hasGreeted(user['user'])) { cb.sendNotice('Welcome ' + user['user'] + ', please greet our beautiful hostess by calling her Mistress. Example: Hello Mistress', user['user'], "#FF0000", "", "bold", ""); } // Check for mods if (user['is_mod']) { hasGreetedArray.push(user['user']); cb.sendNotice('Welcome ' + user['user'] + ', you are exempt from needing to greet. \nBut doing so is always apprecitaed.', user['user'], "#00FF00", "", "bold", ""); } }); // Bulk of the magic cb.onMessage(function(msg) { var user = msg['user']; // Mistress is always exempt, mods are sometimes exempt // This bit is mainly for if the bot was reset during a session if (!hasGreeted(cb.room_slug)) { hasGreetedArray.push(cb.room_slug); } if (msg['is_mod'] && !hasGreeted(msg['user'])) { hasGreetedArray.push(msg['user']); } if (msg['is_mod'] || msg['user'] == cb.room_slug) { cbjs.arrayRemove(strikes, msg['user']); cbjs.arrayRemove(silenced, msg['user']); } // Check if they have been silenced if (isSilenced(user)) { msg['m'] = cb.settings.stutter_message; return; } // What to do if they have not greeted Mistress if (!hasGreeted(user)) { if (!msg['m'].toLowerCase().includes("mistress")) { // Check if they have a strike, and silence if (hasStrike(user)) { silenced.push(user); msg['m'] = cb.settings.stutter_message; cb.sendNotice(user + ', you have been silenced.', user, "#FF0000", "", "bolder", ""); return msg; } // Give strike, and re-warn strikes.push(user); msg["X-Spam"] = true; msg['m'] = "Your message was not sent to the public chat."; cb.sendNotice('Again, ' + user + ', please greet her by saying Mistress. Last chance.', user, "#FF0000", "", "bolder", ""); return msg; } else if (msg['m'].toLowerCase().includes("mistress")) { // Good user hasGreetedArray.push(user) cb.sendNotice(user + ', Thank you :).', user, "#00FF00", "", "bold", ""); } } // Commands // slug and mods if (msg['m'].charAt(0) == "/") { msg["X-Spam"] = true; if (user == cb.room_slug || msg['is_mod']) { if (msg['m'].substr(0, 8) == "/absolve") { absolve(msg['m'], msg['user']); } else if (msg['m'].substr(0, 8) == "/silence") { silence(msg['m'], msg['user']); } else if (msg['m'].substr(0, 5) == "/help") { cb.sendNotice("Anna's Bot\n | /absolve [username/s] - Remove strikes and silences for [username/s]\n | -- [username/s] can be a list separated by spaces, or left empty to absolve all users\n | /silence [username/s] - Silence [username/s]\n | -- [username/s] is a list separated by spaces\n | /help - show this menu", cb.room_slug, "#217EF7", "", "bold", ""); //\n [username/s] can be a list separated by spaces, or left empty to absolve all users\n /help - show this menu } else { cb.sendNotice("Sorry mistress, I don't know that one\n" + "Try /help for the list of commands.", cb.room_slug, "#217EF7", "", "bold", ""); } } else { cb.sendNotice(user + ', you do not have access to commands. Your embarrassment has been hidden from chat.', user, "#FF0000", "", "bolder", ""); } } if (!msg["X-Spam"] && cb.settings.rotate != 0) { changeColor(); if (curMsg == parseInt(((2 * cb.settings.rotate) - 1))) { curMsg = 0; } else { curMsg++; } msg['c'] = "#" + curCol; } return msg; }); //STOP // Absolve the pure evil function absolve(message, user) { var absArr = message.split(" "); var len = absArr.length; if (len > 1) { for (var i = 1; i < len; i++) { cb.sendNotice('Absolving ' + absArr[i], user, "#217EF7", "", "bold", ""); cb.sendNotice('You have been absolved by ' + user + ', be thankful, and greet Mistress as such.', absArr[i], "#00FF00", "", "bolder", ""); cbjs.arrayRemove(strikes, absArr[i]); cbjs.arrayRemove(silenced, absArr[i]); } } else { strikes = new Array(); silenced = new Array(); } if (user == cb.room_slug) { cb.sendNotice('You are very kind Mistress.', cb.room_slug, "#00FF00", "", "bolder", ""); } } // Goodbye bitches function silence(message, user) { var silArr = message.split(" "); var len = silArr.length; if (silArr.length == 1) { cb.sendNotice('No username is given.', user, "#217EF7", "", "bold", ""); return; } if (len > 1) { for (var i = 1; i < len; i++) { // Can't have this happen if (silArr[i] == cb.room_slug) { cb.sendNotice("Not to the room_slug you don't.", user, "#217EF7", "", "bold", ""); return; } cb.sendNotice('Silencing ' + silArr[i], user, "#217EF7", "", "bold", ""); cb.sendNotice('You have been silenced by ' + user, silArr[i], "#FF0000", "", "bolder", ""); strikes.push(silArr[i]); silenced.push(silArr[i]); } } } // Is this lazy? A little bit. function hasGreeted(username) { return checkArray(hasGreetedArray, username); } function hasStrike(username) { return checkArray(strikes, username); } function isSilenced(username) { return checkArray(silenced, username); } function checkArray(arr, string) { if (typeof Array.prototype.includes === "function") { return arr.includes(string); } else { for (var i = 0; i < arr.length; i++) { if (arr[i] == string) { return true; } } } } function changeColor() { if (curMsg <= cb.settings.rotate) { var r = parseInt("05", 16) + (Math.floor(250/cb.settings.rotate) * curMsg); } if (curMsg > cb.settings.rotate) { var r = parseInt("FF", 16) - (Math.floor(250/cb.settings.rotate) * (curMsg - cb.settings.rotate)); } if (r.toString(16).length < 2) { curCol = "0" + r.toString(16) + "0000"; } else { curCol = r.toString(16) + "0000"; } curCol = curCol.toUpperCase(); }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.