Bots Home
|
Create an App
Olivia's Whisper Bot
Author:
oliviadellvine
Description
Source Code
Launch Bot
Current Users
Created by:
Oliviadellvine
var userArray = []; var chatHidden = true; // Bot settings. cb.settings_choices = [ { name: "fwb_list", type: "str", label: "List of people who can talk secretly", defaultValue: "" }, { name: "notice_color", type: "str", required: true, label: "Global notices color (e.g. #FFF6FB)" }, { name: "notice_background_color", type: "str", required: true, label: "Global notices background color (e.g. #FFF6FB)" } ]; // Fill mods and fans arrays. if (cb.settings.fwb_list !== undefined) { userArray = cb.settings.fwb_list.split(" "); } // Act upon chat messages. cb.onMessage(function(msg) { var message = msg["m"].split(" "); // Explode message to an array. var user = msg["user"]; var onTheList = userOnList(user); var has_access = user == cb.room_slug || msg["is_mod"]; var commands = [ "/w", "/add", "/toggle", "/remove" ]; // Commands that can be called. // Check if a command is called. if (cbjs.arrayContains(commands, message[0])) { msg["X-Spam"] = true; // Hide command from chat by marking it as spam. var command = message[0]; var errorMessages = new Array(); // Do some checks. if ((message[0] == commands[1] || message[0] == commands[2]) && has_access == false) { errorMessages.push("You are not allowed to execute this command."); } if (errorMessages.length == 0) { // No errors, execute! var target_user = message[1]; message.splice(0, 1); // Remove command and target_user from array. var text = message.join(" "); // Implode remains of array to string. switch (command) { case commands[0]: msg["m"] = text; msg["X-Spam"] = false; break; case commands[1]: var tempLength = message.length; msg["m"] = "***Added"; for (var i = 0; i < tempLength; i++){ userArray.push(message[i]); msg["m"] += " " + message[i]; } msg["m"] += "***"; break; case commands[2]: chatHidden = !chatHidden; if (chatHidden){ msg["m"] = "***Chat is now visible***"; } else{ msg["m"] = "***Chat is now hidden***"; } break; case commands[3]: var tempLength = message.length; msg["m"] = "***Removed"; for (var m = 0; m < tempLength; m++){ removeUser(message[m]); msg["m"] += " " + message[m]; } msg["m"] += "***"; break; } } else { //Errors found, display them to the user! cb.sendNotice(errorMessages.join("\n"), user); } } else { msg["X-Spam"] = true; // No command. if (onTheList == true && !chatHidden) { sendIt(user, msg["m"]); msg["m"] = "***Message Sent***"; } else{ msg["m"] = text; } } return msg; }); function userOnList(user) { var length = userArray.length; for(var j = 0; j < length; j++){ if (user == userArray[j]){ return true; } } if (user == cb.room_slug){ return true; } return false; } function sendIt(user, text){ cb.sendNotice( user + ": " + text, cb.room_slug, cb.settings["notice_background_color"], cb.settings["notice_color"] ); var length = userArray.length; for(var k = 0; k < length; k++){ cb.sendNotice( user + ": " + text, userArray[k], cb.settings["notice_background_color"], cb.settings["notice_color"] ); } } function removeUser(user) { var tempArray = []; var arrayLength = userArray.length; for (var l = 0; l < arrayLength; l++) { if (userArray[l] != user){ tempArray.push(userArray[l]); } } userArray = tempArray; }
© Copyright Chaturbate 2011- 2026. All Rights Reserved.