Bots Home
|
Create an App
fanka
Author:
mistressadelle
Description
Source Code
Launch Bot
Current Users
Created by:
Mistressadelle
/** Name: PBP Mothership Author: chelsea2950 for perfectbrownpussy Current version 1.1 Created 03/02/2019 Last Updated 03/28/2019 (see description for change log) This is a fanclub bot with the following features: - Enter the fanclub list using a comma separated string - Also able to join the club within a show by tipping the defined amount - Members get font and highlight color choices - 50 slots for personalized icons **/ { if (cb.room_slug == 'mistressadelle') { cb.settings_choices = [ {name: 'dummy0', label: '**************************************************************** Welcome back mistressadelle! ****************************************************************', type: 'choice',required: false}, {name: 'tipToJoin',label: 'Allow tipping to join the Fan Club?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'tipAmountToJoin',label: 'Tip Amount to join fanclub during the show', type: 'int', minValue: 1,maxValue: 10000,defaultValue: 500}, {name: 'fanclubList', label: 'Enter the names of existing Mothership Fan Club members. Should be the CB usernames, separated by a comma with no spaces',type: 'str',minLength: 1,maxLength: 1000, defaultValue: '',required: false}, {name: 'textColor',label: 'Text color for fanclub user messages',type: 'choice',choice1: 'White/No Color',choice2: 'Black',choice3: 'Dark Grey',choice4: 'Dark Red',choice5: 'Dark Orange',choice6: 'Dark Green',choice7: 'Dark Aqua',choice8: 'Dark Blue',choice9: 'Dark Purple',choice10: 'Dark Pink',choice11: 'Dark Gold',choice12: 'Dark Teal',choice13: 'Dark Brown',choice14: 'Dark Bronze',choice15: 'Dark Periwinkle',choice16: 'Dark Fuschia',choice17: 'Dark Lime',choice18: 'Dark Plum',choice19: 'Custom',defaultValue: 'Dark Green'}, {name: 'textCustomColor', label: 'If you picked "Custom" as the text color in the previous setting, enter the hex color (6 character hex color codes including the # prefix, such as #FFFFFF):', type: 'str', minLength: 1,maxLength: 7,required: false}, {name: 'highlightColor',label: 'Background/Highlight color for fanclub user messages', type: 'choice', choice1: 'White/No Color',choice2: 'Light Yellow',choice3: 'Light Blue',choice4: 'Light Pink',choice5: 'Light Red',choice6: 'Light Green',choice7: 'Light Purple',choice8: 'Light Orange',choice9: 'Light Grey',choice10: 'Light Aqua',choice11: 'Light Teal',choice12: 'Cream',choice13: 'Light Bronze',choice14: 'Light Periwinkle',choice15: 'Light Fuschia',choice16: 'Light Lime',choice17: 'Light Plum',choice18: 'Custom',defaultValue: 'Light Green'}, {name: 'highlightCustomColor', label: 'If you picked "Custom" as the highlight color in the previous setting, enter the hex color (6 character hex color codes including the # prefix, such as #FFFFFF):',type: 'str',minLength: 1,maxLength: 7,required: false} ]; } else { cb.settings_choices = [ {name: 'warning', label: 'Sorry, this bot is only usable for broadcaster mistressadelle', type: 'choice',required: false}, ]; } } { // *********************************** Variables and Arrays ************************************** var initialize = 0; /* Used to run initialization once */ var BC = cb.room_slug; var green = "#a2dfac"; // Used for general messaging from fembot var defaultIcon = cb.settings.fanclubDefaultIcon; // *** Arrays ***/ var fanListArray = []; var iconArray = {user: [], icon: []}; } { // *********************************** Functions ************************************** { function checkTextColor(color) { switch (color) { case "White/No color": return "#FFFFFF"; case "Black": return "#000000"; case "Dark Blue": return "#0629AC"; case "Dark Pink": return "#FF6680"; case "Dark Green": return "#006600"; case "Dark Red": return "#cc0000"; case "Dark Purple": return "#3d003d"; case "Dark Grey": return "#737373"; case "Dark Orange": return "#e77400"; case "Dark Aqua": return "#006767"; case "Dark Gold": return "#998100"; case "Dark Teal": return "#003f1f"; case "Dark Brown": return "#582c00"; case "Dark Bronze": return "#a56728"; case "Dark Periwinkle": return "#155bd7"; case "Dark Fuschia": return "#d6155c"; case "Dark Lime": return "#6b790c"; case "Dark Plum": return "#7f13bf"; default: if (/^#[0-9A-F]{6}$/i.test(color)) { return color; } else if (/^[0-9A-F]{6}$/i.test(color)) { return ('#' + color); } else { return ("default"); } } } function checkBgColor(color) { switch (color) { case "White/No color": return "#FFFFFF"; case "Light Aqua": return "#adeaea"; case "Light Pink": return "#FFE6EA"; case "Light Green": return "#94e594"; case "Light Red": return "#ff9a9a"; case "Light Purple": return "#f2cdff"; case "Light Orange": return "#ffd9b3"; case "Light Grey": return "#e6e6e6"; case "Light Blue": return "#d1eaee"; case "Light Yellow": return "#ffff94" case "Cream": return "#f9f6ed" case "Light Bronze": return "#ebccad"; case "Light Periwinkle": return "#d7e4fb"; case "Light Teal": return "#d7fbee"; case "Light Fuschia": return "#fbd7e4"; case "Light Lime": return "#ecf6a7"; case "Light Plum": return "#e3c0f9"; default: if (/^#[0-9A-F]{6}$/i.test(color)) { return color; } else if (/^[0-9A-F]{6}$/i.test(color)) { return ('#' + color); } else { return ("default"); } } } function addRmvFan(user, chgby, mode) { if (mode == 'a') { if (cbjs.arrayContains(fanListArray,user)) { cb.sendNotice(user + ' is already on the Mothership Fan Club list.', chgby, green); } else { fanListArray.push(user); cb.sendNotice('You have added ' + user + ' to the Mothership Fan Club list. Note this is only applied during this session, permanent Mothership Fan Club list changes must be made to the list defined when starting the bot. This list should also be saved to a separate document.', chgby, green); cb.sendNotice('Congratulations! You have been added to the Mothership Fan Club list!', user, msBgColor, msTextColor, 'bold'); } } else if (mode == 'r') { if (cbjs.arrayContains(fanListArray,user)) { cbjs.arrayRemove(fanListArray,user); cb.sendNotice('You have removed ' + user + ' from the Mothership Fan Club list. Note this is only applied during this session, permanent Fan Club list changes must be made to the list defined when starting the bot. This list should also be saved to a separate document.', chgby, green); } else { cb.sendNotice(user + ' is not on the Mothership Fan Club list.', chgby, green); } } } function addByTipping(user) { if (!cbjs.arrayContains(fanListArray,user)) { fanListArray.push(user); cb.sendNotice(user + ' has joined Mothership Fan Club!', '', msBgColor, msTextColor, 'bold'); cb.sendNotice(user + ' has been added to the Fan Club List. Note this is only applied during this session - permanent Mothership Fan Club list changes must be made to the list defined when starting the bot. This list should also be saved to a separate document.', cb.room_slug, green); } } function updateDefaultIcon(newicon, chgby) { defaultIcon = newicon; cb.sendNotice('You have updated the default Mothership Fan Club icon to "' + newicon + '". Note this change is only applied during this session, permanent changes must be made to the settings on the bot launch page when next started/restarted.', chgby, green); } function updateUserIcon(user, newicon, chgby) { if (cbjs.arrayContains(fanListArray,user)) { if (cbjs.arrayContains(iconArray.user,user)) { userindex = iconArray.user.indexOf(user); iconArray.icon[userindex] = newicon; cb.sendNotice('You have updated the icon for Mothership Fan Club member ' + user + ' to "' + newicon + '". Note this change is only applied during this session, permanent changes must be made to the settings on the bot launch page when next started/restarted.', chgby, green); } else { iconArray.user.push(user); iconArray.icon.push(newicon); cb.sendNotice('You have added the icon for Mothership Fan Club member ' + user + ' as "' + newicon + '". Note this change is only applied during this session, permanent changes must be made to the settings on the bot launch page when next started/restarted.', chgby, green); } } else { cb.sendNotice('User name "' + user + '" is not in the fanclub list.', chgby, green); } } function helpBC(from) { cb.sendNotice('Mothership Fan Club Help Menu' + '\n/msaddfan [user]: Add [user] to the fanclub list.' + '\n/msrmvfan [user]: Remove [user] from the fanclub list.' + '\n/msfanlist: display the list of people on the fanclub list.' + '\n/mschgdft [icon]: Update the default Fan Club icon to the new value of [icon].' + '\n/mschguser [user] [icon]: Update the Fan Club icon for [user] to the new value of [icon].' ,from); } } } // ******************************* Upon user entry of a Message ************************************** { cb.onMessage(function (msg) { if (cb.room_slug == 'mistressadelle') { var message = msg['m'].split(' '); var m = msg.m; var u = msg.user; var isFanClub = cbjs.arrayContains(fanListArray,u); var isBC = (u === cb.room_slug); var BC = cb.room_slug; var command = message[0] if(message[0].charAt(0) == '/') { msg['X-Spam'] = true; switch(command) { case '/msaddfan': { if (isBC) { if (message[1]) { addRmvFan(message[1], u, 'a'); } else { cb.sendNotice('You didn\'t specify the user you want to add to the Mothership Fan Club.', u, green); } } else { cb.sendNotice('Only broadcasters are able to use that command.', u, green); } break; } case '/msrmvfan': { if (isBC) { if (message[1]) { addRmvFan(message[1], u, 'r'); } else { cb.sendNotice('You didn\'t specify the user you want to remove from the Mothership Fan Club.', u, green); } } else { cb.sendNotice('Only broadcasters are able to use that command.', u, green); } break; } case '/msfanlist': { if (isBC) { cb.sendNotice('Users currently in the Mothership Fan Club: (' + fanListArray.length + ' members)\n' + (fanListArray.length > 0 == true ? cbjs.arrayJoin(fanListArray, ',') : 'No users.'), u); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.\nType "/fbhelp commands" to see a full list of the available commands.', u, green); } break; } case '/mschgdft': { if (isBC) { if (message[1]) { updateDefaultIcon(message[1], u); } else { cb.sendNotice('You didn\'t specify the new default icon/gif for the Mothership Fan Club. You can either use a gif (such as ":hearts") or a unicode character (such as "\u2661").', u, green); } } else { cb.sendNotice('Only broadcasters are able to use that command.', u, green); } break; } case '/mschguser': { if (isBC) { if (message[1]) { if (message[2]) { updateUserIcon(message[1], message[2], u); } else { cb.sendNotice('The second parameter for this command is the new icon value and no value was given. Please use the syntax of "/mschguser [username] [newicon]". For the new icon, you can either use a gif (such as ":hearts") or a unicode character (such as "\u2661").', u, green); } } else { cb.sendNotice('The first parameter for this command is the user name and no user name was given. Please use the syntax of "/mschguser [username] [newicon]".', u, green); } } else { cb.sendNotice('Only broadcasters are able to use that command.', u, green); } break; } case '/mshelp': { if (isBC) { helpBC(u); } else { cb.sendNotice('Only broadcasters are able to use that command.', u, green); } break; } } } // ********** Add colors and icon for fans or users if (isFanClub) { if (msBgColor) { msg['background'] = msBgColor; } if (msTextColor) { msg['c'] = msTextColor; } if (message[0].charAt(0) != "/" && message[0].charAt(0) != "!") { if (cbjs.arrayContains(iconArray.user,u)) { userindex = iconArray.user.indexOf(u); pfxicon = iconArray.icon[userindex]; } else if (defaultIcon) { pfxicon = defaultIcon; } else { pfxicon = ''; } if (pfxicon != '') { msg.m = pfxicon + ' ' + msg.m; } } } return msg; } }); } // *********************************** Actions on user entering ************************************** { cb.onEnter(function(user) { }); } // *********************************** Actions upon leaving ************************************** { cb.onLeave(function(user) { }); } // *********************************** Actions upon tipping ************************************** { cb.onTip(function (tip) { if (cb.room_slug == 'mistressadelle') { var tipAmount = Number.parseInt(tip.amount, 10); var u = tip.from_user // ***** Check for Fan Club Join if (cb.settings.tipToJoin == 'Yes' && tipAmount >= cb.settings.tipAmountToJoin) { addByTipping(u,tipAmount); } } }); } // *********************************** Initialize ************************************** { if(initialize == 0) { if (cb.room_slug == 'mistressadelle') { if (cb.settings.textColor == 'Custom') { msTextColor = checkTextColor(cb.settings.textCustomColor); if (msTextColor == 'default') { cb.sendNotice('Error while setting the Mothership Fan Club text color. It has to be in a HEX format. Using default value.', cb.room_slug, green, '', 'bold'); msTextColor = '#000000'; } } else { msTextColor = checkTextColor(cb.settings.textColor); } if (cb.settings.highlightColor == 'Custom') { msBgColor = checkBgColor(cb.settings.highlightCustomColor); if (msBgColor == 'default') { cb.sendNotice('Error while setting the Mothership Fan Club highlight color. It has to be in a HEX format. Using default value.', cb.room_slug, green, '', 'bold'); msBgColor = '#ffffff'; } } else { msBgColor = checkBgColor(cb.settings.highlightColor); } // *** Load Array for Fan Club List if(cb.settings.fanclubList) { var n = cb.settings.fanclubList; fanListArray = n.split(','); } // *** Load Array for User Icons for (let i = 1; i <= 50; i++) { iconuser = this["User"+i]; icon = this["Icon"+i]; if(iconuser && icon) { iconArray.user.push(iconuser); iconArray.icon.push(icon); } } initialize = 1; } } }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.