Bots Home
|
My Uploads
|
Create an App
My Crew 2.0
Author:
tablesalt90
Description
Source Code
Launch Bot
Current Users
Created by:
Tablesalt90
App Images
/* * * My Crew 2 bot * Author: tablesalt90 - @tablesalt90 - tablesalt90(at)gmail(dot)com * * Note to those who wish to reuse this code with the purpose of making * a new version of this bot with your own modification... * * I encourage you to do so and hope you learn something in the process. * All I ask is that you please give credit where credit is due when building * upon my code. I don't obfuscate or encrypt my code for the purpose * of allowing others to easily learn from it. I take the time to include * meaningful comments throughout the code as well as comment blocks that * prefix all of my methods. I hope you find my code very clean and * easy to follow. If you have any questions or suggestions feel free to * DM me on twitter or send me an email. Don't be alarmed if I don't * respond immediately. I don't check messages everyday. :) * * This is total re-write of my original My Crew bot initally created in 2013. * I have added several new features found in some of the other bots I've * written over the years, and a few new ones. * * The code is pretty optimized and uses a set of arrays and objects * to manage the ranks of the crew and the members and are controlled * by loader functions. Object searching and filtering uses the * .filter() method and ES6 arrow functions to produce filtered arrays * from the store objects. I find storing, getting, putting data into * objects is much easier to keep straight. Then filtering specific data * out to arrays for easier processing of the data. * * If you want to create bots and apps that use objects for storing user, or other, * data then chunking the data out to filtered arrays for use in your methods * check out the getCrewCounts() and getCrewArray() methods. And read up on using * .filter() .reduce() .find() and using ES6 arrow functions. * * Major features * * 1. Up to five different ranks can exist in the crew. Each rank has it's own lable or tag * and a defined tip amount required to reach that rank. At runtime users that tip a defined * amount for a rank will be added to that rank for the session. Of course to make the change * perminant you'll need to add them to the list of users for that rank in the config. Users * may be manually added to ranks as well during runtime. See the runtime commands. * * 2. This version includes spam pattern filtering which can be used in the config or * at runtime to mute messages from usernames that match any of the defined patterns or keywords * in the filter array. See the runtime commands. * * 3. Up to two notifications may be set. These will be trigged at the selected intervals (up * to 2 hours) while the bot is running. To disable the notifications set the interval value to 0. * This can be controlled through the runtime commands as well. * * 4. Optional command privileges for Mods and/or Fan Club memebers. This may be set in the config * and modified during runtime. See the runtime commands. * * 5. Individual labels may be set for each user or crew memeber at runtime. This will override their default rank * label if they are a crew member. However, their messages will still be highlighted. See the runtime commands. * * 6. My popular Gender Bot is part of this version. This optional add-on can be enabled/disabled through the config * or at runtime. When enabled emotes indicating the users gender will be displayed before each message. See the runtime * commands. * * 7. Individual emotes may be set for each user or crew member. This is a runtime command that will override the standard * Gender Bot emote if it is set for an individual user or crew member. * * 8. Ghost users allows a user that has been silenced using the CB silence feature to have their messages displayed through * chat notifications. This is great for users that are accidently silenced. See the runtime commands. * * 9. Timeout makes it so an individual user's messages are surpressed for a selected number of minutes. This is a runtime * command that may be used by the broadcaster, mods/fan (if enabled) to "silence" a user temporarily as a warning. While in timeout * the user's messages will be replaced with a random quote or alternative message. * * 10. Mute is similar to the Timeout command but doesn't replace their message, it simply displays nothing. Mute doesn't have a time * setting they are either muted or unmuted. * * 11. Tip Menu lets you create a list of request/actions and token amounts so you don't have to use a notfication or keep telling people tip amounts. * * 12. Tipper Log keeps track of all tips made while the bot is running. A list of tippers can be displayed using a runtime command. * * 13. Top Tippers displays a list of the top n (number set in the config) tippers logged while the bot has been running. This can be set to * display ever x minutes (set in config). * * 14. Whisper allows the broadcaster and mods/fans (if enabled) to send an in-chat private message to a user. Simply begin the message * with @ followed by the username of the user you want to send the message to. For example, @tablesalt90 Hi there! would send a private * message to the user tablesalt90 using a chat notification. This command may interfer with other bots that you @ as a command trigger. * * * */ var highlightColors = { White: '#FFFFFF', Aqua: '#7FFFD4', LtBrown: '#F4A460', Cyan: '#E0FFFF', Gold: '#EEE8AA', Yellow: '#FFF68F', Slate: '#C6E2FF', Pink: '#FFF0F5', Orange: '#FFD39B', Mint: '#BDFCC9', Grey: '#F2F2F2', Plum: '#CD96CD' } var messageColors = { Primary: '#007BFF', Info: '#17A2B8', Danger: '#DC3545', Success: '#28A745', Warning: '#FFC107', Secondary: '#6C757D', White: '#FFFFFF', Black: '#000000' } var botVersion = "2.0.0"; var botDate = "Jun 20, 2018"; var crews = ['a','b','c','d','e']; var members = []; var ranks = {}; var creator = {}; var settings = {}; var spamArray = []; var tipMenu = []; /* * General Messaging Object Methods */ var Notice = { Public: function(message, bg, fg) { cb.sendNotice(message, null, bg, fg, 'bold', null); }, Private: function(message, recipient, bg, fg) { cb.sendNotice(message, recipient, bg, fg, 'bold', null); }, Mods: function(message, bg, fg) { cb.sendNotice(message, null, bg, fg, 'bold', 'red'); }, Fans: function (message, bg, fg) { cb.sendNotice(message, null, bg, fg, 'bold', 'green'); }, Broadcaster: function (message, bg, fg) { cb.sendNotice(message, null, bg, fg, 'bold', 'orange'); }, Error: { Public: function (message) { Notice.Public(message, messageColors.Danger, messageColors.White); }, Private: function (message, recipient) { Notice.Private(message, recipient, messageColors.Danger, messageColors.White); } }, Info: { Public: function(message) { Notice.Public(message, messageColors.Info, messageColors.Black); }, Private: function(message, recipient) { Notice.Private(message, recipient, messageColors.Info, messageColors.Black); } }, Warning: { Public: function(message) { Notice.Public(message, messageColors.Warning, messageColors.Black); }, Private: function(message, recipient) { Notice.Private(message, recipient, messageColors.Warning, messageColors.Black); } }, Success: { Public: function(message) { Notice.Public(message, messageColors.Success, messageColors.White); }, Private: function(message, recipient) { Notice.Private(message, recipient, messageColors.Success, messageColors.White); } }, Normal: { Public: function(message) { Notice.Public(message, messageColors.Primary, messageColors.White); }, Private: function(message, recipient) { Notice.Private(message, recipient, messageColors.Primary, messageColors.White); } }, Muted: { Public: function(message) { Notice.Public(message, messageColors.Secondary, messageColors.White); }, Private: function(message, recipient) { Notice.Private(message, recipient, messageColors.Secondary, messageColors.White); } } } /* * CB Settings Array */ cb.settings_choices = [ { name: 'allowWhisper', type: 'choice', label: 'Allow whispering', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'whisperTrigger', type: 'str', label: 'Whisper Trigger (@)', minLength: 1, maxLength: 1, required: true, defaultValue: '@' }, { name: 'commandTrigger', type: 'str', label: 'Command Trigger (/mc)', minLength: 1, maxLength: 10, required: true, defaultValue: '/mc' }, { name: 'allowGreyEmotes', type: 'choice', label: 'Allow Grey Emotes?', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'genderEmotes', type: 'choice', label: 'Show gender of users in chat?', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'autoNotice1', type: 'str', label: 'Notification Message 1, use text and emotes', minLength: 0, maxLength: 512, required: false, defaultValue: '' }, { name: 'autoNotice1Interval', type: 'int', label: 'Show Notification 1 Every x Minutes', minValue: 0, maxValue: 120, required: false, defaultValue: 0 }, { name: 'autoNotice2', type: 'str', label: 'Notification Message 2, use text and emotes', minLength: 0, maxLength: 512, required: false, defaultValue: '' }, { name: 'autoNotice2Interval', type: 'int', label: 'Show Notification 2 Every x Minutes', minValue: 0, maxValue: 120, required: false, defaultValue: 0 }, { name: 'modCommands', type: 'choice', label: 'Allow Moderators to use commands?', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'fanCommands', type: 'choice', label: 'Allow Fan Club Members to use commands?', choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, { name: 'spamPatternList', type: 'str', label: 'List spam names to automatically block (fullname or partial)', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'crewHighlightColor', type: 'choice', label: 'Highlight color to use for all crew ranks', choice1: 'White', choice2: 'Aqua', choice3: 'LtBrown', choice4: 'Cyan', choice5: 'Gold', choice6: 'Yellow', choice7: 'Slate', choice8: 'Pink', choice9: 'Orange', choice10: 'Mint', choice11: 'Grey', choice12: 'Plum', required: true, defaultValue: 'White' }, { name: 'crewALabel', type: 'str', label: 'Crew Rank A Label', minLength: 0, maxLength: 30, required: true, defaultValue: '[Friend]' }, { name: 'crewAList', type: 'str', label: 'List of usernames in Crew Rank A', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'crewATip', type: 'int', label: 'Tip required to join Crew Rank A', minValue: 1, maxValue: 999999, required: true, defaultValue: 0 }, { name: 'crewBLabel', type: 'str', label: 'Crew Rank B Label', minLength: 0, maxLength: 30, required: false, defaultValue: '' }, { name: 'crewBList', type: 'str', label: 'List of usernames in Crew Rank B', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'crewBTip', type: 'int', label: 'Tip required to join Crew Rank B', minValue: 1, maxValue: 999999, required: false, defaultValue: 0 }, { name: 'crewCLabel', type: 'str', label: 'Crew Rank C Label', minLength: 0, maxLength: 30, required: false, defaultValue: '' }, { name: 'crewCList', type: 'str', label: 'List of usernames in Crew Rank C', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'crewCTip', type: 'int', label: 'Tip required to join Crew Rank C', minValue: 1, maxValue: 999999, required: false, defaultValue: 0 }, { name: 'crewDLabel', type: 'str', label: 'Crew Rank D Label', minLength: 0, maxLength: 30, required: false, defaultValue: '' }, { name: 'crewDList', type: 'str', label: 'List of usernames in Crew Rank D', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'crewDTip', type: 'int', label: 'Tip required to join Crew Rank D', minValue: 1, maxValue: 999999, required: false, defaultValue: 0 }, { name: 'crewELabel', type: 'str', label: 'Crew Rank E Label', minLength: 0, maxLength: 30, required: false, defaultValue: '' }, { name: 'crewEList', type: 'str', label: 'List of usernames in Crew Rank E', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'crewETip', type: 'int', label: 'Tip required to join Crew Rank E', minValue: 1, maxValue: 999999, required: false, defaultValue: 0 }, { name: 'tipMenu', type: 'str', label: 'Tip Menu (item:amount item:amount)', minLength: 0, maxLength: 10240, required: false, defaultValue: '' } ]; /* * CB API methods */ cb.onEnter(function(user) { performOnEnter(getUserData(user)) }); cb.onLeave(function(user) { performOnLeave(getUserData(user)) }); cb.onMessage(function(message) { msg = performOnMessage(getUserData(message), getMessageData(message)); if (msg.hide) { message['X-Spam'] = true } if (msg.fg) { message['c'] = msg.fg } if (msg.bg) { message['background'] = msg.bg } message['m']= msg.message; return message; }); cb.onTip(function(tip) { performOnTip(getTipData(tip)) }); /* * My Crew 2 Helper Object Methods */ var Helper = { isMod: function(data) { return data['is_mod']; }, isBroadcaster: function(data) { return (data['user'] == settings.broadcaster); }, isCreator: function(data) { return (data['user'] == uncode(settings.creator)); }, isFan: function(data) { return data['in_fanclub']; }, isDarkBlue: function(data) { return data['tipped_recently']; }, isPurple: function(data) { return data['tipped_alot_recently']; }, isDarkPurple: function(data) { return data['tipped_tons_recently']; }, isBlue: function(data) { return data['has_tokens']; }, isGrey: function(data) { return !(this.hasTokens(data) || this.isMod(data) || this.isBroadcaster(data) || this.isCreator(data) || this.isFan(data)) }, isMale: function(data) { return (this.getGender(data) === 'm'); }, isFemale: function(data) { return (this.getGender(data) === 'f'); }, isCouple: function(data) { return (this.getGender(data) === 'c'); }, isTrans: function(data) { return (this.getGender(data) === 's'); }, hasTokens: function(data) { return data['has_tokens']; }, hasTipped: function(data) { return (this.isDarkBlue(data) || this.isPurple(data) || this.isDarkPurple(data)); }, getUsername: function(data) { return data['user']; }, getGender: function(data) { return data['gender']; }, getMessage: function(data) { return data['m']; }, getMessageFont: function(data) { return data['f']; }, getMessageColor: function(data) { return data['c']; }, getTipAmount: function(data) { return data['amount']; }, getTipMessage: function(data) { return data['message']; }, getTipReceiver: function(data) { return data['to_user']; }, getTipFromUser: function(data) { return data['from_user']; }, getTipFromUserGender: function(data) { return data['from_user_gender']; }, isTipFromUserFan: function(data) { return data['from_user_in_fanclub']; }, isTipFromUserMod: function(data) { return data['from_user_is_mod']; }, isTipFromUserBlue: function(data) { return data['from_user_has_tokens']; }, isTipFromUserDarkBlue: function(data) { return data['from_user_tipped_recently']; }, isTipFromUserPurple: function(data) { return data['from_user_tipped_alot_recently']; }, isTipFromUserDarkPurple: function(data) { return data['from_user_tipped_tons_recently']; }, isTipFromUserMale: function(data) { return (this.getTipFromUserGender(data) === 'm'); }, isTipFromUserFemale: function(data) { return (this.getTipFromUserGender(data) === 'f'); }, isTipFromUserCouple: function(data) { return (this.getTipFromUserGender(data) === 'c'); }, isTipFromUserTrans: function(data) { return (this.getTipFromUserGender(data) === 's'); } } /* * General My Crew 2 Methods * */ /* * Perform logic and notification functions when cb.onEnter * is triggered. * * @param {object} userData * @returns none */ function performOnEnter(userData) { Notice.Info.Private(settings.botName + ' ' + settings.botVersion + ' is running.\n' + 'For a list of available commands type ' + settings.commandTrigger + ' help \n' + 'For instructions scroll to the top of the chat and click the bot link' + '', userData.username); if (userData.isMod && settings.modCommands) { Notice.Error.Private('Mod Commands are enabled!', userData.username); } else if (userData.isFan && settings.fanCommands) { Notice.Success.Private('Fan Club Commands are enabled!', userData.username); } else if (userData.isGrey && !settings.allowGreyEmotes) { Notice.Warning.Private('Grey Emotes are disabled. You will not be able to use emotes.',userData.username); } if (settings.genderEmotes) { Notice.Info.Private('Gender Emotes are enabled', userData.username); } if (index = memberExists(userData.username)) { var member = members[index]; var rank = member.rank; if (member.rank != 'z') { Notice.Public('Welcome ' + ranks[rank].label + ' Member ' + userData.username,settings.highlightColor,messageColors.Black); } } else { // user that entered the room doesn't exist in the // member array. We need to add them so commands can // be used on the. Adding them to the members array // doesn't mean they are part of the crew. They // are added with a rank of "z" this indicates the // default rank and they have no special permissions // in the bot. createProfile(userData.username); } } /* * Perform logic and notification functions when cb.onEnter * is triggered. * * @param {object} userData * @returns none */ function performOnLeave(userData) { } /* * Process tasks and modifictions to be performed on * message data when cb.onMessage is triggered. * This method also executes command methods when a * command is triggered. * * @param {object} userData * @param {object} messageData * @returns {object} */ function performOnMessage(userData, messageData) { } /* * Perform logic and notification functions when cb.onTip * is triggered. * * @param {object} tipData * @returns none */ function performOnTip(tipData) { } function updateMemberRank(username,newRank) { } function muteMember(username) { } function unmuteMember(username) { } function timeoutMember(username, minutes) { } function timeoutReleaseMember(username) { } function setMemberLabel(username) { } function clearMemberLabel(username) { } function setMemberEmote(username) { } function clearMemberEmote(username) { } function setMemberChatColor(username) { } function clearMemberChatColor(username) { } function getTipTotal() { } function getMemberTipTotal() { } function getMemberLastTip(username) { } function getMemberLastTipNote(username) { } function getTopTippers(maxNumber) { } function sendWhisper(message, recipient) { } function showTipMenu(username = false) { var output = '****** Tip Menu ******'; for (i =0;i < tipMenu.length; i++) { output += tipMenu[i].item + ' ' + tipMenu[i].amount + '\n'; } if (!username) { Notice.Public(output,messageColors.Black,messageColors.White); } else { Notice.Private(output,username,messageColors.Black,messageColors.White); } } /* * Takes the data in an object from cb.onEnter, cb.onLeave, * cb.onMessage, and returns the values based on the data using * helper functions as a new object of values related to the user * that caused the cb.onX method to be called. * * @param {object} data * @returns {object} */ function getUserData(data) { return { username: Helper.getUsername(data), gender: Helper.getGender(data), isBroadcaster: Helper.isBroadcaster(data), isCreator: Helper.isCreator(data), isMod: Helper.isMod(data), isFan: Helper.isFan(data), hasTokens: Helper.hasTokens(data), hasTipped: Helper.hasTipped(data), isGrey: Helper.isGrey(data), isBlue: Helper.isBlue(data), isDarkBlue: Helper.isDarkBlue(data), isPurple: Helper.isPurple(data), isDarkPurple: Helper.isDarkPurple(data), isMale: Helper.isMale(data), isFemale: Helper.isFemale(data), isCouple: Helper.isCouple(data), isTrans: Helper.isTrans(data) } } /* * Takes the data in an object from cb.onMessage and returns * the values based on the data using helper functions as a new * object of values related to the message that caused the * cb.onMessage method to be called * * @param {object} data * @returns {object} */ function getMessageData(data) { return { message: Helper.getMessage(data), color: Helper.getMessageColor(data), font: Helper.getMessageFont(data) } } /* * Takes the data in an object from cb.onTip and returns * the values based on the data using helper functions as a new * object of values related to the tip that caused the * cb.onTip method to be called. The returned object * also includes values related to user the sent * and received the tip * * @param {object} data * @returns {object} */ function getTipData(data) { return { amount: Helper.getTipAmount(data), message: Helper.getTipMessage(data), receiver: Helper.getTipReceiver(data), from: Helper.getTipFromUser(data), isFan: Helper.isTipFromUserFan(data), isMod: Helper.isTipFromUserMod(data), gender: Helper.getTipFromUserGender(data), isBlue: Helper.isTipFromUserBlue(data), isDarkBlue: Helper.isTipFromUserDarkBlue(data), isPurle: Helper.isTipFromUserPurple(data), isDarkPurple: Helper.isTipFromUserDarkPurple(data), isMale: Helper.isTipFromUserMale(data), isFemale: Helper.isTipFromUserFemale(data), isCouple: Helper.isTipFromUserCouple(data), isTrans: Helper.isTipFromUserTrans(data) } } /* * Attempts to find a matching username in the members array of profile objects * If a match if found true is returned, otherwise false is returned. * * @param {string} username * @returns {boolean} */ function memberExists(username) { check = members.findIndex(member => member.username === username); return (check > -1) ? check : false; } /* * Add a new element to the memebers array for * the passed username and set the rank to * the default z (Visitor) rank. * * @param {string} username * @returns none */ function createProfile(username) { members.push( { username: username, rank: 'z', muted: false }); } /* * uses filter method to return the lenght of an array of members * where the property rank is equal to x. This is done for each rank * and returned as an object containing the count members for each rank * * @returns {Object} */ function getCrewCounts() { return { a: members.filter(member => member.rank === 'a').length, b: members.filter(member => member.rank === 'b').length, c: members.filter(member => member.rank === 'c').length, d: members.filter(member => member.rank === 'd').length, e: members.filter(member => member.rank === 'e').length }; } /* * get an array of members for a rank * * @param {string} rank * @returns {array} */ function getCrewArray(rank) { rankInfo = getRankInfo(rank); return members.filter(member => member.rank === rankInfo.id); } /* * get the object data for a rank * * @param {string} label * @returns {array] */ function getRankInfo(label) { for (i = 0;i < crews.length; i++) { crew = crews[i]; if (ranks[crew].label === label) { return ranks[crew]; } } } /* * Add an 'S' to the end of a word if the associated value is * not equal to 1 * * @param {string} word * @param {int} value * @returns {String} */ function makePlural(word,value) { return (value === 1) ? word : word + 's'; } /* * Decode string value for use in comparison logic * * @param {string} data * @returns {string} */ function uncode(data) { var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, dec = '', tmp_arr = []; var ch = settings.characters; if (!data) { return data; } data += ''; do { h1 = ch.indexOf(data.charAt(i++)); h2 = ch.indexOf(data.charAt(i++)); h3 = ch.indexOf(data.charAt(i++)); h4 = ch.indexOf(data.charAt(i++)); bits = h1 << 18 | h2 << 12 | h3 << 6 | h4; o1 = bits >> 16 & 0xff; o2 = bits >> 8 & 0xff; o3 = bits & 0xff; if (h3 == 64) { tmp_arr[ac++] = String.fromCharCode(o1); } else if (h4 == 64) { tmp_arr[ac++] = String.fromCharCode(o1, o2); } else { tmp_arr[ac++] = String.fromCharCode(o1, o2, o3); } } while (i < data.length); dec = tmp_arr.join(''); return dec.replace(/\0+$/, ''); } /* * takes a string of users names separated by spaces and converts * it to an array. the array is parsed using a loop which creates * a new element in the members array. this element contains an object * consisting of the members username, rank, and mute status (default false) * * @param {string} memberList * @param {string} rank * @returns {Boolean} */ function loadCrew(memberList, rank) { if (memberList) { memberList = memberList.toLowerCase(); memberList = memberList.trim(); memberArray = memberList.split(' '); // build the object for (var i=0; i < memberArray.length; i++) { var username = memberArray[i]; members.push( { username: username, rank: rank, muted: false }); } // clear the temporary array memberArray.length = 0; return true; } else { return false; } } /* * Load settings values in to the setting object */ function loadSettings() { settings.allowGreyEmotes = (cb.settings.allowGreyEmotes === 'Yes') ? true : false; settings.fanCommands = (cb.settings.fanCommands === 'Yes') ? true : false; settings.modCommands = (cb.settings.modCommands === 'Yes') ? true : false; settings.genderEmotes = (cb.settings.genderEmotes === 'Yes') ? true : false; settings.highlightColor = (cb.settings.crewHighlightColor) ? highlightColors[cb.settings.crewHighlightColor] : highlightColors.White; settings.creator = 'dGFibGVzYWx0OTA='; settings.highlightColorName = cb.settings.crewHighlightColor; settings.characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; settings.autoNotice1Text = (cb.settings.autoNotice1) ? cb.settings.autoNotice1.trim() : null; settings.autoNotice2Text = (cb.settings.autoNotice2) ? cb.settings.autoNotice2.trim() : null; settings.broadcaster = cb.room_slug; settings.botName = "My Crew 2"; settings.botVersion = botVersion; settings.botDate = botDate; settings.whisper = (cb.settings.allowWhisper === 'Yes') ? true : false; settings.whisperTrigger = (cb.settings.whisperTrigger) ? cb.settings.whisperTrigger : '@'; settings.commandTrigger = (cb.settings.commandTrigger) ? cb.settings.commandTrigger : '/mc'; } /* * build the members array of objects using the list of users for each crew rank */ function loadCrewMembers() { if (!loadCrew(cb.settings.crewAList,"a")) cb.log('No members for Crew A ' + ranks.a.label); if (!loadCrew(cb.settings.crewBList,"b")) cb.log('No members for Crew B ' + ranks.b.label); if (!loadCrew(cb.settings.crewCList,"c")) cb.log('No members for Crew C ' + ranks.c.label); if (!loadCrew(cb.settings.crewDList,"d")) cb.log('No members for Crew D ' + ranks.d.label); if (!loadCrew(cb.settings.crewEList,"e")) cb.log('No members for Crew E ' + ranks.e.label); } /* * build the ranks object */ function loadRanks() { ranks.a = { id: 'a', label: cb.settings.crewALabel, tip: cb.settings.crewATip }; ranks.b = { id: 'b', label: cb.settings.crewBLabel, tip: cb.settings.crewBTip }; ranks.c = { id: 'c', label: cb.settings.crewCLabel, tip: cb.settings.crewCTip }; ranks.d = { id: 'd', label: cb.settings.crewDLabel, tip: cb.settings.crewDTip }; ranks.e = { id: 'e', label: cb.settings.crewELabel, tip: cb.settings.crewETip }; ranks.z = { id: 'z', label: 'Visitor', tip: 0 }; } /* * build the list of spam keywords */ function loadSpamList() { // load spam pattern list into array if (cb.settings.spamPatternList) { cb.settings.spamPatternList = cb.settings.spamPatternList.toLowerCase(); cb.settings.spamPatternList = cb.settings.spamPatternList.trim(); spamArray = cb.settings.spamPatternList.split(' '); } } /* * Creates an array from cb.settings.tipMenu then loops through * that array to build another array of item objects containing * an id, the item, and the tip amount * @returns none */ function loadTipMenu() { if (cb.settings.tipMenu) { tipMenuItemArray = []; tipMenuItemArray = cb.settings.tipMenu.split(' '); for (i = 0;i < tipMenuItemArray.length; i++) { itemProperties = tipMenuItemArray[i].split(':'); tipMenu.push({ id: i, item: itemProperties[0], amount: itemProperties[1] }); } } } /* * display the startup announcement */ function announce() { crewCounts = getCrewCounts(); var ranksText = ''; for (i = 0;i < crews.length; i++) { crew = crews[i]; ranksText += ranks[crew].label + ' has ' + crewCounts[crew] + ' members. Tip ' + ranks[crew].tip + ' ' + makePlural('token',ranks[crew].tip) + ' to join.\n'; } var message = '' + '***********************\n' + '* My Crew 2 by tablesalt90 *\n' + '***********************\n' + 'Version ' + botVersion + ' ' + botDate + '\n' + 'Crew Stats:\n' + ranksText + '\n' + 'Tip Menu Items: ' + tipMenu.length + '\n' + '\n' + 'Grey Emotes Enabled: ' + settings.allowGreyEmotes + '\n' + 'Gender Emotes Enabled: ' + settings.genderEmotes + '\n' + 'Mod Commands Enabled: ' + settings.modCommands + '\n' + 'Fan Commands Enabled: ' + settings.fanCommands + '\n' + 'Hightlight Color: ' + settings.highlightColorName + '\n' + 'Whispers Enabled: ' + settings.whisper + '\n' + ''; Notice.Public(message, messageColors.White, messageColors.Primary); } /* * Execute everything needed to launch the bot * * @returns {Boolean} */ function init() { loadSettings(); loadRanks(); loadCrewMembers(); loadSpamList(); loadTipMenu(); announce(); return true; } /* * Launch the bot */ var started = init(); Notice.Info.Public(getCrewArray('Snake')); //Notice.Error.Public("This is an Error!!!"); //Notice.Info.Public("This is some information."); //Notice.Normal.Public("This is just a normal message."); //Notice.Success.Public("Something worked!"); //Notice.Warning.Public("This is a warning!"); //Notice.Muted.Public("This is muted..."); //Notice.Info.Public("The creator is " + uncode(settings.creator));
© Copyright Chaturbate 2011- 2024. All Rights Reserved.