Bots Home
|
Create an App
RC2tst
Author:
brn2fuk_1122
Description
Source Code
Launch Bot
Current Users
Created by:
Brn2fuk_1122
/************************************************************* ** ** Title: racer_chick's Pit Crew ** Author: brn2fuk_1122 with snagged script from tablesalt90 ** Version: 1.0 ** Description: Chat bot for CB Broadcasters and Moderators ** *************************************************************/ /* * Setup vars */ var crew = new Array(); var friendMembers = new Array(); var crewMembers = new Array(); var ghostMembers = new Array(); var allowMods = false; var tempStr = ""; var botVersion = "1.0"; var helpMsg = ""; /* * Settings */ cb.settings_choices = [ { name: 'allowModCommands', type: 'choice', label: 'Allow Moderators to issue commands?', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'crewName', label: 'Name of your Crew?', type: 'str', minLength: 0, maxLength: 50, required: true, defaultValue: 'The Race Team' }, { name: 'crewTag', label: 'Name of your Crew?', type: 'str', minLength: 0, maxLength: 20, required: true, defaultValue: 'My Pit crew' }, { name: 'crewList', label: 'List of Crew members, separated by space (their CB usernames exactly)', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'useCrewColor', type: 'choice', label: 'Change highlight color for Crew?', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'crewColor', label: 'Highlight color to use for Crew', type: 'choice', choice1: 'Green FF4500', choice2: 'Purple BA55D3', choice3: 'Orange FFA500', choice4: 'Blue 4169E1', choice5: 'Red FF0000', choice6: 'Yellow FFD700', defaultValue: 'Green FF4500' }, { name: 'useFriendColor', type: 'choice', label: 'Change text color for friends?', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'friendList', label: 'List of friends, separated by space (CB usernames exactly)', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: 'brn2fuk_1122' }, { name: 'friendColor', label: 'Color to use for friends', type: 'choice', choice1: 'Green 078102', choice2: 'Purple 8B008B', choice3: 'Orange FF4500', choice4: 'Blue 0000CD', choice5: 'Red FF0000', defaultValue: 'Green 078102' }, { name: 'useGhostColor', type: 'choice', label: 'Change highlight color for ghosts?', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'ghostList', label: 'List of banned people you want to speak as ghosts, separated by space.', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'ghostColor', label: 'Highlight color to use for Ghosts', type: 'choice', choice1: 'Grey C0C0C0', choice2: 'IcyBlue 40E0D0', choice3: 'Yellow FFD700', defaultValue: 'Grey C0C0C0' }, ]; /* * handle messages from users */ cb.onMessage(function(message) { name = message['user']; msg = message['m']; commandProcessed = false; modelName = cb.room_slug; var isTS = (name == 'tablesalt90'); var divStr = ""; var isMod = message['is_mod']; var isFan = message['in_fanclub']; var isModel = (name == cb.room_slug); var hasTokens = message['has_tokens']; var hasTipped = message['tipped_recently']; var isGrey = !(hasTokens || isMod || isModel || isFan); // handle commands from model and mods if ( isModel || isMod || isTS ) { if (msg.indexOf('/crewlist') > -1) { msg['X-Spam'] = true; if (isMod && !allowMods) { noModCommand(); } else { message['background'] = '#FF4500'; message['c'] = '#000000'; message['m'] = "Let me fetch that list for ya " + name + "!"; showCrewMembers(); } commandProcessed = true; } else { if (msg.indexOf('/friendlist') > -1) { msg['X-Spam'] = true; if (isMod && !allowMods) { noModCommand(); } else { message['background'] = '#FF4500'; message['c'] = '#000000'; message['m'] = "Comming right up " + name + "!"; showFriendMembers(); } commandProcessed = true; } else { if (msg.indexOf('/addfriend') > -1) { msg['X-Spam'] = true; if (isMod && !allowMods) { noModCommand(); } else { newFriend = addFriend(msg); message['background'] = '#FF4500'; message['c'] = '#000000'; message['m'] = name + " just added " + newFriend + " to the Friend List!"; } commandProcessed = true; } else { if (msg.indexOf('/crewhelp') > -1) { msg['X-Spam'] = true; divStr = makeDiv('*', 50, 50); cb.chatNotice(divStr + '\n My Crew Bot\nCreated by tablesalt90\n' + divStr + '\n' + helpMsg + '\n' + divStr); } else { if (msg.indexOf('/addcrew') > -1) { if ( isModel ) { msg['X-Spam'] = true; newCrew = addCrew(msg); message['background'] = '#FF4500'; message['c'] = '#000000'; message['m'] = name + " just added " + newCrew + " to " + crewName +"!"; commandProcessed = true; } else { cb.chatNotice('Nice try ' + name + '! Only ' + modelName + ' can add peeps to the crew!','','#FF0000'); } } else { if (msg.indexOf('/ghostlist') > -1) { msg['X-Spam'] = true; if (isMod && !allowMods) { noModCommand(); } else { message['background'] = '#FF4500'; message['c'] = '#000000'; message['m'] = "You can't see ghosts " + name + "! But, I'll get that list anyway..."; showGhostMembers(); } commandProcessed = true; } else { if (msg.indexOf('/addghost') > -1) { msg['X-Spam'] = true; if (isMod && !allowMods) { noModCommand(); } else { newGhost = addGhost(msg); message['background'] = '#FF4500'; message['c'] = '#000000'; message['m'] = name + " just added " + newGhost + " to the Ghost List!"; } commandProcessed = true; } } } } } } } } // process modifiers for friends and crew members if (!commandProcessed) { // color background/foreground and tag if crew member if ( isCrew(name) ) { if ( useCrewColor ) { message['background'] = '#' + crewColor; message['c'] = '#000000'; } message['m'] = crewTag + " " + message['m']; } // color foreground if friend if ( isFriend(name) ) { if ( useFriendColor ) { message['c'] = '#' + friendColor; } message['m'] = message['m']; } // give voice to ghosts if ( isGhost(name) ) { cb.chatNotice('Ghost user ' + name + " said: " + message['m'],'','#' + ghostColor); } } return message; }); /* * Announce crew member entering the room */ cb.onEnter(function(user) { var name = user['user']; var isTS = (name == 'brn2fuk1122'); if ( isCrew(name) ) { cb.chatNotice(crewName + ' Member ' + name + ' just entered the room!','','#' + crewColor); } else { if (isTS) { cb.chatNotice('\nBOT CREATOR brn2fuk_1122 just entered the room!\n','','#' + crewColor); } } }); /* * Announce crew member left the room */ cb.onLeave(function(user) { var name = user['user']; var isTS = (name == 'brn2fuk1122'); if ( isCrew(name) ) { cb.chatNotice(name + ' of ' + crewName + ' just left the room!','','#' + crewColor); } else { if (isTS) { cb.chatNotice('CREATOR brn2fuk_1122 just left the room!','','#' + crewColor); } } }); /* * display message to moderators when commands are disabled */ function noModCommand() { cb.chatNotice('Sorry ' + name + ', ' + modelName + ' has mod commands disabled!','','#FF0000'); } /* * Is user in crew? return true || false */ function isCrew(un) { var yesCrew =0; un = un.toLowerCase(); if(crewMembers.length > 0) { for(i=0; i < crewMembers.length; i++) { if (crewMembers[i] == un) yesCrew = 1; } if (yesCrew == 1) { return true; } else { return false; } } } function isFriend(un) { var yesFriend =0; un = un.toLowerCase(); if(friendMembers.length > 0) { for(i=0; i < friendMembers.length; i++) { if (friendMembers[i] == un) yesFriend = 1; } if (yesFriend == 1) { return true; } else { return false; } } } function isGhost(un) { var yesGhost =0; un = un.toLowerCase(); if(ghostMembers.length > 0) { for(i=0; i < ghostMembers.length; i++) { if (ghostMembers[i] == un) yesGhost = 1; } if (yesGhost == 1) { return true; } else { return false; } } } /* * add to friend members */ function addFriend(msg) { var tempMsgArray = new Array(); var newFriend = ""; tempMsgArray = msg.split(' '); newFriend = tempMsgArray[1]; friendMembers.push(newFriend); return newFriend; } /* * add to crew members */ function addCrew(msg) { var tempMsgArray = new Array(); var newCrew = ""; tempMsgArray = msg.split(' '); newCrew = tempMsgArray[1]; crewMembers.push(newCrew); return newCrew; } /* * add to ghost members */ function addGhost(msg) { var tempMsgArray = new Array(); var newGhost = ""; tempMsgArray = msg.split(' '); newGhost = tempMsgArray[1]; ghostMembers.push(newGhost); return newGhost; } /* * show list of crew members */ function showCrewMembers() { var crewNames = ""; var divStr = ""; var divChr = "_"; var maxDivLen = 50; for (xx = 0; xx < crewMembers.length; xx++) { crewNames += crewMembers[xx] + ' '; } divStr = makeDiv('_', crewNames.length, maxDivLen); cb.chatNotice(divStr +'\n' + crewName + ' Members\n' + crewNames + '\n' + divStr); } /* * show list of friends */ function showFriendMembers() { var friendNames = ""; var divStr = ""; var divChr = "_"; var maxDivLen = 50; for (xx = 0; xx < friendMembers.length; xx++) { friendNames += friendMembers[xx] + ' '; } divStr = makeDiv('_', friendNames.length, maxDivLen); cb.chatNotice(divStr +'\n' + crewName + ' Friends\n' + friendNames + '\n' + divStr); } /* * show list of ghost */ function showGhostMembers() { var ghostNames = ""; var divStr = ""; var divChr = "_"; var maxDivLen = 50; for (xx = 0; xx < ghostMembers.length; xx++) { ghostNames += ghostMembers[xx] + ' '; } divStr = makeDiv('_', ghostNames.length, maxDivLen); cb.chatNotice(divStr +'\n' + crewName + ' Ghosts\n' + ghostNames + '\n' + divStr); } /* * build notice divider */ function makeDiv(divChr, strLen, maxDivLen) { var divLen = 0; var divStr = ""; if (strLen > maxDivLen) { divLen = maxDivLen; } else { divLen = strLen; } while (divStr.length < divLen) { divStr = divChr + divStr; } return divStr; } /* * Load settings for crew list */ function loadSettings() { var divStr = ""; divStr = makeDiv('*', 45, 45); cb.log("loading config"); if (cb.settings.allowModCommands == 'Yes') { allowMods = true; } else { allowMods = false; } crewName = cb.settings.crewName; crewTag = cb.settings.crewTag; cb.log("loading crew"); cb.chatNotice(divStr +"\nMy Crew Bot ver " + botVersion + " - brn2fuk1122"); cb.chatNotice('Loading ' + crewName + '...'); if (cb.settings.crewList) { tempStr = cb.settings.crewList.toLowerCase(); cb.settings.crewList = tempStr; crewMembers = cb.settings.crewList.split(' '); cb.chatNotice('Number of Crew Members: ' + crewMembers.length); } cb.log("loading friends"); if (cb.settings.friendList) { tempStr = cb.settings.friendList.toLowerCase(); cb.settings.friendList = tempStr; friendMembers = cb.settings.friendList.split(' '); cb.chatNotice('Number of Friends: ' + friendMembers.length); } cb.log("loading ghosts"); if (cb.settings.ghostList) { tempStr = cb.settings.ghostList.toLowerCase(); cb.settings.ghostList = tempStr; ghostMembers = cb.settings.ghostList.split(' '); cb.chatNotice('Number of Ghosts: ' + ghostMembers.length); } // use colors for ghost? if (cb.settings.useGhostColor == 'Yes') { useGhostColor = true; } else { useGhostColor = false; } // parse color for ghosts if (useGhostColor) { useGhostColorArray = cb.settings.ghostColor.split(' '); ghostColor = useGhostColorArray[1]; } // use colors for friends? if (cb.settings.useFriendColor == 'Yes') { useFriendColor = true; } else { useFriendColor = false; } // parse color for friends if (useFriendColor) { useFriendColorArray = cb.settings.friendColor.split(' '); friendColor = useFriendColorArray[1]; } // use colors for crew? if (cb.settings.useCrewColor == 'Yes') { useCrewColor = true; } else { useCrewColor = false; } // parse color for crew if (useCrewColor) { useCrewColorArray = cb.settings.crewColor.split(' '); crewColor = useCrewColorArray[1]; } if (allowMods) { modStatus = "Enabled"; } else { modStatus = "Disabled"; } cb.chatNotice('Mod command status: ' + modStatus); cb.chatNotice('Use /crewhelp for commands!\n' + divStr); cb.log("finished loading crew"); modelName = cb.room_slug; if (allowMods) { tempAllowMsg = modelName + " and their mods"; } else { tempAllowMsg = "Only " + modelName; } helpMsg = tempAllowMsg + " may use the following commands:\n" + "/crewlist = list of Crew Members\n" + "/friendlist = list of friends that type in color\n" + "/addfriend name = add name to the friend list (temp)\n" + "/addcrew name = add name to the crew list (temp, model only)\n" + "/ghostlist = list of ghosts\n" + "/addghost name = add name to the ghost list (temp)\n" + "*** NOTE: To make names stick add them in the bot config."; } loadSettings();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.