Bots Home
|
Create an App
BBF's Ranked Society
Author:
bbftest
Description
Source Code
Launch Bot
Current Users
Created by:
Bbftest
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Title: Ranked Society + Author: BigBoobiesFan + Based on ideas in the crew-bots of tablesalt90 + Written for paolaturbay_v, but usable for all broadcaster + Version: 1.1 November 11., 2017 + First Version: 1.0 November 4., 2017 + Description: Manage your users as a Ranked Society ** +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Features: Keeps track of all tips Show tip scoreboard (all tips) Announce top X tippers (public) Send tippers lists to self (private) Manage users in groups: Family, Crew, Gang, Nobility, whatever... plus 2 additional Custom Fanclubs, Moderators, Greys, Banned ones Allow Mods to use commands Special user greetings Greetings for group members Emote blocker for grey users Select background colors for group users Automatically add user to group for specific tip amounts and send reminder to model to add them in config 2 custom notifications with selectable time delay Send public room notice Send notice to all mods Send private notice to broadcaster */ /*++++++++++++ + Setup vars ++++++++++++*/ var botVersion = "1.1"; var botDate = "11.11.2017"; var todaysTippers = new Array(); var FriendUsersArray = new Array(); var friendTag=""; var friendColor=""; var Rank1UsersArray = new Array(); var rank1Tag=""; var rank1Tip=0; var rank1Color=""; var Rank2UsersArray = new Array(); var rank2Tag=""; var rank2Tip=0; var rank2Color=""; var Rank3UsersArray = new Array(); var rank3Tag=""; var rank3Tip=0; var rank3Color=""; var Rank4UsersArray = new Array(); var rank4Tag=""; var rank4Color=""; var rank4Tip=0; var Cfc1UsersArray = new Array(); var cfc1Tag=""; var cfc1Color=""; var cfc1Tip=0; var Cfc2UsersArray = new Array(); var cfc2Tag=""; var cfc2Color=""; var cfc2Tip=0; var fanColor=""; var fanTag=""; var modColor=''; var modTag=''; var modelColor=''; var modelTag=''; var BannedUsersArray = new Array(); var HighTipKingName = ""; var highTipKingColor = ""; var highTipKingTip = 500; var highTipKingTag = ""; var tempArray = new Array(); var modelName = cb.room_slug; var msgNotify = ""; var msgPublic = ""; var msgPrivate = ""; var msgModel = ""; var msgMod = ""; var groupColor = "#FFFFFF"; var autoNotice1Text = ""; var autoNotice2Text = ""; var botTrigger = "/rs"; var botTrigger2 = "/bbf"; var modCommands = true; var userGreets = 1; var allowGreyEmotes = false; var advanceSingle = false; var showTips = true; var rank1Tip = 0; var rank2Tip = 0; var rank3Tip = 0; var rank4Tip = 0; var HighTipKingTip = 1000; var societyName = "My Kingdom"; var botMsgBg = '#BDDEDC'; var botAlertBg = '#ff5555'; var botNoteBg = '#99FF66'; var helpMsg=''; // var botGhostBg = '#EDEDED'; /*+++++++++ + Settings +++++++++*/ cb.settings_choices = [ { name: 'societyName', label: '*** YOUR SOCIETY **** **** *** The overall name of your society', type: 'str', minLength: 0, maxLength: 128, required: true, defaultValue: 'My Kingdom' }, { name: 'modelTag', label: 'Your own designation (may be an emote)', type: 'str', minLength: 0, maxLength: 128, required: true, defaultValue: 'Queen' }, { name: 'modelColor', label: 'Highlight color to use for YOURSELF', type: 'choice', choice1: 'White FFFFFF', choice2: 'Aqua 7FFFD4', choice3: 'LtBrown F4A460', choice4: 'Cyan E0FFFF', choice5: 'Gold EEE8AA', choice6: 'Yellow FFF68F', choice7: 'Slate C6E2FF', choice8: 'Pink FFF0F5', choice9: 'Orange FFD39B', choice10: 'Mint BDFCC9', choice11: 'Grey F2F2F2', choice12: 'Plum CD96CD', defaultValue: 'White FFFFFF' }, { name: 'allowGreyEmotes', type: 'choice', label: 'Allow GREY Graphics?', choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, { name: 'autoNotice1', label: 'Notification Message 1, use text and emotes', type: 'str', minLength: 0, maxLength: 512, required: false, defaultValue: '' }, { name: 'autoNotice1Interval', label: 'Show Notification 2 Announce the Ranks Every x Minutes', type: 'int', minValue: 0, defaultValue: 5 }, { name: 'autoNotice2', label: 'Notification Message 2, use text and emotes', type: 'str', minLength: 0, maxLength: 512, required: false, defaultValue: '' }, { name: 'autoNotice2Interval', label: 'Show Notification 2 Every x Minutes', type: 'int', minValue: 0, defaultValue: 5 }, { name: 'autoAnnounceInterval', label: 'Announce the Ranks Every x Minutes', type: 'int', minValue: 0, defaultValue: 8 }, { name: 'modCommands', type: 'choice', label: 'Allow Moderators to use commands?', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'userGreets', type: 'choice', label: 'Make special user announcements in public when Society Member enter?', choice1: '0: No One', choice2: '1: Society Members', choice3: '2: Recent Tippers (dark blue+)', choice4: '3: Token Owners (light blue)', defaultValue: '1: Society Members' }, { name: 'showTips', type: 'choice', label: 'Show Users Tip Amount in title?', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'rankAdvance', label: 'Do users need a single or accumulated tips to advance in Rank', type: 'choice', choice1: 'Accumulated', choice2: 'Single', defaultValue: 'Accumulated' }, { name: 'friendTag', label: '*** FRIENDS *** *** *** *** Tag for Friends (non-tippers) users', type: 'str', minLength: 0, maxLength: 25, required: true, defaultValue: 'Ally' }, { name: 'friendList', label: 'List of Friend users, separated by space (their CB usernames exactly)', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'friendColor', label: 'Highlight color to use for Friend users', type: 'choice', choice1: 'White FFFFFF', choice2: 'Aqua 7FFFD4', choice3: 'LtBrown F4A460', choice4: 'Cyan E0FFFF', choice5: 'Gold EEE8AA', choice6: 'Yellow FFF68F', choice7: 'Slate C6E2FF', choice8: 'Pink FFF0F5', choice9: 'Orange FFD39B', choice10: 'Mint BDFCC9', choice11: 'Grey F2F2F2', choice12: 'Plum CD96CD', defaultValue: 'White FFFFFF' }, { name: 'rank1Tag', label: '*** RANK 1 *** *** **** **** *** *** *** Tag for users of Rank 1', type: 'str', minLength: 0, maxLength: 25, required: true, defaultValue: 'Lover' }, { name: 'rank1List', label: 'List of users of Rank 1, separated by space (their CB usernames exactly)', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'rank1Tip', label: 'Tips needed for getting into this Rank', type: 'int', minValue: 0, required: false, defaultValue: '111' }, { name: 'rank1Color', label: 'Highlight color to use for rank 1 users', type: 'choice', choice1: 'White FFFFFF', choice2: 'Aqua 7FFFD4', choice3: 'LtBrown F4A460', choice4: 'Cyan E0FFFF', choice5: 'Gold EEE8AA', choice6: 'Yellow FFF68F', choice7: 'Slate C6E2FF', choice8: 'Pink FFF0F5', choice9: 'Orange FFD39B', choice10: 'Mint BDFCC9', choice11: 'Grey F2F2F2', choice12: 'Plum CD96CD', defaultValue: 'White FFFFFF' }, { name: 'rank2Tag', label: '*** RANK 2 *** *** **** *** **** *** *** Tag for users of Rank 2', type: 'str', minLength: 0, maxLength: 25, required: true, defaultValue: 'Noble' }, { name: 'rank2List', label: 'List of rank 2 users, separated by space (their CB usernames exactly)', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'rank2Tip', label: 'Tips needed for getting into this Rank', type: 'int', minValue:0, required: false, defaultValue: '333' }, { name: 'rank2Color', label: 'Highlight color to use for rank2 users', type: 'choice', choice1: 'White FFFFFF', choice2: 'Aqua 7FFFD4', choice3: 'LtBrown F4A460', choice4: 'Cyan E0FFFF', choice5: 'Gold EEE8AA', choice6: 'Yellow FFF68F', choice7: 'Slate C6E2FF', choice8: 'Pink FFF0F5', choice9: 'Orange FFD39B', choice10: 'Mint BDFCC9', choice11: 'Grey F2F2F2', choice12: 'Plum CD96CD', defaultValue: 'White FFFFFF' }, { name: 'rank3Tag', label: '*** RANK 3 *** *** **** *** **** *** *** Tag for users of Rank 3', type: 'str', minLength: 0, maxLength: 25, required: true, defaultValue: 'Prince' }, { name: 'rank3List', label: 'List of rank3 users, separated by space (their CB usernames exactly)', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'rank3Tip', label: 'Tips needed for getting into this Rank', type: 'int', minValue:0, required: false, defaultValue: '666' }, { name: 'rank3Color', label: 'Highlight color to use for Rank3 users', type: 'choice', choice1: 'White FFFFFF', choice2: 'Aqua 7FFFD4', choice3: 'LtBrown F4A460', choice4: 'Cyan E0FFFF', choice5: 'Gold EEE8AA', choice6: 'Yellow FFF68F', choice7: 'Slate C6E2FF', choice8: 'Pink FFF0F5', choice9: 'Orange FFD39B', choice10: 'Mint BDFCC9', choice11: 'Grey F2F2F2', choice12: 'Plum CD96CD', defaultValue: 'White FFFFFF' }, { name: 'rank4Tag', label: '*** RANK 4 *** *** **** *** **** *** *** Tag for users of Rank 4', type: 'str', minLength: 0, maxLength: 25, required: true, defaultValue: 'King' }, { name: 'rank4List', label: 'List of Rank4 users, separated by space (their CB usernames exactly)', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'rank4Tip', label: 'Tips needed for getting into this Rank', type: 'int', minValue:0, required: false, defaultValue: '1111' }, { name: 'rank4Color', label: 'Highlight color to use for Rank4 users', type: 'choice', choice1: 'White FFFFFF', choice2: 'Aqua 7FFFD4', choice3: 'LtBrown F4A460', choice4: 'Cyan E0FFFF', choice5: 'Gold EEE8AA', choice6: 'Yellow FFF68F', choice7: 'Slate C6E2FF', choice8: 'Pink FFF0F5', choice9: 'Orange FFD39B', choice10: 'Mint BDFCC9', choice11: 'Grey F2F2F2', choice12: 'Plum CD96CD', defaultValue: 'White FFFFFF' }, { name: 'highTipKingTag', label: '*** High Tip King *** *** *** Tag for your highest tipper so far', type: 'str', minLength: 0, maxLength: 25, required: true, defaultValue: 'Emperor' }, { name: 'highTipKingName', label: 'Name of the High Tip King (the CB usernames exactly)', type: 'str', minLength: 0, maxLength: 40, required: false, defaultValue: '' }, { name: 'highTipKingTip', label: 'Tips he tipped in one session', type: 'int', minValue:0, required: false, defaultValue: '1000' }, { name: 'autoAnnounceHTK', label: 'Show Name & Tip of the HighTipKing Every x Minutes', type: 'int', minValue: 0, defaultValue: 10 }, { name: 'highTipKingColor', label: 'Highlight color to use for Rank4 users', type: 'choice', choice1: 'White FFFFFF', choice2: 'Aqua 7FFFD4', choice3: 'LtBrown F4A460', choice4: 'Cyan E0FFFF', choice5: 'Gold EEE8AA', choice6: 'Yellow FFF68F', choice7: 'Slate C6E2FF', choice8: 'Pink FFF0F5', choice9: 'Orange FFD39B', choice10: 'Mint BDFCC9', choice11: 'Grey F2F2F2', choice12: 'Plum CD96CD', defaultValue: 'White FFFFFF' }, { name: 'fanTag', label: '*** CB FanClub *** *** *** *** ** Tag for the CB FanClub Members', type: 'str', minLength: 0, maxLength: 25, required: true, defaultValue: 'High Court' }, { name: 'fanColor', label: 'Highlight color to use for CB FanClub Members', type: 'choice', choice1: 'White FFFFFF', choice2: 'Aqua 7FFFD4', choice3: 'LtBrown F4A460', choice4: 'Cyan E0FFFF', choice5: 'Gold EEE8AA', choice6: 'Yellow FFF68F', choice7: 'Slate C6E2FF', choice8: 'Pink FFF0F5', choice9: 'Orange FFD39B', choice10: 'Mint BDFCC9', choice11: 'Grey F2F2F2', choice12: 'Plum CD96CD', defaultValue: 'White FFFFFF' }, { name: 'cfc1Tag', label: '*** Custom Fan Club 1 *** **** *** Tag for the 1. Custom FanClub', type: 'str', minLength: 0, maxLength: 25, required: true, defaultValue: 'Court' }, { name: 'cfc1List', label: 'List of members of the 1. Custom FanClub, separated by space (their CB usernames exactly)', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'cfc1Tip', label: 'Single Tip needed for getting into Custom Fan Club 1', type: 'int', defaultValue: '100' }, { name: 'cfc1Color', label: 'Highlight color to use for members of the 1. Custom FanClub', type: 'choice', choice1: 'White FFFFFF', choice2: 'Aqua 7FFFD4', choice3: 'LtBrown F4A460', choice4: 'Cyan E0FFFF', choice5: 'Gold EEE8AA', choice6: 'Yellow FFF68F', choice7: 'Slate C6E2FF', choice8: 'Pink FFF0F5', choice9: 'Orange FFD39B', choice10: 'Mint BDFCC9', choice11: 'Grey F2F2F2', choice12: 'Plum CD96CD', defaultValue: 'White FFFFFF' }, { name: 'cfc2Tag', label: '*** Custom Fan Club 2 *** **** *** Tag for the 2. Custom FanClub', type: 'str', minLength: 0, maxLength: 25, required: true, defaultValue: 'Clergy' }, { name: 'cfc2List', label: 'List of members of the 2. Custom FanClub, separated by space (their CB usernames exactly)', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, { name: 'cfc2Tip', label: 'Single Tip needed for getting into Custom Fan Club 2', type: 'int', defaultValue: '200' }, { name: 'cfc2Color', label: 'Highlight color to use for members of the 2. Custom FanClub', type: 'choice', choice1: 'White FFFFFF', choice2: 'Aqua 7FFFD4', choice3: 'LtBrown F4A460', choice4: 'Cyan E0FFFF', choice5: 'Gold EEE8AA', choice6: 'Yellow FFF68F', choice7: 'Slate C6E2FF', choice8: 'Pink FFF0F5', choice9: 'Orange FFD39B', choice10: 'Mint BDFCC9', choice11: 'Grey F2F2F2', choice12: 'Plum CD96CD', defaultValue: 'White FFFFFF' }, { name: 'modTag', label: '*** MODERATOR *** *** *** *** *** *** *** Tag for the Moderators', type: 'str', minLength: 0, maxLength: 25, required: true, defaultValue: 'Paladin' }, { name: 'modColor', label: 'Highlight color to use for Moderators', type: 'choice', choice1: 'White FFFFFF', choice2: 'Aqua 7FFFD4', choice3: 'LtBrown F4A460', choice4: 'Cyan E0FFFF', choice5: 'Gold EEE8AA', choice6: 'Yellow FFF68F', choice7: 'Slate C6E2FF', choice8: 'Pink FFF0F5', choice9: 'Orange FFD39B', choice10: 'Mint BDFCC9', choice11: 'Grey F2F2F2', choice12: 'Plum CD96CD', defaultValue: 'White FFFFFF' }, { name: 'personaNonGrata', label: '*** Persona Non Grata *** *** List of permanently silenced Users', type: 'str', minLength: 0, maxLength: 10240, required: false, defaultValue: '' }, ]; /*+++++++++++++++++++++++ + handle tips from users ++++++++++++++++++++++*/ var totalTipped = 0; cb.onTip(function (tip) { var divStr = ""; var msgText = ""; var msgNotify = ""; var tipAmount = parseInt(tip['amount']); var name = tip['from_user']; msgModel=''; msgPublic=''; var isBanned = userInArray(BannedUsersArray, name); if (isBanned){ if (todaysTippers[name]) { todaysTippers[name].tips = 0; } }else{ // is user in tipper array? if (!todaysTippers[name]) { //nope add them todaysTippers[name] = {username: name, tips: 0}; } if (!todaysTippers[name].tips) { todaysTippers[name].tips = 0; } todaysTippers[name].tips += tipAmount; if(advanceSingle){ switch(tipAmount){ case rank1Tip: if (!userInArray(Rank4UsersArray, name) && !userInArray(Rank3UsersArray, name) && !userInArray(Rank2UsersArray, name)) { result = addUser(Rank1UsersArray, name, true); if (result instanceof Array) { Rank4UsersArray = result; msgPublic += ' ' + name + ' is now ' + modelName + '\'s ' + cb.settings.rank1Tag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' to list of '+cb.settings.rank1Tag+'\'s in the bot config!'; } else { if (result == 'duplicate') { msgPublic += ' ' + name + ' is already ' + modelName + '\'s ' + cb.settings.rank1Tag + '!!! Thank you for your tip!';; } else { msgPublic += ' ' + 'Failed to add user ' + name + ' to ' + cb.settings.rank1Tag + '. Something went wrong!'; } } } break; case rank2Tip: if (!userInArray(Rank4UsersArray, name) && !userInArray(Rank3UsersArray, name)) { result = addUser(Rank2UsersArray, name, true); if (result instanceof Array) { Rank4UsersArray = result; msgPublic += ' ' + name + ' is now ' + modelName + '\'s ' + cb.settings.rank2Tag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' to list of '+cb.settings.rank2Tag+'\'s in the bot config!'; } else { if (result == 'duplicate') { msgPublic += ' ' + name + ' is already ' + modelName + '\'s ' + cb.settings.rank2Tag + '!!! Thank you for your tip!';; } else { msgPublic += ' ' + 'Failed to add user ' + name + ' to ' + cb.settings.rank2Tag + '. Something went wrong!'; } } } else { msgPublic += ' ' + name + ' already has a higher rank than ' + cb.settings.rank2Tag + '! Status not changed. Thank you for your tip!'; } break; case rank3Tip: if (!userInArray(Rank4UsersArray, name)) { result = addUser(Rank3UsersArray, name, true); if (result instanceof Array) { Rank4UsersArray = result; msgPublic += ' ' + name + ' is now ' + modelName + '\'s ' + cb.settings.rank3Tag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' to list of '+cb.settings.rank3Tag+'\'s in the bot config!'; } else { if (result == 'duplicate') { msgPublic += ' ' + name + ' is already ' + modelName + '\'s ' + cb.settings.rank3Tag + '!!! Thank you for your tip!';; } else { msgPublic += ' ' + 'Failed to add user ' + name + ' to ' + cb.settings.rank3Tag + '. Something went wrong!'; } } } else { msgPublic += ' ' + name + ' already has a higher rank than ' + cb.settings.rank3Tag + '! Status not changed. Thank you for your tip!'; } break; case rank4Tip: if (!userInArray(Rank4UsersArray, name)) { result = addUser(Rank4UsersArray, name, true); if (result instanceof Array) { Rank4UsersArray = result; msgPublic += ' ' + name + ' is now ' + modelName + '\'s ' + cb.settings.rank4Tag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' to list of '+cb.settings.rank4Tag+'\'s in the bot config!'; } else { if (result == 'duplicate') { msgPublic += ' ' + name + ' is already ' + modelName + '\'s ' + cb.settings.rank4Tag + '!!! Thank you for your tip!';; } else { msgPublic += ' ' + 'Failed to add user ' + name + ' to ' + cb.settings.rank4Tag + '. Something went wrong!'; } } } // else { // msgPublic += ' ' + name + ' already has a higher rank than ' + cb.settings.rank4Tag + '! Status not changed. Thank you for your tip!'; // } break; default: msgPublic += ' ' + 'Thank you ' + name + ' for your tip of ' + tipAmount; if (tipAmount == 1) { msgPublic += ' token!'; } else { msgPublic += ' tokens!'; } break; } if(todaysTippers[name].tips > highTipKingTip && highTipKingTip > 0){ if (HighTipKingName != name) { if (HighTipKingName!=''){ msgPublic += ' ' + 'Oh happy day!!! ' + name + ' dethroned '+HighTipKingName+' and is now ' + modelName + '\'s new ' + highTipKingTag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' and his tip as High Tip King in the bot config!'; if (!userInArray(Rank4UsersArray, HighTipKingName)) { result = addUser(Rank4UsersArray, HighTipKingName, true); if (result instanceof Array) { Rank4UsersArray = result; msgPublic += ' ' + '\n'+HighTipKingName + ' is now ' + modelName + '\'s ' + cb.settings.rank4Tag +'!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + HighTipKingName + ' to list of '+cb.settings.rank4Tag+'\'s in the bot config!'; } } HighTipKingName = name; highTipKingTip = todaysTippers[name].tips; }else{ msgPublic += ' ' + 'Oh happy day!!! ' + name + ' is now ' + modelName + '\'s ' + highTipKingTag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' and his tip as High Tip King in the bot config!'; } HighTipKingName = name; highTipKingTip = todaysTippers[name].tips; delUserFromAll(name, false); } else { msgPublic += ' ' + name + ' is already ' + modelName + '\'s ' + highTipKingTag + ' and proved himself worthy of that title!!!'; //HighTipKingName = name; highTipKingTip = todaysTippers[name].tips; } } } else{ if(todaysTippers[name].tips > highTipKingTip && highTipKingTip > 0){ if (HighTipKingName != name) { if (HighTipKingName != '') { msgPublic += ' ' + 'Oh happy day!!! ' + name + ' dethroned '+HighTipKingName+' and is now ' + modelName + '\'s new ' + highTipKingTag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' and his tip as High Tip King in the bot config!'; if (!userInArray(Rank4UsersArray, name)) { result = addUser(Rank4UsersArray, HighTipKingName, true); if (result instanceof Array) { Rank4UsersArray = result; msgPublic += ' ' + '\n'+HighTipKingName + ' is now ' + modelName + '\'s ' + cb.settings.rank4Tag +'!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + HighTipKingName + ' to list of '+cb.settings.rank4Tag+'\'s in the bot config!'; } } } else { msgPublic += ' ' + 'Oh happy day!!! ' + name + ' is now ' + modelName + '\'s ' + cb.settings.highTipKingTag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' and his tip as High Tip King in the bot config!'; } HighTipKingName = name; highTipKingTip = todaysTippers[name].tips; delUserFromAll(name, false); } else { msgPublic += ' ' + name + ' is already ' + modelName + '\'s ' + cb.settings.highTipKingTag + ' and proved himself worthy of that title!!!'; highTipKingTip = todaysTippers[name].tips; } } else if(todaysTippers[name].tips >= rank4Tip && rank4Tip > 0){ if (!userInArray(Rank4UsersArray, name)) { result = addUser(Rank4UsersArray, name, true); if (result instanceof Array) { Rank4UsersArray = result; msgPublic += ' ' + name + ' is now ' + modelName + '\'s ' + cb.settings.rank4Tag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' to list of '+cb.settings.rank4Tag+'\'s in the bot config!'; } else { if (result == 'duplicate') { msgPublic += ' ' + name + ' is already ' + modelName + '\'s ' + cb.settings.rank4Tag + '!!! Thank you for your tip!';; } else { msgPublic += ' ' + 'Failed to add user ' + name + ' to ' + cb.settings.rank4Tag + '. Something went wrong!'; } } } } else if (todaysTippers[name].tips >= rank3Tip && rank3Tip > 0){ //deblog(name+' tipped '+todaysTippers[name].tips+'. try to advance'); if (!userInArray(Rank3UsersArray, name)) { result = addUser(Rank3UsersArray, name, true); if (result instanceof Array) { Rank3UsersArray = result; msgPublic += ' ' + name + ' is now ' + modelName + '\'s ' + cb.settings.rank3Tag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' to list of '+cb.settings.rank3Tag+'\'s in the bot config!'; } else { if (result == 'duplicate') { msgPublic += ' ' + name + ' is already ' + modelName + '\'s ' + cb.settings.rank3Tag + '!!! Thank you for your tip!';; } else { msgPublic += ' ' + 'Failed to add user ' + name + ' to ' + cb.settings.rank3Tag + '. Something went wrong!'; } } } } else if (todaysTippers[name].tips >= rank2Tip && rank2Tip > 0){ //deblog(name+' tipped '+todaysTippers[name].tips+'. try to advance'); if (!userInArray(Rank2UsersArray, name)) { result = addUser(Rank2UsersArray, name, true); if (result instanceof Array) { Rank2UsersArray = result; msgPublic += ' ' + name + ' is now ' + modelName + '\'s ' + cb.settings.rank2Tag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' to list of '+cb.settings.rank2Tag+'\'s in the bot config!'; } else { if (result == 'duplicate') { msgPublic += ' ' + name + ' is already ' + modelName + '\'s ' + cb.settings.rank2Tag + '!!! Thank you for your tip!';; } else { msgPublic += ' ' + 'Failed to add user ' + name + ' to ' + cb.settings.rank3Tag + '. Something went wrong!'; } } } } else if (todaysTippers[name].tips >= rank1Tip && rank1Tip > 0){ //deblog(name+' tipped '+todaysTippers[name].tips+'. try to advance'); if (!userInArray(Rank1UsersArray, name)) { result = addUser(Rank1UsersArray, name, true); if (result instanceof Array) { Rank1UsersArray = result; msgPublic += ' ' + name + ' is now ' + modelName + '\'s ' + cb.settings.rank1Tag +'!!! Thank you for your tip!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + name + ' to list of '+cb.settings.rank1Tag+'\'s in the bot config!'; } else { if (result == 'duplicate') { msgPublic += ' ' + name + ' is already ' + modelName + '\'s ' + cb.settings.rank2Tag + '!!! Thank you for your tip!';; } else { msgPublic += ' ' + 'Failed to add user ' + name + ' to ' + cb.settings.rank3Tag + '. Something went wrong!'; } } } }else{ msgPublic += ' ' + 'Thank you ' + name + ' for your tip of ' + tipAmount; if (tipAmount == 1) { msgPublic += ' token!'; } else { msgPublic += ' tokens!'; } } } // Custom FanClubs if(tipAmount === cfc1Tip){ //deblog(name+' tipped '+tipAmount+' to become a member of the '+ cfc1Tag); if (!userInArray(Cfc1UsersArray, name)) { result = addUser(Cfc1UsersArray, name, false); if (result instanceof Array) { Cfc1UsersArray = result; msgPublic += ' ' + name + ' is now a member of ' + modelName + '\'s ' + cfc1Tag +'!!!'; msgModel += modelName + ', don\'t forget to add ' + name + ' to list of'+cfc1Tag+'\'s in the bot config!'; } else { if (result == 'duplicate') { msgPublic += name + ' is already member of ' + modelName + '\'s ' + cfc1Tag + '!!!'; } else { msgPublic += 'Failed to add user ' + name + ' to ' + cfc1Tag + '. Something went wrong!'; } } } } if(tipAmount === cfc2Tip){ //deblog(name+' tipped '+tipAmount+' to become a member of the '+ cfc2Tag); if (!userInArray(Cfc2UsersArray, name)) { result = addUser(Cfc2UsersArray, name, false); if (result instanceof Array) { Cfc2UsersArray = result; msgPublic += ' ' + name + ' is now a member of ' + modelName + '\'s ' + cfc2Tag +'!!!'; msgModel += modelName + ', don\'t forget to add ' + name + ' to list of'+cfc2Tag+'\'s in the bot config!'; } else { if (result == 'duplicate') { msgPublic += name + ' is already member of ' + modelName + '\'s ' + cfc2Tag + '!!!'; } else { msgPublic += 'Failed to add user ' + name + ' to ' + cfc2Tag + '. Something went wrong!'; } } } } // Output any public notices or command results if (msgPublic!='') { sendPublic(msgPublic); msgPublic = ""; } // Output any messages to the model if (msgModel!='') { sendModel(msgModel); msgModel = ""; } } }); /*+++++++++++++++++++++++ * user entrance messages ++++++++++++++++++++++*/ cb.onEnter(function(user) { var nameFound = false; var greeting = ''; var name = user['user']; var isMod = user['is_mod']; var isFan = user['in_fanclub'] || userInArray (Rank1UsersArray, user['user']) || userInArray (Rank2UsersArray, user['user']) || userInArray (Rank3UsersArray, user['user']) || userInArray (Rank4UsersArray, user['user']) || userInArray (FriendUsersArray, user['user']) || userInArray (Cfc1UsersArray, user['user']) || userInArray (Cfc2UsersArray, user['user']) || HighTipKingName == name; var isBBF = (name == 'bigboobiesfan'); var isModel = (name == cb.room_slug); var hasTokens = user['has_tokens']; var hasTipped = user['tipped_recently']; var isGrey = !(hasTokens || isMod || isModel || isFan); var isBanned = userInArray(BannedUsersArray, name); if (isBanned) { // show notice if user is permanently silenced cb.sendNotice(name + ' is back, but permanently silenced! Maybe ban him from your room!',modelName,botAlertBg,'','bold'); } else { if (isMod || isModel){ cb.sendNotice(announceBot(true),name, botMsgBg,'','bold'); } else { cb.sendNotice(announceBot(false),name, botMsgBg,'','bold'); } if (userGreets>0) { if (HighTipKingName == name){ cb.sendNotice('All hail ' +highTipKingTag+ ' ' + user['user'] + '! Welcome to '+societyName+'!','',highTipKingColor,'','bold'); } else if (isMod){ cb.sendNotice('Hail ' +modTag+ ' ' + user['user'] + ', reporting for duty to '+societyName+'!','',modColor,'DC0000','bold'); } else if ( userInArray (Rank4UsersArray, user['user']) ) { cb.sendNotice('Welcome ' +rank4Tag+ ' ' + user['user'] + ' to '+societyName+'!','',rank1Color,'','bold'); } else if ( userInArray (Rank3UsersArray, user['user']) ) { cb.sendNotice('Welcome ' +rank3Tag+ ' ' + user['user'] + ' to '+societyName+'!','',friendColor,'','bold'); } else if (userInArray(Rank2UsersArray, user['user'])) { cb.sendNotice('Welcome ' +rank2Tag+ ' ' + user['user'] + ' to '+societyName+'!','',rank2Color,'','bold'); } else if (userInArray(Rank1UsersArray, user['user'])) { cb.sendNotice('Welcome ' +rank1Tag+ ' ' + user['user'] + ' to '+societyName+'!','',rank3Color,'','bold'); } else if (user['in_fanclub']) { cb.sendNotice('Welcome ' +fanTag+ ' member ' + user['user'] + ' to '+societyName+'!','',fanColor,'','bold'); } else if (userInArray(Cfc1UsersArray, user['user'])) { cb.sendNotice('Welcome ' +cfc1Tag+ ' member ' + user['user'] + ' to '+societyName+'!','',cfc1Color,'','bold'); } else if (userInArray(Cfc2UsersArray, user['user'])) { cb.sendNotice('Welcome ' +cfc2Tag+ ' member' + user['user'] + ' to '+societyName+'!','',cfc2Color,'','bold'); } else if (userInArray(FriendUsersArray, user['user'])) { cb.sendNotice('Welcome ' +friendTag+ ' ' + user['user'] + ' to '+societyName+'!','',friendColor,'','bold'); } else { if (userGreets > 1 && hasTipped){ cb.sendNotice('Welcome ' + name + ' to '+societyName+'!','','','','bold'); }else if (userGreets > 2 && (hasTipped||hasTokens)){ cb.sendNotice('Welcome ' + name + ' to '+societyName+'!','','','','bold'); }else{ cb.sendNotice('Welcome ' + name + ' to '+societyName+'!',name,'','','bold'); } } }else{ cb.sendNotice('Welcome ' + name + ' to '+societyName+'!',name,'','','bold'); } if (isMod) { cb.sendNotice(modWelcome(user['user']),user['user'],botAlertBg,'','bold'); } else { if (!allowGreyEmotes && isGrey) { cb.sendNotice('\nYou don\'t have any tokens. Use of emoticons for users without tokens and not part of the society is not allowed at this time.\n\n\n',user['user'],botAlertBg,'','bold'); } } } }); /*+++++++++++++++++++++++++++ + handle messages from users +++++++++++++++++++++++++++*/ cb.onMessage(function(message) { var msg = message['m']; var rankTag = ''; var clubTag = ''; var name = message['user']; var isMod = message['is_mod']; var isFan = message['in_fanclub']; var isBBF = (name == 'bigboobiesfan'); var isModel = (name == cb.room_slug); var hasTokens = message['has_tokens']; var hasTipped = message['tipped_recently']; var isGrey = !(hasTokens || isMod || isModel || isFan); var divStr = ""; var userArray = new Array(); var userList = ""; var showOutput = true; var isInGroup = false; var isBanned = userInArray(BannedUsersArray, name); if (isBanned && !isBBF) { message['X-Spam'] = true; } else{ // if user is in a group, add the group tag to their message // and change the background color if ( HighTipKingName == name ) { message['background'] = highTipKingColor; rankTag = highTipKingTag; // groupColor = highTipKingColor; isInGroup = true; } else if ( userInArray (Rank4UsersArray, name) ) { message['background'] = rank4Color; rankTag = rank4Tag; // groupColor = rank4Color; isInGroup = true; } else if ( userInArray (Rank3UsersArray, name) ) { message['background'] = friendColor; rankTag = rank3Tag; // groupColor = friendColor; isInGroup = true; } else if (userInArray(Rank2UsersArray, name)) { message['background'] = rank2Color; rankTag = rank2Tag; // groupColor = rank2Color; isInGroup = true; } else if (userInArray(Rank1UsersArray, name)) { message['background'] = rank1Color; rankTag = rank1Tag; // groupColor = rank1Color; isInGroup = true; } else if (userInArray(FriendUsersArray, name)) { message['background'] = friendColor; rankTag = friendTag; // groupColor = friendColor; isInGroup = true; } if (isMod){ message['background'] = modColor; // deblog('messageColor='+message['c']); message['c'] = '#DC0000'; // deblog('messageColor='+message['c']); // groupColor = modColor; isInGroup = true; } if (modelName==name){ message['background'] = modelColor; // deblog('messageColor='+message['c']); // message['c'] = '#DC5500'; // deblog('messageColor='+message['c']); // groupColor = modelColor; isInGroup = true; } else if (userInArray(Cfc2UsersArray, name)) { message['background'] = cfc2Color; // clubTag = cfc2Tag; /* groupColor = cfc2Color; */ isInGroup = true; } else if (userInArray(Cfc1UsersArray, name)) { message['background'] = cfc1Color; // clubTag = cfc1Tag; // groupColor = cfc1Color; isInGroup = true; } else if (isFan) { message['background'] = fanColor; // clubTag = fanTag; // groupColor = fanColor; isInGroup = true; } // handle commands if ( isModel || (isMod && (modCommands === true)) || isBBF ) { var activeBotTrigger = botTrigger; if (msg.indexOf(botTrigger2) > -1) { activeBotTrigger = botTrigger2; } if ((msg.indexOf(botTrigger) > -1) || (msg.indexOf(botTrigger2) > -1)) { //deblog('command handling'); msgCommand = getParam(msg,' ',1); msgParam1 = getParam(msg,' ',2); msgParam2 = getParam(msg,' ',3); msgParam3 = getParam(msg,' ',4); var regexCommandSplit = '^' + activeBotTrigger + ' (\\S+)(?:\\b\\s*)(.*)?'; var regexListSplit = /[,\s]+/; var reCmdSplit = new RegExp(regexCommandSplit); var cmdSplit = msg.match(reCmdSplit); var cmd; var cmdval; var cmdValArray; if(!msgCommand){ msgCommand=''; } switch(msgCommand.toLowerCase()) { case 'help': case 'h': message['X-Spam'] = true; divStr = makeDiv('_',40,40); msgPrivate += ' ' + divStr + '\nRANKED SOCIETY Bot ver ' + botVersion + '\nCreated by BigBoobiesFan\n' + divStr + '\n'; msgPrivate += helpMsg + '\n' + divStr; break; case 'tips': case 't': message['X-Spam'] = true; if (!msgParam1) { msgParam1 = 0; } if (msgParam1==0){ msgPrivate += ' ' + getTippers(msgParam1); } else { msgPublic += ' ' + getTippers(msgParam1); } break; // case 'notice': // case 'note': // case 'n': // case 'pm': // message['X-Spam'] = true; // if ( cmdSplit && msgParam2) { // cmdval = cmdSplit[3]; // if ( cmdval != null ) { // cmdval = cmdval.replace(/^\s+|\s+$/g,''); // cmdval = '*** Private notice from ' + name + ': ' + cmdval + ' ***' // cb.sendNotice(cmdval, msgParam1, botMsgBg,'','bold'); // } // } // break; case 'modnote': case 'modn': case 'bcnote': case 'bcn': case 'bn': case 'mn': message['X-Spam'] = true; if ( cmdSplit ) { cmdval = cmdSplit[2]; if ( cmdval != null ) { cmdval = cmdval.replace(/^\s+|\s+$/g,''); } // contains message. who do we send it to? switch(msgCommand.toLowerCase()) { case 'bcnote': case 'bn': msgModel += ' ' + '*** Private notice from ' + name + ': ' + cmdval + ' ***'; msgPrivate += ' ' + 'Your message was sent to ' + modelName + '...'; break; case 'modnote': case 'modn': case 'mn': msgMod += ' ' + '*** Moderator notice from ' + name + ': ' + cmdval + ' ***'; msgPrivate += ' ' + 'Your message was sent to the moderators...'; break; } } break; case 'view': case 'show': case 'list': case 'l': // which user array do we need to display? var showOutput = true; message['X-Spam'] = true; var listedGroup=""; if (msgParam1){ switch(msgParam1.toLowerCase()) { case "f": case "rf": case "friend": case "fr": case "friends": case friendTag: case friendTag+'s': userArray=FriendUsersArray; listedGroup=friendTag; break; case "1": case "r1": case "rank1": case rank1Tag: case rank1Tag+'s': userArray=Rank1UsersArray; listedGroup=rank1Tag; break; case "2": case "r2": case "rank2": case rank2Tag: case rank2Tag+'s': userArray=Rank2UsersArray; listedGroup=rank2Tag; break; case "3": case "r3": case "rank3": case rank3Tag: case rank3Tag+'s': userArray=Rank3UsersArray; listedGroup=rank3Tag; break; case "4": case "r4": case "rank4": case rank4Tag: case rank4Tag+'s': userArray=Rank4UsersArray; listedGroup=rank4Tag; break; case "fc1": case "fanclub1": case cfc1Tag: case cfc1Tag+'s': userArray=Cfc1UsersArray; listedGroup=cfc1Tag+' member'; break; case "fc2": case "fanclub2": case cfc2Tag: case cfc2Tag+'s': userArray=Cfc2UsersArray; listedGroup=cfc2Tag+' member'; break; case "htk": userArray={HighTipKingName}; listedGroup=highTipKingTag; break; default: showOutput = false; msgPrivate += ' ' + "You must provide a group name to list: rf r1 r2 r3 r4 fc1 fc2 htk"; break; } }else{ showOutput = false; msgPrivate += ' ' + "You must provide a group name to list: rf r1 r2 r3 r4 fc1 fc2 htk"; } if (showOutput === true) { userList = getUsers(userArray); // arrayProperName = msgParam1.charAt(0).toUpperCase() + msgParam1.substring(1); if (userList.length > 1) { divStr = makeDiv('_',userList.length,40); msgPrivate += ' ' + divStr + '\n' + listedGroup + 's:\n'; msgPrivate += userList; msgPrivate += '\n' + divStr; } else { msgPrivate += ' ' + 'No ' + listedGroup + 's found!'; } } break; case 'showall': case 'listall': case 'export': case 'x': message['X-Spam'] = true; var exportGroups=getGroupsExport(); divStr = makeDiv('_',userList.length,40); msgPrivate += ' ' + divStr + '\nExport of all Groups for Copy/Paste:\n'; msgPrivate += exportGroups; msgPrivate += '\n' + divStr; break; case 'ban': case 'b': case 'banuser': case 'kick': case 'kickuser': case 'silence': message['X-Spam'] = true; userName=msgParam1; if(userName){ userName = userName.toLowerCase(); delUserFromAll(userName, true); // add userName to array var userArrayLength = userArray.length; BannedUsersArray[BannedUsersArray.length] = userName; // check to see that addition of user worked usernameBanned = userInArray(BannedUsersArray, userName); if (usernameBanned === true) { //deblog(userName+' got permanently silenced from '+name); msgPublic += ' ' + '>>> '+userName+' got permanently silenced from '+name + '!'; msgModel += ' ' + modelName + ', don\'t forget to add ' + msgParam1 + ' to the Banned Users list in the bot config!'; } else { msgPrivate='Banning '+ userName + 'failed'; // failed, return failed } } break; case 'unban': case 'ub': if (isBBF || isModel || isMod) { var validSyntax = true; result = delUser(BannedUsersArray, msgParam1); if (result instanceof Array) { BannedUsersArray = result; msgPublic += ' ' + name + ' unbanned ' + msgParam1 + '!'; msgModel += ' ' + modelName + ', don\'t forget to remove ' + msgParam1 + ' from the Banned Users list in the bot config!'; } else { if (result == 'notfound') { msgPrivate += ' ' + msgParam1 + ' was not BANNED!'; } else { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' from Banned Userss. Something went wrong!'; } } } else { msgPrivate += ' ' + 'Only broadcaster, mods, and creator can remove users from groups!'; } if (validSyntax === true) { message['X-Spam'] = true; } break; case 'useradd': case 'adduser': case 'add': case 'a': if (isBBF || isModel || isMod) { message['X-Spam'] = true; var validSyntax = true; // check that we got 3 parameters if (msgParam2) { // which user array are we updating? switch(msgParam2.toLowerCase()) { case "1": case "r1": case "rank1": case rank1Tag: case rank1Tag+'s': result = addUser(Rank1UsersArray, msgParam1, true); if (result instanceof Array) { Rank1UsersArray = result; msgPublic += ' ' + name + ' appointed ' + msgParam1 + ' the rank of '+rank1Tag+'s!'; // if model didn't issue command remind model to update the bot if (!isModel) { msgModel += ' ' + modelName + ', don\'t forget to add ' + msgParam1 + ' to the '+rank1Tag+'s list in the bot config!'; } } else { if (result == 'duplicate') { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' because they are already in '+rank1Tag+'s!'; } else { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' to '+rank1Tag+'s. Something went wrong!'; } } break; case "2": case "r2": case "rank2": case rank2Tag: case rank2Tag+'s': result = addUser(Rank2UsersArray, msgParam1, true); if (result instanceof Array) { Rank2UsersArray = result; msgPublic += ' ' + name + ' appointed ' + msgParam1 + ' the rank of '+rank2Tag+'s!'; // if model didn't issue command remind model to update the bot if (!isModel) { msgModel += ' ' + modelName + ', don\'t forget to add ' + msgParam1 + ' to the '+rank2Tag+'s list in the bot config!'; } } else { if (result == 'duplicate') { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' because they are already in '+rank2Tag+'s!'; } else { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' to '+rank2Tag+'s. Something went wrong!'; } } break; case "3": case "r3": case "rank3": case rank3Tag: case rank3Tag+'s': result = addUser(Rank3UsersArray, msgParam1, true); if (result instanceof Array) { Rank3UsersArray = result; msgPublic += ' ' + name + ' appointed ' + msgParam1 + ' the rank of '+rank3Tag+'s!'; // if model didn't issue command remind model to update the bot if (!isModel) { msgModel += ' ' + modelName + ', don\'t forget to add ' + msgParam1 + ' to the '+rank3Tag+'s list in the bot config!'; } } else { if (result == 'duplicate') { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' because they are already in '+rank3Tag+'s!'; } else { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' to '+rank3Tag+'s. Something went wrong!'; } } break; case "4": case "r4": case "rank4": case rank4Tag: case rank4Tag+'s': result = addUser(Rank4UsersArray, msgParam1, true); if (result instanceof Array) { Rank4UsersArray = result; msgPublic += ' ' + name + ' appointed ' + msgParam1 + ' the rank of '+rank4Tag+'s!'; // if model didn't issue command remind model to update the bot if (!isModel) { msgModel += ' ' + modelName + ', don\'t forget to add ' + msgParam1 + ' to the '+rank4Tag+' list in the bot config!'; } } else { if (result == 'duplicate') { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' because they are already in '+rank4Tag+'s!'; } else { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' to '+rank4Tag+'s. Something went wrong!'; } } break; case "f": case "rf": case "friend": case "fr": case "friends": case friendTag: case friendTag+'s': result = addUser(FriendUsersArray, msgParam1, true); if (result instanceof Array) { FriendUsersArray = result; msgPublic += ' ' + name + ' added ' + msgParam1 + ' to the list of '+friendTag+'s!'; // if model didn't issue command remind model to update the bot if (!isModel) { msgModel += ' ' + modelName + ', don\'t forget to add ' + msgParam1 + ' to '+friendTag+'s in the bot config!'; } } else { if (result == 'duplicate') { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' because they are already in '+friendTag+'!'; } else { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' to '+friendTag+'s. Something went wrong!'; } } break; case "fc1": case "fanclub1": case cfc1Tag: case cfc1Tag+'s': result = addUser(Cfc1UsersArray, msgParam1, false); if (result instanceof Array) { Cfc1UsersArray = result; msgPublic += ' ' + name + ' added ' + msgParam1 + ' to the list of '+cfc1Tag+' members!'; // if model didn't issue command remind model to update the bot if (!isModel) { msgModel += ' ' + modelName + ', don\'t forget to add ' + msgParam1 + ' to '+cfc1Tag+' members in the bot config!'; } } else { if (result == 'duplicate') { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' because they are already '+cfc1Tag+' members!'; } else { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' to '+cfc1Tag+' members. Something went wrong!'; } } break; case "fc2": case "fanclub2": case cfc2Tag: case cfc2Tag+'s': result = addUser(Cfc2UsersArray, msgParam1, false); if (result instanceof Array) { Cfc2UsersArray = result; msgPublic += ' ' + name + ' added ' + msgParam1 + ' to the list of '+cfc2Tag+' members!'; // if model didn't issue command remind model to update the bot if (!isModel) { msgModel += ' ' + modelName + ', don\'t forget to add ' + msgParam1 + ' to '+cfc2Tag+' members in the bot config!'; } } else { if (result == 'duplicate') { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' because they are already '+cfc2Tag+' members!'; } else { msgPrivate += ' ' + 'Failed to add user ' + msgParam1 + ' to '+cfc2Tag+' members. Something went wrong!'; } } break; default: validSyntax = false; msgPrivate += ' ' + 'You didn\'t supply a valid group to add the user to. Valid groups are:\n'; msgPrivate += 'rf r1 r2 r3 r4 fc1 fc2 ... choose only one.'; break; } } else { validSyntax = false; msgPrivate += ' ' + 'You must provide the group and the username you wish to add. For example,\n' + botTrigger + ' adduser r1 someusername\n'; msgPrivate += 'or ' + botTrigger + ' adduser fc1 someuser\nValid groups are: rf r1 r2 r3 r4 fc1 fc2'; } } else { msgPrivate += ' ' + 'Only brodcaster and mods can add users to groups!'; } if (validSyntax === true) { message['X-Spam'] = true; } break; case 'userdel': case 'deluser': case 'delete': case 'remove': case 'd': case 'del': if (isBBF || isModel || isMod) { message['X-Spam'] = true; var validSyntax = true; // check that we got 3 parameters if (msgParam2) { // which user array are we updating? switch(msgParam2.toLowerCase()) { case "1": case "r1": case "rank1": case rank1Tag: case rank1Tag+'s': result = delUser(Rank1UsersArray, msgParam1); if (result instanceof Array) { Rank1UsersArray = result; msgPublic += ' ' + name + ' removed ' + msgParam1 + ' from the '+rank1Tag+'s list!'; msgModel += ' ' + modelName + ', don\'t forget to remove ' + msgParam1 + ' from the '+rank1Tag+'s list in the bot config!'; } else { if (result == 'notfound') { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' because they are not in '+rank1Tag+'s!'; } else { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' from '+rank1Tag+'s. Something went wrong!'; } } break; /* case "ghost": result = delUser(ghostUsersArray, msgParam2); if (result instanceof Array) { ghostUsersArray = result; msgPublic += ' ' + name + ' removed ' + msgParam2 + ' from the Ghost list!'; } else { if (result == 'notfound') { msgPrivate = 'Failed to remove user ' + msgParam2 + ' because they are not in Ghosts!'; } else { msgPrivate = 'Failed to remove user ' + msgParam2 + ' from Ghosts. Something went wrong!'; } } break; */ case "rf": case "fr": case "f": case "friend": case "friends": case friendTag: case friendTag+'s': result = delUser(FriendUsersArray, msgParam1); if (result instanceof Array) { FriendUsersArray = result; msgPublic += ' ' + name + ' removed ' + msgParam1 + ' from the list of '+friendTag+'s!'; // if model didn't issue command remind model to update the bot msgModel += ' ' + modelName + ', don\'t forget to remove ' + msgParam1 + ' from '+friendTag+'s in the bot config!'; } else { if (result == 'notfound') { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' because they are not in '+friendTag+'s!'; } else { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' from '+friendTag+'s. Something went wrong!'; } } break; case "2": case "r2": case "rank2": case rank2Tag: case rank2Tag+'s': result = delUser(Rank2UsersArray, msgParam1); if (result instanceof Array) { Rank2UsersArray = result; msgPublic += ' ' + name + ' removed ' + msgParam1 + ' from the list of '+rank2Tag+'s!'; // if model didn't issue command remind model to update the bot msgModel += ' ' + modelName + ', don\'t forget to remove ' + msgParam1 + ' from '+rank2Tag+'s in the bot config!'; } else { if (result == 'notfound') { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' because they are not in '+rank2Tag+'s!'; } else { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' from '+rank2Tag+'s. Something went wrong!'; } } break; case "3": case "r3": case "rank3": case rank3Tag: case rank3Tag+'s': result = delUser(Rank3UsersArray, msgParam1); if (result instanceof Array) { Rank3UsersArray = result; msgPublic += ' ' + name + ' removed ' + msgParam1 + ' from the list of '+rank3Tag+'s!'; // if model didn't issue command remind model to update the bot msgModel += ' ' + modelName + ', don\'t forget to remove ' + msgParam1 + ' from Fiances in the bot config!'; } else { if (result == 'notfound') { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' because they are not in '+rank3Tag+'s!'; } else { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' from '+rank3Tag+'s. Something went wrong!'; } } break; case "4": case "r4": case "rank4": case rank4Tag: case rank4Tag+'s': result = delUser(Rank4UsersArray, msgParam1); if (result instanceof Array) { Rank4UsersArray = result; msgPublic += ' ' + name + ' removed ' + msgParam1 + ' from the list of '+rank4Tag+'s!'; // if model didn't issue command remind model to update the bot if (!isModel) { msgModel += ' ' + modelName + ', don\'t forget to remove ' + msgParam1 + ' from '+rank4Tag+'s in the bot config!'; } } else { if (result == 'notfound') { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' because they are not in '+rank4Tag+'s!'; } else { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' from '+rank4Tag+'s. Something went wrong!'; } } break; case "fc1": case "fanclub1": case cfc1Tag: case cfc1Tag+'s': result = delUser(Cfc1UsersArray, msgParam1); if (result instanceof Array) { Cfc1UsersArray = result; msgPublic += ' ' + name + ' removed ' + msgParam1 + ' from the list of '+cfc1Tag+' members!'; // if model didn't issue command remind model to update the bot if (!isModel) { msgModel += ' ' + modelName + ', don\'t forget to remove ' + msgParam1 + ' from '+cfc1Tag+' members in the bot config!'; } } else { if (result == 'notfound') { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' because they are not '+cfc1Tag+' members!'; } else { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' from '+cfc1Tag+' members. Something went wrong!'; } } break; case "fc2": case "fanclub2": case cfc2Tag: case cfc2Tag+'s': result = delUser(Cfc2UsersArray, msgParam1); if (result instanceof Array) { Cfc2UsersArray = result; msgPublic += ' ' + name + ' removed ' + msgParam1 + ' from the list of '+cfc2Tag+' members!'; // if model didn't issue command remind model to update the bot if (!isModel) { msgModel += ' ' + modelName + ', don\'t forget to remove ' + msgParam1 + ' from '+cfc2Tag+' members in the bot config!'; } } else { if (result == 'notfound') { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' because they are not '+cfc2Tag+' members!'; } else { msgPrivate += ' ' + 'Failed to remove user ' + msgParam1 + ' from '+cfc2Tag+' members. Something went wrong!'; } } break; default: validSyntax = false; msgPrivate += ' ' + 'You didn\'t supply a valid group to add the user to. Valid groups are:\n'; msgPrivate += 'rf r1 r2 r3 r4 fc1 fc2 ... choose only one.'; break; } } else { validSyntax = false; msgPrivate += ' ' + 'You must provide the group and the username you wish to add. For example,\n' + botTrigger + ' adduser r1 someusername\n'; msgPrivate += 'or ' + botTrigger + ' adduser fc1 someuser\nValid groups are: rf r1 r2 r3 r4 fc1 fc2'; } } else { msgPrivate += ' ' + 'Only broadcaster, mods, and creator can remove users from groups!'; } if (validSyntax === true) { message['X-Spam'] = true; } break; case 'check': case 'c': case 'test': if (msgParam1) { message['X-Spam'] = true; groupList = checkUser(msgParam1); msgPrivate += ' ' + 'User ' + msgParam1 + ' found in: ' + groupList; } break; case 'modcommands': case 'mods': case 'm': if(isModel || isBBF) { message['X-Spam'] = true; modCommands=!modCommands; if (modCommands){ msgPublic += ' ' + name + ' has enabled Moderator commands!'; }else{ msgPublic += ' ' + name + ' has disabled Moderator commands!'; } } else { msgPrivate += ' ' + 'Only broadcaster and creator can enable or disable mod commands!'; } break; case 'ge': case 'grey': case 'greyemote': case 'greyemotes': case 'grayemote': case 'grayemotes': case 'emotes': case 'emote': if (isBBF || isModel || isMod) { message['X-Spam'] = true; allowGreyEmotes=!allowGreyEmotes; if (allowGreyEmotes){ msgPublic += ' ' + name + ' has enabled grey emotes!'; }else{ msgPublic += ' ' + name + ' has disabled grey emotes!'; } } else { msgPrivate += ' ' + 'Only broadcaster, mods and creator can disable or enable grey emotes!'; } break; case 'g': case 'greets': case 'greetings': if(isModel || isBBF) { message['X-Spam'] = true; var tmpGl=parseInt(msgParam1); if (tmpGl!='NaN' && tmpGl >=0 && tmpGl <=3){ userGreets= tmpGl;} else {userGreets=1;} switch (userGreets){ case 0: cb.settings.usergreets="0: No One"; break; case 1: cb.settings.usergreets="1: Society Members"; break; case 2: cb.settings.usergreets="2: Recent Tippers (dark blue+)"; break; case 3: cb.settings.usergreets="3: Token Owners (light blue)"; break; } msgPublic += ' ' + name + ' has set User Greetings to Level <'+userGreets+'>!'; // userGreets=!userGreets; // if (userGreets){ // msgPublic += ' ' + name + ' has enabled User Greetings!'; // }else{ // msgPublic += ' ' + name + ' has disabled User Greetings!'; // } } else { msgPrivate += ' ' + 'Only broadcaster and creator can enable or disable user greetings!'; } break; case 's': case 'status': case 'stat': case 'announce': message['X-Spam'] = true; msgPrivate += ' ' + announceBot(true); break; default: message['X-Spam'] = true; msgPrivate += ' ' + 'You must provide a command. Type ' + botTrigger + ' help\n ...to get a list of options.'; break; } // Output any notices or command results to user if (msgPrivate.length > 0) { cb.sendNotice(msgPrivate, name, botMsgBg,'','bold'); msgPrivate = ""; } // Output any public notices or command results if (msgPublic.length > 0) { cb.sendNotice(msgPublic, '', botMsgBg,'','bold'); msgPublic = ""; } // Output any messages to the mods if (msgMod.length > 0) { cb.sendNotice(msgMod,'', botMsgBg,'','bold','red'); msgMod = ""; } // Output any messages to the model if (msgModel.length > 0) { cb.sendNotice(msgModel, modelName, botMsgBg,'','bold'); msgModel = ""; } } } // see if user envoked emotes that should be removed (no grey emotes) if (!isInGroup && !isBBF && !isModel && !allowGreyEmotes && isGrey) { //user is grey, is not in a group, not BBF, not model and grey emotes are not allowed if (msg.indexOf(':') > -1) { //colon found, replace all with _ msg = msg.replace(/:([^\s]+)/g,"[blocked emote]"); } } // apply group tags var prefix=''; if (rankTag!='') { prefix = rankTag; //deblog(prefix); } if (showTips){ if (prefix != ''){ if (todaysTippers[name]){ prefix = prefix+' : '+ todaysTippers[name].tips; } } else{ if (todaysTippers[name]){ prefix = todaysTippers[name].tips; } } //deblog(prefix); } if (prefix != ''){ prefix = '[ '+prefix+' ]'; //deblog(prefix); } clubTag = getClubTag(name, isFan, isMod); if (clubTag){ if (clubTag==modelTag){ if (clubTag.indexOf(':') <= -1){ clubTag='[ '+clubTag+' ]'; } }else{ if(clubTag.indexOf('|') > -1){ clubTag='[ '+clubTag+' ]'; }else{ if(clubTag.indexOf(':') <= -1){ clubTag='[ '+clubTag+' ]'; } } } prefix = prefix+clubTag; } if(prefix){ msg=prefix+' '+msg; } } // return final altered message message['m'] = msg; return message; }); //end onMessage /*++++++++++++++ * bot functions ++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++ * Generates a list of clubTags, seperated by |, * for fan clubs, moderator and the model ++++++++++++++++++++++++++++++++++++++++++++++*/ function getClubTag(name, isFan, isMod){ var tag=''; if (name==modelName){ tag=modelTag; }else{ if(isFan){ tag += ' '+fanTag+' |'; } if(userInArray(Cfc1UsersArray,name)){ tag += ' ' + cfc1Tag + ' |'; } if(userInArray(Cfc2UsersArray,name)){ tag += ' '+cfc2Tag+' |'; } if(isMod){ tag += ' '+modTag+' |'; } tag = tag.trim(); tag = tag.substring(0, tag.length - 1); } return tag; } /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * return string of todaysTippers to display * can limit number of todaysTippers returned to show only top 10, top 5 ect. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ function getTippers(topNumber) { var topTippers = new Array(); var tempTippers = objectToArray(todaysTippers); var output = ''; tempTippers.sort(dynamicSort('-tips')); if (topNumber > 0) { topTippers = tempTippers.slice(0,topNumber); if (topTippers.length == 1) { output = '\nTop Tipper'; } else { output = '\nTop ' + topTippers.length + ' Tippers'; } } else { topTippers = tempTippers; output = '\nAll Tippers'; } if (topTippers.length > 0) { for (i = 0; i < topTippers.length; i++) { output += '\n' + topTippers[i].username + ': ' + topTippers[i].tips; } } else { output = '\nThere have been no tippers since the bot started!\n'; } return output + '\n'; } /*+++++++++++++++++++++++++++++++++++++++++ + check if a word or phrase is in a string +++++++++++++++++++++++++++++++++++++++++*/ function isWordInString(word,str) { var re = new RegExp(word,"i"); var n = str.search(re); if (n > -1) { return true; } else { return false; } } /*+++++++++++++++++++++++++++++++++++++++++++++++++++++ + display notification message and start interval timer +++++++++++++++++++++++++++++++++++++++++++++++++++++*/ function displayNotification1() { cb.sendNotice(autoNotice1Text,'',botNoteBg,'','bold'); cb.setTimeout(displayNotification1, cb.settings.autoNotice1Interval * 60000); } function displayNotification2() { cb.sendNotice(autoNotice2Text,'',botNoteBg,'','bold'); cb.setTimeout(displayNotification2, cb.settings.autoNotice2Interval * 60000); } function displayReplaceHTK() { //deblog('displayReplaceHTK') if (highTipKingTip>0){ if(HighTipKingName !=''){ cb.sendNotice(HighTipKingName + ' is ' + modelName+'\'s '+ highTipKingTag+'!','',botNoteBg,'','bold'); cb.sendNotice('Tip more than '+highTipKingTip+' Token to be the new '+highTipKingTag+'!','',highTipKingColor,'','bold'); }else{ cb.sendNotice('NO ONE is '+modelName+'\'s '+ highTipKingTag+'!','',botNoteBg,'','bold'); cb.sendNotice('Tip more than '+highTipKingTip+' Token to become the '+highTipKingTag+'!','',highTipKingColor,'','bold'); } if(cb.settings.autoAnnounceHTK>0){ cb.setTimeout(displayReplaceHTK, cb.settings.autoAnnounceHTK * 60000); } } } function displayAnnounce() { //deblog('displayAnnounce') cb.sendNotice(announceBot(false),'',botMsgBg,'','bold'); if (cb.settings.autoAnnounceInterval>0){ cb.setTimeout(displayAnnounce, cb.settings.autoAnnounceInterval * 60000); } } function deblog(log){ cb.sendNotice('>>> '+log,'',botNoteBg,'','bold'); } function sendPublic(msg){ //deblog('model='+cb.room_slug); cb.sendNotice(msg,'',botNoteBg,'','bold'); } function sendModel(msg){ //deblog('model='+cb.room_slug); cb.sendNotice(msg, cb.room_slug, botNoteBg, '', 'bold'); } /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + return parameter value from a message string + Req: msgString = full message as string + Req: splitChr = character to split on (usually space) + Req: paramNumber = number of the parameter to return (first is 0) + Return: paramValue = value of the requested parameter ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ function getParam(msgString,splitChr,paramNumber) { var tempArray = new Array(); tempArray = msgString.split(splitChr); paramValue = tempArray[paramNumber]; return paramValue; } /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + build a variable length divider from a character + Req: divChr = the character to use for the divier, ie: _ - * + Req: strLen = length of the data to be divided (lenth of a string, or fixed) + Req: maxDivLen = the max number of characters the div can grow to +* Return: divStr = string of repeated character that make the 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; } /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * return array of users with the new user added, duplicate, * or error string. * Req: userArray = array of users to add the new user to * Req: username = username of new user * Return: array of users with new users added * On error: return "duplicate" if username in user array already * On error: return "failed" if user no duplicate and wasn't added ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ function addUser(userArray, username, addRank) { var userArrayLength = userArray.length; username = username.toLowerCase(); // check if username is in userarray usernameExists = userInArray(userArray, username); if (usernameExists === true) { return "duplicate"; // username found in array, return duplicate } else { // remove user from all user arrays if (addRank) { delUserFromAll(username, false);} // add username to array userArray[userArrayLength] = username; // check to see that addition of user worked usernameExists = userInArray(userArray, username); if (usernameExists === true) { return userArray; // it worked, return the array } else { return "failed"; // failed, return failed } } } /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * return array of users with the new user removed, duplicate, * or error string. * Req: userArray = array of users to add the new user to * Req: username = username of new user * Return: array of users with user removed * On error: return "notfound" if username not in user array * On error: return "failed" if user no duplicate and wasn't added ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ function delUser(userArray, username) { var userArrayLength = userArray.length; var userElement = -1; username = username.toLowerCase(); if (userInArray(userArray, username)) { userElement = getArrayElement(userArray, username); if (userElement > -1) { tempArray = removeArrayElement(userArray, userElement); if (!userInArray(userArray, username)) { // user was removed return tempArray; } else { // user was not removed, failed return "failed"; } } else { //user element was not in array for some reason return "failed"; } } else { return 'notfound'; } } /*++++++++++++++++++++++++++++++++++++++++++ * remove a user from all groups * Req: username = name over user to remove * Return: none ++++++++++++++++++++++++++++++++++++++++++*/ function delUserFromAll(username, delClubs) { if ( userInArray(FriendUsersArray, username) ) { result = delUser(FriendUsersArray, username); if (result instanceof Array) { FriendUsersArray = result; } } if ( userInArray(Rank1UsersArray, username) ) { result = delUser(Rank1UsersArray, username); if (result instanceof Array) { Rank1UsersArray = result; } } if ( userInArray(Rank2UsersArray, username) ) { result = delUser(Rank2UsersArray, username); if (result instanceof Array) { Rank2UsersArray = result; } } if ( userInArray(Rank3UsersArray, username) ) { result = delUser(Rank3UsersArray, username); if (result instanceof Array) { Rank3UsersArray = result; } } if ( userInArray(Rank4UsersArray, username) ) { result = delUser(Rank4UsersArray, username); if (result instanceof Array) { Rank4UsersArray = result; } } if(delClubs){ if ( userInArray(Cfc1UsersArray, username) ) { result = delUser(Cfc1UsersArray, username); if (result instanceof Array) { Cfc1UsersArray = result; } } if ( userInArray(Cfc2UsersArray, username) ) { result = delUser(Cfc2UsersArray, username); if (result instanceof Array) { Cfc2UsersArray = result; } } } } /* return group bg color*/ function getGroupBgColor(username) { var bgc = "#ffffff"; if ( userInArray (Cfc1UsersArray, username)) { bgc = cfc1Color; } else if (userInArray(Cfc2UsersArray, username)) { bgc = cfc2Color; } // else if ( userInArray (Rank4UsersArray, username) ) { bgc = rank4Color; } // else if ( userInArray (Rank4UsersArray, username) ) { bgc = rank4Color; } else if (userInArray(Rank4UsersArray, username)) { bgc = rank4Color; } else if (userInArray(Rank3UsersArray, username)) { bgc = rank3Color; } else if (userInArray(Rank2UsersArray, username)) { bgc = rank2Color; } else if (userInArray(Rank1UsersArray, username)) { bgc = rank1Color; } else if (userInArray(FriendUsersArray, username)) { bgc = friendColor; } return bgc; } /*+++++++++++++++++++++++++++++++++++++++++++++++++++++ * return the element or index number of an array value * Req: sourceArray = array to parse * Req: value = value to find * Return: index of the element *+++++++++++++++++++++++++++++++++++++++++++++++++++++*/ function getArrayElement(sourceArray, value) { var index = 0; for (i = 0; i < sourceArray.length; i++) { if (sourceArray[i] == value) { index = i; } } return index; } /*++++++++++++++++++++++++++++++++++++++++++++++++++ * dynamic sort function to sort array by a property * Borrowed from Asdfghjkl28 +++++++++++++++++++++++++++++++++++++++++++++++++++*/ function dynamicSort(property) { var sortOrder = 1; if (property[0] === "-") { sortOrder = -1; property = property.substr(1, property.length - 1); } var sortfunc = function (a, b) { if (typeof a[property] === "undefined") { if (typeof b[property] === "undefined") { // both undef return 0; } else { // b ok, a undef return -1; } } if (typeof b[property] === "undefined") { if (typeof a[property] === "undefined") { // both undef return 0; } else { // a ok, b undef return 1; } } var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0; return result * sortOrder; }; return sortfunc; } /* +++++++++++++++++++++++++++++ * convert object to an array * Borrowed from Asdfghjkl28 +++++++++++++++++++++++++++++*/ function objectToArray(myObj) { var arr = []; for (var i in myObj) { if (myObj.hasOwnProperty(i)) { arr.push(myObj[i]); } } return arr; } /*+++++++++++++++++++++++++++++++++++++++++++++++++++ * return an array with the indicated element removed * Req: sourceArray = array to be modified * Req: element = element to be removed * Return: the modified array +++++++++++++++++++++++++++++++++++++++++++++++++++*/ function removeArrayElement(sourceArray,element) { sourceArray.splice(element, 1); return sourceArray; } /*++++++++++++++++++++++++++++++++++++++++++ * return boolean if user is in user array * Req: userArray = array of users to parse * Req: userName = name of user to parse fr * Returns: userFound = true or false +++++++++++++++++++++++++++++++++++++++++++*/ function userInArray(userArray, username) { var userFound = false; username = username.toLowerCase(); if (userArray.length > 0) { for(i=0; i < userArray.length; i++) { if (userArray[i] == username) userFound = true; } } return userFound; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++ * return a string of usernames from an array of users * Req: userArray = array of users * Return: string of of usersnames ++++++++++++++++++++++++++++++++++++++++++++++++++++*/ function getUsers(userArray) { var userList = ""; for (i = 0; i < userArray.length; i++) { userList += userArray[i] + ' '; } userList=userList.trim(); return userList; } function getGroupsExport(){ var exportList = friendTag+': '; exportList += getUsers(FriendUsersArray); exportList += '; '+rank1Tag+': '; exportList += getUsers(Rank1UsersArray); exportList += '; '+rank2Tag+': '; exportList += getUsers(Rank2UsersArray); exportList += '; '+rank3Tag+': '; exportList += getUsers(Rank3UsersArray); exportList += '; '+rank4Tag+': '; exportList += getUsers(Rank4UsersArray); exportList += '; '+highTipKingTag+'/Tip: '; exportList += HighTipKingName+'/'+highTipKingTip; exportList += '; '+cfc1Tag+': '; exportList += getUsers(Cfc1UsersArray); exportList += '; '+cfc2Tag+': '; exportList += getUsers(Cfc2UsersArray); exportList += '; Banned User: '; exportList += getUsers(BannedUsersArray); exportList += ';' return exportList; } /* * return list of groups that a user is a member of * Req: username = username to find * Return: string with list of groups the user was found in */ function checkUser(username) { var groupList = ""; username = username.toLowerCase(); if (userInArray(FriendUsersArray, username)) groupList += friendTag+"; "; if (userInArray(Rank1UsersArray, username)) groupList += rank1Tag+"; "; if (userInArray(Rank2UsersArray, username)) groupList += rank2Tag+"; "; if (userInArray(Rank3UsersArray, username)) groupList += rank3Tag+"; "; if (userInArray(Rank4UsersArray, username)) groupList += rank4Tag+"; "; if (userInArray(Cfc1UsersArray, username)) groupList += cfc1Tag+"; "; if (userInArray(Cfc2UsersArray, username)) groupList += cfc2Tag+"; "; if (username==HighTipKingName.toLowerCase()) groupList += highTipKingTag+"; "; groupList = groupList.trim(); grouplist = groupList.substring(0, groupList.length - 1); return groupList; } function newStuff() { var output = 'Hi ' + modelName + '! '; output+=announceBot(true)+'\n'+helpMsg; return output; } function modWelcome(username) { var output = '\nGreetings Moderator '+username+'\n'; output+='\n'+helpMsg; return output; } /* * Builds user arrays and strings based on data provided by bot * config settings */ function InitSettings() { // SocietyName if (cb.settings.societyName) { societyName = cb.settings.societyName; } else { societyName = ""; } // grey graphics if (cb.settings.allowGreyEmotes == 'Yes') { allowGreyEmotes = true; } else { allowGreyEmotes = false; } // mod commands if (cb.settings.modCommands == 'Yes') { modCommands = true; } else { modCommands = false; } // greetings if (cb.settings.userGreets){ tempArray=cb.settings.userGreets.split(":"); var tmpGl=parseInt(tempArray[0]); if (tmpGl!='NaN'){ userGreets= tmpGl;} else {userGreets=1;} }else {userGreets=1;} // if (cb.settings.userGreets == 'Yes') { userGreets = true; } // else { userGreets = false; } // ShowTips if (cb.settings.showTips == 'Yes') { showTips = true; } else { showTips = false; } // AdvanceSingleTip if (cb.settings.rankAdvance == 'Single') { advanceSingle = true; } else { advanceSingle = false; } // RankTips rank1Tip = cb.settings.rank1Tip; rank2Tip = cb.settings.rank2Tip; rank3Tip = cb.settings.rank3Tip; rank4Tip = cb.settings.rank4Tip; cfc1Tip = cb.settings.cfc1Tip; cfc2Tip = cb.settings.cfc2Tip; highTipKingTip = cb.settings.highTipKingTip; // AdvanceSingleTip if (cb.settings.rankAdvance == 'Single') { advanceSingle = true; } else { advanceSingle = false; } // load friends into array and other variables if (cb.settings.friendList) { tempStr = cb.settings.friendList.toLowerCase(); //make names all lowercase cb.settings.friendList = tempStr.trim(); // remove extra spaces FriendUsersArray = cb.settings.friendList.split(' '); addUser(FriendUsersArray, 'bigboobiesfan', true); } if (cb.settings.friendTag) { friendTag = cb.settings.friendTag.trim(); } if (cb.settings.friendColor) { tempArray = cb.settings.friendColor.split(' '); friendColor = '#' + tempArray[1]; } // load Rank1 into array and other variables if (cb.settings.rank1List) { tempStr = cb.settings.rank1List.toLowerCase(); //make names all lowercase cb.settings.rank1List = tempStr.trim(); // remove extra spaces Rank1UsersArray = cb.settings.rank1List.split(' '); } if (cb.settings.rank1Tag) { rank1Tag = cb.settings.rank1Tag.trim(); } if (cb.settings.rank1Color) { tempArray = cb.settings.rank1Color.split(' '); rank1Color = '#' + tempArray[1]; } // load Rank2 into array and other variables if (cb.settings.rank2List) { tempStr = cb.settings.rank2List.toLowerCase(); //make names all lowercase cb.settings.rank2List = tempStr.trim(); // remove extra spaces Rank2UsersArray = cb.settings.rank2List.split(' '); } if (cb.settings.rank2Tag) { rank2Tag = cb.settings.rank2Tag.trim(); } if (cb.settings.rank2Color) { tempArray = cb.settings.rank2Color.split(' '); rank2Color = '#' + tempArray[1]; } // load Rank3 into array and other variables if (cb.settings.rank3List) { tempStr = cb.settings.rank3List.toLowerCase(); //make names all lowercase cb.settings.rank3List = tempStr.trim(); // remove extra spaces Rank3UsersArray = cb.settings.rank3List.split(' '); } if (cb.settings.rank3Tag) { rank3Tag = cb.settings.rank3Tag.trim(); } if (cb.settings.rank3Color) { tempArray = cb.settings.rank3Color.split(' '); rank3Color = '#' + tempArray[1]; } // load Rank4 into array and other variables if (cb.settings.rank4List) { tempStr = cb.settings.rank4List.toLowerCase(); //make names all lowercase cb.settings.rank4List = tempStr.trim(); // remove extra spaces Rank4UsersArray = cb.settings.rank4List.split(' '); } if (cb.settings.rank4Tag) { rank4Tag = cb.settings.rank4Tag.trim(); } if (cb.settings.rank4Color) { tempArray = cb.settings.rank4Color.split(' '); rank4Color = '#' + tempArray[1]; } // load highTipKing into variables if (cb.settings.highTipKingName) { tempStr = cb.settings.highTipKingName.toLowerCase(); //make names all lowercase cb.settings.highTipKingName = tempStr.trim(); // remove extra spaces HighTipKingName = tempStr.trim(); } if (cb.settings.highTipKingTag) { highTipKingTag = cb.settings.highTipKingTag.trim(); } if (cb.settings.highTipKingColor) { tempArray = cb.settings.highTipKingColor.split(' '); highTipKingColor = '#' + tempArray[1]; } // load CFC1 into array and other variables if (cb.settings.cfc1List) { tempStr = cb.settings.cfc1List.toLowerCase(); //make names all lowercase cb.settings.cfc1List = tempStr.trim(); // remove extra spaces Cfc1UsersArray = cb.settings.cfc1List.split(' '); } if (cb.settings.cfc1Tag) { cfc1Tag = cb.settings.cfc1Tag.trim(); } if (cb.settings.cfc1Color) { tempArray = cb.settings.cfc1Color.split(' '); cfc1Color = '#' + tempArray[1]; } // load CFC2 into array and other variables if (cb.settings.cfc2List) { tempStr = cb.settings.cfc2List.toLowerCase(); //make names all lowercase cb.settings.cfc2List = tempStr.trim(); // remove extra spaces Rank4UsersArray = cb.settings.cfc2List.split(' '); } if (cb.settings.cfc2Tag) { cfc2Tag = cb.settings.cfc2Tag.trim(); } if (cb.settings.cfc2Color) { tempArray = cb.settings.cfc2Color.split(' '); cfc2Color = '#' + tempArray[1]; } if (cb.settings.modTag) { modTag = cb.settings.modTag.trim(); } if (cb.settings.modColor) { tempArray = cb.settings.modColor.split(' '); modColor = '#' + tempArray[1]; } if (cb.settings.modelTag) { modelTag = cb.settings.modelTag.trim(); } if (cb.settings.modelColor) { tempArray = cb.settings.modelColor.split(' '); modelColor = '#' + tempArray[1]; } if (cb.settings.fanTag) { fanTag = cb.settings.fanTag.trim(); } // load notifications if (cb.settings.autoNotice1) { autoNotice1Text = cb.settings.autoNotice1.trim(); } if (cb.settings.autoNotice2) { autoNotice2Text = cb.settings.autoNotice2.trim(); } InitHelpMessage(); } function InitHelpMessage(){ var tempAllowMsg = "Only " + modelName; if (modCommands) { tempAllowMsg = modelName + " and mods"; } helpMsg = tempAllowMsg + " may use the following commands:\n" + "*(Legit Ranks: f = "+friendTag+"; r1 = "+rank1Tag+"; r2 = "+rank2Tag+"; r3 = "+rank3Tag+"; r4 = "+rank3Tag+"; fc1 = "+cfc1Tag+"; fc2 = "+cfc2Tag+"; htk = "+highTipKingTag+"; Use the shorts instead of [r] in the commands)*\n" + botTrigger + " help = Displays this list of commands. \n" + botTrigger + " add [username] [r] = add username to rank\n" + botTrigger + " del [username] [r] = delete username from rank\n" + botTrigger + " check [username] = show what rank/groups a user is in\n" + botTrigger + " list [r] = list of users in that rank. \n" + botTrigger + " ban [username] = Bans a user, suppressing all his messages\n" + botTrigger + " unban [username] = Unbans a user\n" + botTrigger + " tips = show all tippers (private)\n" + botTrigger + " tips # = show top # tippers (private)\n" + botTrigger + " bcnote [message] = send a private message to "+modelName+"\n" + botTrigger + " modnote [message] = send a private message to all mods\n" + botTrigger + " mods = turn on/off mod commands\n" + botTrigger + " greets # = sets the Level of User Greetings to # (0-3)\n" + botTrigger + " grey = turns on/off grey emotes\n" + botTrigger + " status = show bot status\n" + botTrigger + " export = lists all ranks for copy/paste into config \n" + "*** NOTE: To make names stick add them in the bot config."; } function announceBot(stat) { var divStr=""; var statusMsg = ""; divStr = makeDiv('*', 40, 40); statusMsg = divStr + '\nRANKED SOCIETY Bot ver ' + botVersion + ' last updated ' + botDate + '\nCreated by BigBoobiesFan\n' + divStr + '\n'; if (stat){ statusMsg += 'Grey Emotes: '; if (allowGreyEmotes) { statusMsg += 'On\n'; } else { statusMsg += 'Off\n'; } statusMsg += 'Mod Commands: '; if (modCommands) { statusMsg += 'On\n'; } else { statusMsg += 'Off\n'; } statusMsg += 'User Greetings: '+ cb.settings.userGreets + '\n'; // if (userGreets) { statusMsg += 'On\n'; } // else { statusMsg += 'Off\n'; } } var tmpTxt=''; if(!advanceSingle){ tmpTxt = ' or more '; } statusMsg += friendTag +' Members: ' + FriendUsersArray.length + ' (this is assigned)\n'; statusMsg += rank1Tag +' Members: ' + Rank1UsersArray.length + ' (tip '+rank1Tip+tmpTxt+'tk)\n'; statusMsg += rank2Tag +' Members: ' + Rank2UsersArray.length + ' (tip '+rank2Tip+tmpTxt+'tk)\n'; statusMsg += rank3Tag +' Members: ' + Rank3UsersArray.length + ' (tip '+rank3Tip+tmpTxt+'tk)\n'; statusMsg += rank4Tag +' Members: ' + Rank4UsersArray.length + ' (tip '+rank4Tip+tmpTxt+'tk)\n'; statusMsg += cfc1Tag +' Members: ' + Cfc1UsersArray.length + ' (tip '+cfc1Tip+'tk)\n'; statusMsg += cfc2Tag +' Members: ' + Cfc2UsersArray.length + ' (tip '+cfc2Tip+'tk)\n'; statusMsg += highTipKingTag +' is: ' + HighTipKingName + '!!! (tip more than '+highTipKingTip+' tk to replace him)\n'; if (stat){ statusMsg += 'Type - ' + botTrigger + ' help - for list commands\n'; } statusMsg += divStr; return statusMsg; } InitSettings(); //cb.sendNotice(announceBot(),'', botMsgBg,'','bold'); cb.sendNotice(newStuff(),modelName,'#000000','#FFFF00','bold'); if (autoNotice1Text && cb.settings.autoNotice1Interval > 0) cb.setTimeout(displayNotification1, cb.settings.autoNotice1Interval * 60000); if (autoNotice2Text && cb.settings.autoNotice2Interval > 0) cb.setTimeout(displayNotification2, cb.settings.autoNotice2Interval * 60000); //deblog("autoAnnounceInterval="+cb.settings.autoAnnounceInterval); if (cb.settings.autoAnnounceInterval > 0) cb.setTimeout(displayAnnounce, cb.settings.autoAnnounceInterval * 60000); //deblog("autoAnnounceHTK="+cb.settings.autoAnnounceHTK); if (cb.settings.autoAnnounceHTK > 0) cb.setTimeout(displayReplaceHTK, cb.settings.autoAnnounceHTK * 60000);
© Copyright Chaturbate 2011- 2024. All Rights Reserved.