Bots Home
|
Create an App
ultrakr
Author:
quid14
Description
Source Code
Launch Bot
Current Users
Created by:
Quid14
/**** Version: 1.0.0 (27 Jan 2017) ****/ /************************************************************************************************************************************ ***** App Launch Settings *********************************************************************************************************** ************************************************************************************************************************************/ cb.settings_choices = [ /**** 1. PERSONALIZATION ****/ {name: 'colorscheme', label: '1.) PERSONALIZATION ........................................... Color Scheme:', type: 'choice', choice1: 'Purple', choice2: 'Pink', choice3: 'Orange', choice4: 'Red', choice5: 'Green', choice6: 'Teal', choice7: 'Grey', choice8: 'Custom (Please define below)', required: false}, {name: 'darkcolor', label: 'Custom Dark Color (Hex #)', type: 'str', defaultValue: '[Optional - Set color scheme to "Custom" above]', required: false}, {name: 'lightcolor', label: 'Custom Light Color (Hex #)', type: 'str', defaultValue: '[Optional - Set color scheme to "Custom" above]', required: false}, {name: 'enterMessage', label: 'Welcome Message', type: 'str', minLength: 1, maxLength: 1000, defaultValue: 'Welcome to my room,{username}! :kisses4u If you like what you see, Please :followclick :thxyou7', required: false}, /**** 2. ROOM CONTROL ****/ {name: 'capsToggle', label: '2.) ROOM CONTROL ................ Convert ALL CAPS to lowercase?', type: 'choice', choice1: 'Yes', choice2: 'No', choice3: 'Only for greys', defaultValue: 'No', required: false}, {name: 'stickyToggle', label: 'Prevent sticky keyyyyyyyyyyyyys?', type: 'choice', choice1: 'Yes', choice2: 'No', choice3: 'Only for greys', defaultValue: 'No', required: false}, {name: 'defaultGraphicLevel', label: 'Default Graphic Level (Who can use graphics?)', type: 'choice', choice1: '0 - (Everyone)', choice2: '1 - (Color names only)', choice3: '2 - (Dark blue names and higher)', choice4: '3 - (Users who have tipped)', choice5: '4 - (Only mods and fans)', defaultValue: '0 - (Everyone)', required: false}, {name: 'defaultSilenceLevel', label: 'Default Silence Level (Who can talk in chat?)', type: 'choice', choice1: '0 - (Everyone)', choice2: '1 - (Color names only)', choice3: '2 - (Dark blue names and higher)', choice4: '3 - (Users who have tipped)', choice5: '4 - (Only mods and fans)', defaultValue: '0 - (Everyone)', required: false}, {name: 'niceList', label: 'Nice List (Users who can always talk/use graphics)', type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Optional - Exact usernames, separated by commas]', required: false}, {name: 'silenceList', label: 'Silence List (Users who are permanently silenced)', type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Optional - Exact usernames, separated by commas]', required: false}, /**** 3. WORDLISTS ****/ {name: 'wordlistToggle', label: '3.) BLOCKED WORDLIST .............. Use blocked wordlist feature?', type: 'choice', choice1: 'Yes', choice2: 'No (Skip to section 4)', defaultValue: 'No (Skip to section 4)', required: false}, {name: 'wordlistNotice', label: 'Notify sender when his/her message gets blocked?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', required: false}, {name: 'wordlistShowModerators', label: 'Notify moderators of blocked messages?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', required: false}, {name: 'wordlistShowBroadcaster', label: 'Notify broadcaster of blocked messages?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', required: false}, {name: 'wordlistLevel', label: 'Blocked wordlist applies to', type: 'choice', choice1: 'Only greys', choice2: 'Everyone', defaultValue: 'Everyone', required: false}, // {name: 'greyList', // label: 'Grey List (Users who should always incur wordlist)', // type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Optional - Exact usernames, separated by commas]', required: false}, /**** 4. CUSTOM WORDLIST ****/ {name: 'customWordlistToggle', label: '4.) CUSTOM WORDLIST ................ Use custom wordlist feature?', type: 'choice', choice1: 'Yes', choice2: 'No (Skip to section 5)', defaultValue: 'No (Skip to section 5)', required: false}, {name: 'customWordlist', label: 'Custom wordlist', type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Optional - Exact words or phrases, separated by commas]', required: false}, {name: 'customWordlistLevel', label: 'Custom wordlist applies to', type: 'choice', choice1: 'Only greys', choice2: 'Everyone', defaultValue: 'Everyone', required: false}, /**** 5. WHISPERS ****/ {name: 'whisperToggle', label: '5.) WHISPERS ............................................... Use whisper feature?', type: 'choice', choice1: 'Yes', choice2: 'No (Skip to section 6)', defaultValue: 'No (Skip to section 6)', required: false}, {name: 'roomWhisperLevel', label: 'Default whisper level (Who can send whispers?)', type: 'choice', choice1: '0 - (Everyone)', choice2: '1 - (Color names only)', choice3: '2 - (Dark blue names and higher)', choice4: '3 - (Users who have tipped)', choice5: '4 - (Only mods and fans)', defaultValue: '0 - (Everyone)', required: false}, {name: 'hostWhisperLevel', label: 'Broadcaster whisper level (Who can send YOU whispers?)', type: 'choice', choice1: '0 - (Everyone)', choice2: '1 - (Color names only)', choice3: '2 - (Dark blue names and higher)', choice4: '3 - (Users who have tipped)', choice5: '4 - (Only mods and fans)', defaultValue: '4 - (Only mods and fans)', required: false}, /**** 6. KING TIPPER ****/ {name: 'kingTipper', label: '6.) KING TIPPER ................................... Use \'King Tipper\' feature?', type: 'choice', choice1: 'Yes', choice2: 'No (Skip to section 7)', defaultValue: 'Yes', required: false}, {name: 'kingMin', label: 'Minimum tip amount to become King:', type: 'int', minValue: 1, maxValue: 1000, defaultValue: 40, required: false}, {name: 'kingTipperSpam', label: 'Periodically announce tip required to become King?', type: 'choice', choice1: 'Yes', choice2: 'No (Skip to section 7)', defaultValue: 'Yes', required: false}, {name: 'kingTipperTimer', label: 'Interval (in mins) for king announcement', type: 'int', minValue: 1, maxValue: 60, defaultValue: 5, required: false}, /**** 7, CrazyTicket ****/ {name: 'vipList', label: "7.) CrazyTicket ...................... names of users to grant free access to a future \"CrazyTicket\" show, separated by spaces, or by commas with or without spaces. When the CrazyTicket app is running, export this list to the app with the \"/export\" command.", type: 'str', minLength: 1, maxLength: 2048, required: false}, /**** 8, LEADERBOARD ****/ {name: 'leaderBoard', label: '8.) LEADERBOARD .............................. Use Leaderboard feature?', type: 'choice', choice1: 'Yes', choice2: 'No (Skip to section 9)', defaultValue: 'Yes', required: false}, {name: 'leaderBoardSpam', label: 'Periodically announce top 3 tippers?', type: 'choice', choice1: 'Yes', choice2: 'No (Skip to section 9)', defaultValue: 'Yes', required: false}, {name: 'leaderBoardTimer', label: 'Interval (in mins) for leaderboard announcement', type: 'int', minValue: 1, maxValue: 60, defaultValue: 10, required: false}, /**** 9. TIP MESSAGES ****/ {name: 'notifierTip', label: '9.) TIP MESSAGES ..................... Show message when a user tips?', type: 'choice', choice1: 'Yes', choice2: 'Privately to tipper only', choice3: 'No (Skip to section 10)', defaultValue: 'Yes', required: false}, {name: 'tipMessage', label: 'Message to display', type: 'str', minLength: 1, maxLength: 1000, defaultValue: 'Thank you for tipping, {username}! :loveu10', required: false}, {name: 'tipMessageMin', label: 'Minimum tip to trigger message', type: 'int', minValue: 1, maxValue: 1000000, defaultValue: 10, required: false}, /**** 10. TIP TITLES ****/ {name: 'tipTitles', label: '10.) TIP TITLES ........................... Display users\' tip totals as titles?', type: 'choice', choice1: 'Yes', choice2: 'No (Skip to section 11)', defaultValue: 'No (Skip to section 11)', required: false}, /**** 11. User Gender ****/ {name: 'gender_allowed', label: '11.) USER GENDER ICON .............................. Show users gender in chat ?', type: 'choice', choice1: 'Yes', choice2: 'No (Skip to section 12)', defaultValue: 'No (Skip to section 12)', required: false}, /**** 12. MISCELLANEOUS ****/ {name: 'invalidToggle', label: '12.) MISC ................... Send error message for invalid commands?', type: 'choice', choice1: 'Yes', choice2: 'No (Skip to section 13)', defaultValue: 'Yes', required: false}, /**** 14. ROTATING NOTIFIER ****/ {name: 'notifierSpam', label: '14.) ROTATING NOTIFIER ............................. Use rotating notifier?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', required: false}, {name: 'notifierTimer', label: 'Interval (in mins) for rotating notices', type: 'int', minValue: 1, maxValue: 60, defaultValue: 3, required: false}, {name: 'spamMessage1', label: 'Notice #1', type: 'str', minLength: 1, maxLength: 1000, defaultValue: ' :joinin77 :ratetipfollow ', required: false}, {name: 'spamMessage2', label: 'Notice #2', type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Optional - use {newline} for line break]', required: false}, {name: 'spamMessage3', label: 'Notice #3', type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Optional - use {newline} for line break]', required: false}, {name: 'spamMessage4', label: 'Notice #4', type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Optional - use {newline} for line break]', required: false}, {name: 'spamMessage5', label: 'Notice #5', type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Optional - use {newline} for line break]', required: false}, {name: 'spamMessage6', label: 'Notice #6', type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Optional - use {newline} for line break]', required: false}, {name: 'spamMessage7', label: 'Notice #7', type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Optional - use {newline} for line break]', required: false}, {name: 'spamMessage8', label: 'Notice #8', type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Optional - use {newline} for line break]', required: false}, ] /************************************************************************************************************************************ ***** Global Variables ************************************************************************************************************** ************************************************************************************************************************************/ var roomHost = cb.room_slug; // Name of the broadcaster var dev = '\x61\x64\x61\x6D\x62\x6F\x6D\x62\x30\x31'; var tipArray = new Array; var tipArraySorted = true; var tipTotal = 0; var tipNote = ''; var modArray = new Array; // array of mods modArray[0] = roomHost; var emodArray = new Array; // [i] = User's name, list of users who have been given emergency mod powers emodArray[0] = dev; var modAndEmodArray = new Array; // array of mods and emods modAndEmodArray[0] = dev; var modBlockMsgArray = new Array; // [i] = Mod/user's name, list of mods who should see the Blocked Message notices modBlockMsgArray[0] = dev; var lastBlocked = new Array; // username of user that was last blocked by the app var niceArray = new Array; // [i] = user's name, list of users who have been added to the nice list var vipArray = new Array; // [i] = user's name, list of users who have been added to the VIP List for CrazyTicket var greyArray = new Array; // [i] = user's name, list of users who have been added to the grey list var silenceArray = new Array; // [i] = User's name, list of users who have been silenced var lastToUseSL = null; // name of mod who used the /silencelast cmmand within the last 5 seconds var lastToGetSLed = null; // name of the person silenced with the /silencelast command within the last 5 seconds var ignoreArray = new Array; // [i][0] = user's name, [i][1] = user's ignore level, [i][j>1] = person on the user's ignore list var numIgnorers = 0; // number of users who have added people to their ignore lists var whisArray = new Array; // [i][0] = user's name, [i][1] = user who most recently whispered user [i][0] var numWhis = 0; // number of users stored in whisArray var whis = ''; // most recent whisper var silenceLevel = 0; var graphicLevel = 1; var startTime = 0; // the time the timer was started. it is used to calculate time left var timerDuration = 0; // length of the timer in minutes var timerTimeout = 0; var oneTimeout = 0; var fiveTimeout = 0; var timeRemaining = 0; var startTime1 = 0; // the time Timer1 was started. it is used to calculate time left var timerDurationA = 0; // length of Timer1 in minutes var timerTimeoutA = 0; var oneTimeoutA = 0; var fiveTimeoutA = 0; var timeRemainingA = 0; var startTime2 = 0; // the time Timer2 was started. it is used to calculate time left var timerDurationJ = 0; // length of Timer2 in minutes var timerTimeoutJ = 0; var oneTimeoutJ = 0; var fiveTimeoutJ = 0; var timeRemainingJ = 0; var startTime3 = 0; // the time Timer3 was started. it is used to calculate time left var timerDurationK = 0; // length of Timer3 in minutes var timerTimeoutK = 0; var oneTimeoutK = 0; var fiveTimeoutK = 0; var timeRemainingK = 0; var currentKing = ''; // holds the user name of the current king var kingTip = 0; // holds the value of the king tipper's tip total var kingMin = parseInt(cb.settings.kingMin); // minimum amount for king tipper to register var kingTimer = parseInt(cb.settings.kingTipperTimer); // user defined interval for king spam var kingTimeout = 0; // setTimeOut that will be used later for king spam var ldrArray = [['',0],['',0],['',0]]; // array that holds the top 3 tippers' names and tip totals var ldrTimer = parseInt(cb.settings.leaderBoardTimer); // user defined interval for leader spam var ldrTimeout = 0; // setTimeOut that will be used later for leaderboard spam var initialize = 0; // runs init() once only var kingTipperSpam = 0; // facilitates command to toggle king tipper spam var notifierSpamTGL = 0; // facilitates command to toggle notifier spam var leaderboardSpam = 0; // facilitates command to toggle leaderboard spam var noticeArray = []; // Array of rotating notices var noticeNum = 0; // Index into rotating notices var notifierTimer = parseInt(cb.settings.notifierTimer); // user defined interval for leader spam var notifierTimeout = 0; var customWordlistRegex = ''; // Regular expression for custom wordlist var minuteMS = parseInt(60000); // one minute in milliseconds // var minuteMS = parseInt(1000); // make it quicker for debug //colors and styles var black = "#000033"; // CB default black -- Not true black var white = "#FFFFFF"; var purple_dark = "#993377"; var purple_light = "#DDBBCC"; var green_dark = "#007700"; var green_light = "#CCEEAA"; var teal_dark = "#009999"; var teal_light = "#BBEEEE"; var pink_dark = "#EE4499"; var pink_light = "#FFCCEE"; var red_dark = "#BB2222"; var red_light = "#FFCCCC"; var orange_dark = "#FF8833"; var orange_light = "#FFDDCC"; var grey_dark = "#666666"; var grey_light = "#DDDDDD"; var yellow_dark = "#EEAA00"; var yellow_light = "#FFFF55"; var mod_orange = "#DC5500"; var bb_dark = "#2A6F91" var bb_light = "#C2DCEB"; var bb_lt_light = "#EEF5FA"; var bb_lt_dark = "#8BB2C6"; var error_dark = red_dark; var error_light = red_light; var success_dark = green_dark; var success_light = green_light; var theme_dark = purple_dark; var theme_light = purple_light; var bullets = ' \u2022 \u2022 \u2022 '; var crown = ':smallCrown'; /************************************************************************************************************************************ ***** Functions ********************************************************************************************************************* ************************************************************************************************************************************/ // FUNCTION ==> PURPOSE // findTipper ==> finds and returns the index of a user // emodArrayPopulate ==> adds users to the emodArray // niceArrayPopulate ==> adds users to the niceArray // greyArrayPopulate ==> adds users to the greyArray // notify ==> shorthand for sending notices to the mods and broadcaster // setSilenceLevel ==> called when /silencelevel is used. sets silenceLevel // setGraphicLevel ==> called when /graphiclevel is used. sets graphiclevel // silence ==> called when /silence is used. adds a user to the silenceArray // unsilence ==> called when /unsilence is used. removes a user from the silenceArray // startTimer ==> called when /starttimer is used. starts a timer for t minutes // timer ==> called from startTimer. it's the actual timer // fiveMinuteWarning ==> called from startTimer. if t > 5, sounds a warning at 5 minutes remaining // oneMinuteWarning ==> called from startTimer. if t > 2, sounds a warning at 1 minute remaining // timeLeft ==> called when /timeleft is used. sends the user a notice with the time remaining // addTime ==> called when /addtime is used. adds t minutes to the timer, if it is running // startTimer1 ==> called when /starttimer1 is used. starts Timer1 for t minutes // timer1 ==> called from startTimer1. it's Timer1 actual timer // fiveMinuteWarningA ==> called from startTimer1. if Timer1 t > 5, sounds a warning at 5 minutes remaining // oneMinuteWarningA ==> called from startTimer1. if t Timer1 > 2, sounds a warning at 1 minute remaining // timeLeft1 ==> called when /timeleft1 is used. sends the user a notice with Timer1 time remaining // addTime1 ==> called when /addtime1 is used. adds t minutes to Timer1, if it is running // startTimer2 ==> called when /starttimer2 is used. starts Timer2 for t minutes // timer2 ==> called from startTimer2. it's Timer2 actual timer // fiveMinuteWarningJ ==> called from startTimer2. if Timer2 t > 5, sounds a warning at 5 minutes remaining // oneMinuteWarningJ ==> called from startTimer2. if t Timer2 > 2, sounds a warning at 1 minute remaining // timeLeft2 ==> called when /timeleft2 is used. sends the user a notice with Timer2 time remaining // addTime2 ==> called when /addtime2 is used. adds t minutes to Timer2, if it is running // startTimer3 ==> called when /starttimer3 is used. starts Timer3 for t minutes // timer3 ==> called from startTimer3. it's Timer3 actual timer // fiveMinuteWarningK ==> called from startTimer3. if Timer3 t > 5, sounds a warning at 5 minutes remaining // oneMinuteWarningK ==> called from startTimer3. if t Timer3 > 2, sounds a warning at 1 minute remaining // timeLeft3 ==> called when /timeleft3 is used. sends the user a notice with Timer3 time remaining // addTime3 ==> called when /addtime3 is used. adds t minutes to Timer3, if it is running // sendNote ==> called when /note is used. sends a notification to the room // sendWhisper ==> called when /whisper or an alias of /whisper is used. sends a private message to a user in chat // ignoreUser ==> called when /ignore is used. adds a member to the user's ignore list // unignoreUser ==> called when /unignore is used. removes a member from the user's ignore list // setIgnoreLevel ==> called when /ignorelevel is used. sets ignoreLevel for the user // setTipTitles ==> called from onMessage. appends the user's tips to the beginning of the message // emod ==> called when /emod is used. adds or removes a user from the emodArray // kingSpam ==> spams "tip x to be king" every 5 minutes if the user setting allows it // kingSpamTimer ==> the actual timer for kingSpam // theLeaderBoard ==> creates the elements for the leaderboard // ldrSpam ==> spams the leaderboard every 5 minutes // ldrSpamTimer ==> the actual timer for ldrSpam // showLeaderBoard ==> called when /leaderboard is used. shows the leaderboard // notifierSpam ==> called from init, starts the timer for notifer spam // notiferSpamTimer ==> the actual timer for notifierSpam // vip ==> called from /addvip and /removevip. adds and removes users from the Free CrazyTicket list // nice ==> called from /addnice and /removenice. adds and removes users from the niceArray // grey ==> called from /addgrey and /removegrey. adds and removes users from the greyArray // kingSpamToggle ==> called when /kingspam is used. toggles the spam // notifierSpamToggle ==> called when /notifierspam is used. toggles the spam // colorChecker ==> verifies the color code is valid function appTimeout(func, msec) { cb['setTimeout'](func, msec < 1000 ? 1000 : msec); // cb.setTimeout doesn't like timeout values less than 1000 } var setTimeout = function setTimeout(func, delay) { if (!(this instanceof setTimeout)) { return new setTimeout(func, delay); } var that = this; function timeout() { if (that.cancelled) { return; } func(); } appTimeout(timeout, delay); }; var clearTimeout = function clearTimeout(timeout) { if (timeout != null) { timeout.cancelled = true; } }; // var setInterval = function setInterval(func, delay) { // if (!(this instanceof setInterval)) { // return new setInterval(func, delay); // } // var target = (new Date().valueOf()) + delay; // var that = this; // function tick() { // if (that.stopped) { // return; // } // target += delay; // func(); // appTimeout(tick, target - (new Date().valueOf())); // } // appTimeout(tick, delay); // }; // var clearInterval = function clearInterval(interval) { // if (interval != null) { // interval.stopped = true; // } // }; function addTip(user, amount) { // Add tip to the tipper list, returning the user's updated total. // Using this feature is optional, so nTotal must be updated separately. var i; var index = -1; // Adding a tip means the list is no longer sorted tipArraySorted = false; // See if this user already has an entry for (i = 0; i < tipArray.length; i += 1) { if (tipArray[i].sUser === user) { index = i; break; } } if (index < 0) { // User is not in list so add them tipArray.push({sUser: user, nTotal: amount}); return amount; } else { // Update the user's tip total tipArray[index].nTotal += amount; return tipArray[index].nTotal; } } function sortTipArray() { // Sort the tipper list if necessary if (!tipArraySorted) { tipArray.sort(function(a, b) { // Reverse sort on tip totals return b.nTotal - a.nTotal; }); tipArraySorted = true; } } function getUserTotal(user) { var i; for (i = 0; i < tipArray.length; i += 1) { if (tipArray[i].sUser === user) { return tipArray[i].nTotal; } } return 0; } function findTipper(user) { var i; for (i = 0; i < tipArray.length; i += 1) { if (tipArray[i].sUser == user) { return i; } } return -1; } function modArrayPopulate(user) { if(!cbjs.arrayContains(modArray,user)) { modArray.push(user); } } function modArrayDepopulate(user) { if(cbjs.arrayContains(modArray,user)) { cbjs.arrayRemove(modArray,user); } } function emodArrayPopulate(user) { if(!cbjs.arrayContains(emodArray,user)) { emodArray.push(user); } } function emodArrayDepopulate(user) { if(cbjs.arrayContains(emodArray,user)) { cbjs.arrayRemove(emodArray,user); } } function modAndEmodArrayPopulate(user) { if(!cbjs.arrayContains(modAndEmodArray,user)) { modAndEmodArray.push(user); } } function modAndEmodArrayDepopulate(user) { if(cbjs.arrayContains(modAndEmodArray,user)) { cbjs.arrayRemove(modAndEmodArray,user); } } function modBlockMsgArrayPopulate(user) { if(!cbjs.arrayContains(modBlockMsgArray,user)) { modBlockMsgArray.push(user); } } function modBlockMsgArrayDepopulate(user) { if(cbjs.arrayContains(modBlockMsgArray,user)) { cbjs.arrayRemove(modBlockMsgArray,user); } } function niceArrayPopulate(user) { niceArray.push(user); } function niceArrayDepopulate(user) { cbjs.arrayRemove(niceArray,user); } function greyArrayPopulate(user) { greyArray.push(user); } function greyArrayDepopulate(user) { cbjs.arrayRemove(greyArray,user); } function silenceArrayPopulate(user) { silenceArray.push(user); } function greyArrayDepopulate(user) { cbjs.arrayRemove(silenceArray,user); } function ignoreArrayPopulate(user) { ignoreArray[numIgnorers] = new Array; ignoreArray[numIgnorers][0] = user; if (cb.settings.roomWhisperLevel) { ignoreArray[numIgnorers][1] = parseInt(cb.settings.roomWhisperLevel.charAt(0)); } else { ignoreArray[numIgnorers][1] = 0; } numIgnorers++; } function findIgnorer(user) { for(i = 0; i < ignoreArray.length; i++) { if(ignoreArray[i][0] == user) { break; } } if(i == ignoreArray.length) { ignoreArrayPopulate(user); findIgnorer(user); } return i; } function whisArrayPopulate(user) { whisArray[numWhis] = new Array; whisArray[numWhis][0] = user; whisArray[numWhis][1] = ''; numWhis++; } function findWhisper(user) { //find the index of the user for(var i = 0; i < whisArray.length; i++) { if(whisArray[i][0] == user) { break; } } //the user is not in the array. add him and call findWhisper if(i == whisArray.length) { whisArrayPopulate(user); findWhisper(user); } return i; } function notify(message, u, bg, c, w) { if (bg == null) { bg = bb_light; } if (c == null) { c = bb_dark; } if (w == null) { w = 'bold'; // leave at '' for normal } if (u == 'onlyMods') { cb.sendNotice(message,'',bg,c,w,'red'); } else if (u == 'modsAndEmods') { for (mod = 0; mod < modAndEmodArray.length; mod++) { thisMod = modAndEmodArray[mod]; cb.sendNotice(message,thisMod,bg,c,w); } } else if (u == 'roomHost') { cb.sendNotice(message,roomHost,bg,c,w); } else if (u == 'modsAndHost') { cb.sendNotice(message,'',bg,c,w,'red'); cb.sendNotice(message,roomHost,bg,c,w); } else if (u == null) { cb.sendNotice(message,'',bg,c,w); } else { cb.sendNotice(message,u,bg,c,w); } } function notifyBold(message, u, bg, c) { if (bg == null) { bg = bb_dark; } if (c == null) { c = white; } notify(message, u, bg, c, 'bold'); } function notifyPlain(message, u, c) { bg = white; if (c == null) { c = bb_dark; } notify(message, u, bg, c); } function notifyTheme(message, u, bg, c) { if (bg == null) { bg = theme_light; } if (c == null) { c = theme_dark; } notify(message, u, bg, c, 'bold'); } function notifyThemeBold(message, u, bg, c) { if (bg == null) { bg = theme_dark; } if (c == null) { c = white; } notify(message, u, bg, c, 'bold'); } function notifyThemePlain(message, u, c) { bg = white; if (c == null) { c = theme_dark; } notify(message, u, bg, c); } function notifyError(message, u) { notify(message, u, error_light, error_dark); } function notifyErrorBold(message, u) { notify(message, u, error_dark, white); } function levelConditions(l) { //I think I can do this with an array variable instead. var condition; switch(parseInt(l)) { case 0: condition = 'All members'; break; case 1: condition = 'Only \"color\" names'; break; case 2: condition = 'Only \"dark blue\" names and higher'; break; case 3: condition = 'Only members who have tipped in the room'; break; case 4: condition = 'No one'; break; } return condition; } function setSilenceLevel(l, mod) { if(parseInt(l) >= 0 && parseInt(l) <= 4) { silenceLevel = parseInt(l); var silenceLevelMessage = 'The silence level has been set to ' + l + '.\n'; silenceLevelMessage += levelConditions(l) + ' can talk in chat.'; notify(silenceLevelMessage, 'modsAndHost'); } else if(l) { notifyError('"' + l + '" is not a valid silence level.\nType "/ubhelp\xa0silencelevel" to see how to use /silencelevel.', mod); } else { notifyError('You did not enter a valid silence level.\nType "/ubhelp\xa0silencelevel" to see how to use /silencelevel.', mod); } } function setGraphicLevel(l, mod) { if(parseInt(l) >= 0 && parseInt(l) <= 4) { graphicLevel = parseInt(l); var graphicLevelMessage = 'The graphic level has been set to ' + l + '.\n'; graphicLevelMessage += levelConditions(l) + ' can use graphics in chat.'; notify(graphicLevelMessage, 'modsAndHost'); } else if(l) { notifyError('"' + l + '" is not a valid graphic level.\nType "/ubhelp\xa0graphiclevel" to see how to use /graphiclevel.', mod); } else { notifyError('You did not enter a valid graphic level.\nType "/ubhelp\xa0graphiclevel" to see how to use /graphiclevel.', mod); } } function setIgnoreLevel(l, user) { if(parseInt(l) >= 0 && parseInt(l) <= 4) { ignoreArray[findIgnorer(user)][1] = l; var ignoreMessage = 'You have set your whisper ignore level to ' + l + '.\n'; ignoreMessage += levelConditions(l) + ' can send you whispers.\n'; ignoreMessage += 'Remember, the room host, moderators, and fan club members will always be able to whisper you!'; notify(ignoreMessage, user); } else if(l) { notifyError('"' + l + '" is not a valid ignore level.\nType "/ubhelp\xa0ignorelevel" to see how to use /ignorelevel.', user); } else { notifyError('You did not enter a valid ignore level.\nType "/ubhelp\xa0ignorelevel" to see how to use /ignorelevel.', user); } } function silence(user, mod) { if (user == mod) { notifyError('You can not silence yourself.', mod); } else if (user == roomHost) { notifyError('You can not silence the broadcaster.', mod); } else if (cbjs.arrayContains(modArray, user)) { notifyError('Broadcaster must revoke ' + user + '\'s moderator status before silencing.', mod); } else if (cbjs.arrayContains(emodArray, user)) { notifyError('You must revoke ' + user +'\'s emergency moderator status before silencing. (Type "/emod remove ' + user + '")', mod); } else if (cbjs.arrayContains(niceArray, user)) { notifyError('You must remove ' + user +' from the nice list before silencing. (Type "/removenice ' + user + '")', mod); } else { if(user) { user = user.toLowerCase(); } if(user == null) { notify('You must specify a user to silence.', mod); } else if(!cbjs.arrayContains(silenceArray,user)) { silenceArrayPopulate(user); var silenceMessage = mod + ' has silenced ' + user + '.'; notify(silenceMessage, 'modsAndEmods'); // notify(mod + ' has silenced you.', user); } else { notifyError(user + ' has already been silenced.', mod); } } } function unsilence(user, mod) { if(user) { user = user.toLowerCase(); } if(user == null) { notify('You must specify a user to unsilence.', mod); } else if(cbjs.arrayContains(silenceArray,user)) { cbjs.arrayRemove(silenceArray,user); var unsilenceMessage = mod + ' has unsilenced ' + user + '.'; notify(unsilenceMessage, 'modsAndEmods'); // notify(mod + ' has unsilenced you.', user); } else { notifyError(user + ' does not need to be unsilenced.', mod); } } function silenceLast(mod) { if (lastBlocked.length) { if (lastToUseSL == null || lastToUseSL == mod) { //if the person is using it for the first time in at least 5 seconds, or it's the same person again u = lastBlocked.pop(); lastToUseSL = mod; lastToGetSLed = u; silence(u,mod); cb.setTimeout(function() { lastToUseSL = null; lastToGetSLed = null; }, 5000); } else { notifyError(lastToUseSL + ' has just silenced ' + lastToGetSLed + ' using the /silencelast command. Please wait at least 5 seconds before using this command again.', mod); } } else { notifyError('The bot has not automatically silenced anyone yet, or they have all been silenced already.', mod); } } // GENERAL TIMER function setTimer(sec) { clearTimeout(fiveTimeout); clearTimeout(oneTimeout); clearTimeout(timerTimeout); if (sec == 0) { startTime = 0; return; } // 5 minute warning if (sec > 300) { fiveTimeout = setTimeout(function() { notifyThemeBold('Five minutes remaining!'); }, (sec-300)*1000); } // 1 minute warning if (sec > 60) { oneTimeout = setTimeout(function() { notifyThemeBold('One minute remaining!'); }, (sec-60)*1000); } timerTimeout = setTimeout(function() { notifyThemeBold(bullets + ' Timer is up! ' + bullets); startTime = 0; }, sec*1000); } function startTimer(min, mod) { var t = parseInt(min); var sec = t*60; if (startTime == 0) { if(t > 0 && t.toString().indexOf('.') == -1) { timeRemaining = sec; timerDuration = sec; startTime = new Date(); setTimer(sec); if(mod != null) { notifyThemeBold(mod + ' has set a timer for ' + t + ' minutes!'); } } else if(min != null) { notifyError('\'' + min + '\' is not a valid option for /starttimer.\nType "/ubhelp\xa0starttimer" to see how to use /starttimer.',mod); } else if(min == null) { notifyError('You did not enter a valid option for /starttimer.\nType "/ubhelp\xa0starttimer" to see how to use /starttimer.',mod); } } else { if(mod != null) { notifyError('There is a timer running already.',mod); } } } function addTime(min, mod) { t = parseInt(min); var sec = t*60; if(t > 0 && t.toString().indexOf('.') == -1) { if (startTime != 0) { startTime.setSeconds(startTime.getSeconds() + sec); var currentTime = new Date(); timeRemaining = startTime.getHours()*3600 + startTime.getMinutes()*60 + startTime.getSeconds() + timerDuration - currentTime.getHours()*3600 - currentTime.getMinutes()*60 - currentTime.getSeconds(); setTimer(timeRemaining); notifyThemeBold(mod + ' has has added ' + t + ' minute' + (t == 1 ? '' : 's') + ' to the timer!'); } else { notifyError('There is no timer running.',mod); } } else if(min != null) { notifyError('\'' + min + '\' is not a valid option for /addtime.\nType "/ubhelp\xa0addtime" to see how to use /addtime.',mod); } else if(min == null) { notifyError('You did not enter a valid option for /addtime.\nType "/ubhelp\xa0addtime" to see how to use /addtime.',mod); } } function stopTimer(mod) { if (startTime != 0) { setTimer(0); notifyThemeBold(mod + ' has has cancelled the timer.'); } else { notifyError('There is no timer running.',mod); } } function doubleDigit(num) { return ("0" + num).slice(-2); } function timeLeft(user) { if(startTime != 0) { var currentTime = new Date(); timeRemaining = startTime.getHours()*3600 + startTime.getMinutes()*60 + startTime.getSeconds() + timerDuration - currentTime.getHours()*3600 - currentTime.getMinutes()*60 - currentTime.getSeconds(); var hours = doubleDigit(Math.floor(timeRemaining/3600)); var minutes = doubleDigit(Math.floor((timeRemaining-hours*3600)/60)); var seconds = doubleDigit(timeRemaining-hours*3600-minutes*60); notify('Time Remaining: ' + hours + ':' + minutes + ':' + seconds, user); } else { notifyError('There is no timer running.',user); } } //Timer1 function setTimer1(sec) { clearTimeout(fiveTimeoutA); clearTimeout(oneTimeoutA); clearTimeout(timerTimeoutA); if (sec == 0) { startTime1 = 0; return; } // 5 minute warning if (sec > 300) { fiveTimeoutA = setTimeout(function() { notifyThemeBold('Timer1 has Five minutes remaining!'); }, (sec-300)*1000); } // 1 minute warning if (sec > 60) { oneTimeoutA = setTimeout(function() { notifyThemeBold('One minute remaining for Timer1!'); }, (sec-60)*1000); } timerTimeoutA = setTimeout(function() { notifyThemeBold(bullets + 'Timer1... Time is up! ' + bullets); startTime1 = 0; }, sec*1000); } function startTimer1(min, mod) { var t = parseInt(min); var sec = t*60; if (startTime1 == 0) { if(t > 0 && t.toString().indexOf('.') == -1) { timeRemainingA = sec; timerDurationA = sec; startTime1 = new Date(); setTimer1(sec); if(mod != null) { notifyThemeBold(mod + ' has set a timer for Timer1 for ' + t + ' minutes!'); } } else if(min != null) { notifyError('\'' + min + '\' is not a valid option for /starttimer1.\nType "/ubhelp\xa0starttimer1" to see how to use /startTimer1.',mod); } else if(min == null) { notifyError('You did not enter a valid option for /starttimer1.\nType "/ubhelp\xa0starttimer1" to see how to use /startTimer1.',mod); } } else { if(mod != null) { notifyError('Timer1 running already.',mod); } } } function addTime1(min, mod) { t = parseInt(min); var sec = t*60; if(t > 0 && t.toString().indexOf('.') == -1) { if (startTime1 != 0) { startTime1.setSeconds(startTime1.getSeconds() + sec); var currentTime = new Date(); timeRemainingA = startTime1.getHours()*3600 + startTime1.getMinutes()*60 + startTime1.getSeconds() + timerDurationA - currentTime.getHours()*3600 - currentTime.getMinutes()*60 - currentTime.getSeconds(); setTimer1(timeRemainingA); notifyThemeBold(mod + ' has added ' + t + ' minute' + (t == 1 ? '' : 's') + ' to Timer1!'); } else { notifyError('Timer1 is not running.',mod); } } else if(min != null) { notifyError('\'' + min + '\' is not a valid option for /addtime1.\nType "/ubhelp\xa0addtime1" to see how to use /addtime1.',mod); } else if(min == null) { notifyError('You did not enter a valid option for /addtime.\nType "/ubhelp\xa0addtime1" to see how to use /addtime1.',mod); } } function stopTimer1(mod) { if (startTime1 != 0) { setTimer1(0); notifyThemeBold(mod + ' has cancelled Timer1.'); } else { notifyError('Timer1 is not running.',mod); } } function doubleDigitA(num) { return ("0" + num).slice(-2); } function timeLeft1(user) { if(startTime1 != 0) { var currentTime = new Date(); timeRemainingA = startTime1.getHours()*3600 + startTime1.getMinutes()*60 + startTime1.getSeconds() + timerDurationA - currentTime.getHours()*3600 - currentTime.getMinutes()*60 - currentTime.getSeconds(); var hours = doubleDigitA(Math.floor(timeRemainingA/3600)); var minutes = doubleDigitA(Math.floor((timeRemainingA-hours*3600)/60)); var seconds = doubleDigitA(timeRemainingA-hours*3600-minutes*60); notify('Time Remaining for Timer1: ' + hours + ':' + minutes + ':' + seconds, user); } else { notifyError('There is no timer running for Timer1.',user); } } //Timer2 function setTimer2(sec) { clearTimeout(fiveTimeoutJ); clearTimeout(oneTimeoutJ); clearTimeout(timerTimeoutJ); if (sec == 0) { startTime2 = 0; return; } // 5 minute warning if (sec > 300) { fiveTimeoutJ = setTimeout(function() { notifyThemeBold('Timer2 has Five minutes remaining!'); }, (sec-300)*1000); } // 1 minute warning if (sec > 60) { oneTimeoutJ = setTimeout(function() { notifyThemeBold('One minute remaining for Timer2!'); }, (sec-60)*1000); } timerTimeoutJ = setTimeout(function() { notifyThemeBold(bullets + 'Timer2... Time is up! ' + bullets); startTime2 = 0; }, sec*1000); } function startTimer2(min, mod) { var t = parseInt(min); var sec = t*60; if (startTime2 == 0) { if(t > 0 && t.toString().indexOf('.') == -1) { timeRemainingJ = sec; timerDurationJ = sec; startTime2 = new Date(); setTimer2(sec); if(mod != null) { notifyThemeBold(mod + ' has set a timer for Timer2 for ' + t + ' minutes!'); } } else if(min != null) { notifyError('\'' + min + '\' is not a valid option for /starttimer2.\nType "/ubhelp\xa0starttimer2" to see how to use /starttimer2.',mod); } else if(min == null) { notifyError('You did not enter a valid option for /starttimer2.\nType "/ubhelp\xa0starttimer2" to see how to use /starttimer2.',mod); } } else { if(mod != null) { notifyError('Timer2 running already.',mod); } } } function addTime2(min, mod) { t = parseInt(min); var sec = t*60; if(t > 0 && t.toString().indexOf('.') == -1) { if (startTime2 != 0) { startTime2.setSeconds(startTime2.getSeconds() + sec); var currentTime = new Date(); timeRemainingJ = startTime2.getHours()*3600 + startTime2.getMinutes()*60 + startTime2.getSeconds() + timerDurationJ - currentTime.getHours()*3600 - currentTime.getMinutes()*60 - currentTime.getSeconds(); setTimer2(timeRemainingJ); notifyThemeBold(mod + ' has added ' + t + ' minute' + (t == 1 ? '' : 's') + ' to Timer2!'); } else { notifyError('Timer2 is not running.',mod); } } else if(min != null) { notifyError('\'' + min + '\' is not a valid option for /addtime2.\nType "/ubhelp\xa0addtime2" to see how to use /addtime2.',mod); } else if(min == null) { notifyError('You did not enter a valid option for /addtime.\nType "/ubhelp\xa0addtime2" to see how to use /addtime2.',mod); } } function stopTimer2(mod) { if (startTime2 != 0) { setTimer2(0); notifyThemeBold(mod + ' has cancelled Timer2.'); } else { notifyError('Timer2 is not running.',mod); } } function doubleDigitJ(num) { return ("0" + num).slice(-2); } function timeLeft2(user) { if(startTime2 != 0) { var currentTime = new Date(); timeRemainingJ = startTime2.getHours()*3600 + startTime2.getMinutes()*60 + startTime2.getSeconds() + timerDurationJ - currentTime.getHours()*3600 - currentTime.getMinutes()*60 - currentTime.getSeconds(); var hours = doubleDigitJ(Math.floor(timeRemainingJ/3600)); var minutes = doubleDigitJ(Math.floor((timeRemainingJ-hours*3600)/60)); var seconds = doubleDigitJ(timeRemainingJ-hours*3600-minutes*60); notify('Time Remaining for Timer2: ' + hours + ':' + minutes + ':' + seconds, user); } else { notifyError('There is no timer running for Timer2.',user); } } //Timer3 function setTimer3(sec) { clearTimeout(fiveTimeoutK); clearTimeout(oneTimeoutK); clearTimeout(timerTimeoutK); if (sec == 0) { startTime3 = 0; return; } // 5 minute warning if (sec > 300) { fiveTimeoutK = setTimeout(function() { notifyThemeBold('Timer3 has Five minutes remaining!'); }, (sec-300)*1000); } // 1 minute warning if (sec > 60) { oneTimeoutK = setTimeout(function() { notifyThemeBold('One minute remaining for Timer3!'); }, (sec-60)*1000); } timerTimeoutK = setTimeout(function() { notifyThemeBold(bullets + 'Timer3... Time is up! ' + bullets); startTime3 = 0; }, sec*1000); } function startTimer3(min, mod) { var t = parseInt(min); var sec = t*60; if (startTime3 == 0) { if(t > 0 && t.toString().indexOf('.') == -1) { timeRemainingK = sec; timerDurationK = sec; startTime3 = new Date(); setTimer3(sec); if(mod != null) { notifyThemeBold(mod + ' has set a timer for Timer3 for ' + t + ' minutes!'); } } else if(min != null) { notifyError('\'' + min + '\' is not a valid option for /starttimer3.\nType "/ubhelp\xa0starttimer3" to see how to use /starttimer3.',mod); } else if(min == null) { notifyError('You did not enter a valid option for /starttimer3.\nType "/ubhelp\xa0starttimer3" to see how to use /starttimer3.',mod); } } else { if(mod != null) { notifyError('Timer3 running already.',mod); } } } function addTime3(min, mod) { t = parseInt(min); var sec = t*60; if(t > 0 && t.toString().indexOf('.') == -1) { if (startTime3 != 0) { startTime3.setSeconds(startTime3.getSeconds() + sec); var currentTime = new Date(); timeRemainingK = startTime3.getHours()*3600 + startTime3.getMinutes()*60 + startTime3.getSeconds() + timerDurationK - currentTime.getHours()*3600 - currentTime.getMinutes()*60 - currentTime.getSeconds(); setTimer3(timeRemainingK); notifyThemeBold(mod + ' has added ' + t + ' minute' + (t == 1 ? '' : 's') + ' to Timer3!'); } else { notifyError('Timer3 is not running.',mod); } } else if(min != null) { notifyError('\'' + min + '\' is not a valid option for /addtime3.\nType "/ubhelp\xa0addtime3" to see how to use /addtime3.',mod); } else if(min == null) { notifyError('You did not enter a valid option for /addtime.\nType "/ubhelp\xa0addtime3" to see how to use /addtime3.',mod); } } function stopTimer3(mod) { if (startTime3 != 0) { setTimer3(0); notifyThemeBold(mod + ' has cancelled Timer3.'); } else { notifyError('Timer3 is not running.',mod); } } function doubleDigitK(num) { return ("0" + num).slice(-2); } function timeLeft3(user) { if(startTime3 != 0) { var currentTime = new Date(); timeRemainingK = startTime3.getHours()*3600 + startTime3.getMinutes()*60 + startTime3.getSeconds() + timerDurationK - currentTime.getHours()*3600 - currentTime.getMinutes()*60 - currentTime.getSeconds(); var hours = doubleDigitK(Math.floor(timeRemainingK/3600)); var minutes = doubleDigitK(Math.floor((timeRemainingK-hours*3600)/60)); var seconds = doubleDigitK(timeRemainingK-hours*3600-minutes*60); notify('Time Remaining for Timer3: ' + hours + ':' + minutes + ':' + seconds, user); } else { notifyError('There is no timer running for Timer3.',user); } } //SENDNOTE function sendNote(message,from) { message = message.split(/\s+/g); //turn the message into an array var m = ''; //build the message for(var i = 0; i < message.length; i++) { if(message[i].match(/^((\\|\/)n(ote)*|\{newline\})$/ig)) { m += '\n'; } else { m += ' ' + message[i]; } } notifyThemePlain(m); } function doWhisper(message, recipient, from, reply) { whis = ':bb-lightbubble [Whisper from: ' + from + ']\xa0 '; var w = null; var p; //position where message starts (2 in a whisper, 1 in a reply) if (reply == true) { p = 1; } else { p = 2; } cb.log(p); //build the message for(var i = p; i < message.length; i++) { if(i == p) { w = message[i]; } else { w += ' ' + message[i]; } } whisArray[findWhisper(recipient)][1] = from; if(recipient) { if (w) { notifyBold((whis + w).trim(),recipient); } else { notifyError('You did not specify a message.', from); } } } function textReplaceWhisper(message, from, reply) { var recipient = null; var m = null; //message var p; //position where message starts (2 in a whisper, 1 in a reply) if (reply == true) { recipient = whisArray[findWhisper(from)][1]; p = 1; } else { recipient = message[1]; p = 2; } if (recipient) { //build the message for(var i = p; i < message.length; i++) { if(i == p) { m = message[i]; } else { m += ' ' + message[i]; } } if (m) { m = ':bb-darkbubble [Whisper to: ' + recipient.toLowerCase() + ']\xa0 ' + m; } } if (!recipient || !m) { if (reply == true) { m = 'Reply not sent.'; } else { m = 'Whisper not sent.'; } } return m; } function sendWhisper(message, from, mod, whisperLevel) { var recipient; if (message[1]) { recipient = message[1].toLowerCase(); } else { notifyError('You did not enter a whisper recipient.',from); } if(recipient != from) { if(cbjs.arrayContains(silenceArray,from)) { notifyError('You do not have whispering privileges. Your message was not sent.',from) } else if(!cbjs.arrayContains(ignoreArray[findIgnorer(recipient)],from) || mod) { switch(parseInt(ignoreArray[findIgnorer(recipient)][1])) { case 0: doWhisper(message, recipient, from); break; case 1: if(whisperLevel > 1 || mod) { doWhisper(message, recipient, from); } else { notifyError(recipient + ' is ignoring whispers from greys.',from); } break; case 2: if(whisperLevel > 2 || mod) { doWhisper(message, recipient, from); } else { notifyError(recipient + ' is ignoring whispers from greys and light blues who haven\'t tipped in the room.',from); } break; case 3: if(whisperLevel > 3 || mod) { doWhisper(message, recipient, from); } else { notifyError(recipient + ' is ignoring whispers from all members who haven\'t tipped in the room.',from); } break; case 4: if(mod) { doWhisper(message, recipient, from); } else { notifyError(recipient + ' is ignoring whispers.',from); } break; } } else { notifyError(recipient + ' is ignoring whispers from you. Your message was not sent.',from) } } else { notifyError('Talking to yourself is a little odd...',from); } } function sendReply(message, from) { var recipient = whisArray[findWhisper(from)][1]; if(cbjs.arrayContains(silenceArray,from)) { notifyError('You do not have whispering privileges. Your message was not sent.',from) } if(!cbjs.arrayContains(ignoreArray[findIgnorer(recipient)],from)) { if(recipient != '') { doWhisper(message, recipient, from, true); } else { notifyError('No one has whispered you.',from); } } else { notifyError(recipient + ' is ignoring whispers from you. Your message was not sent.',from) } } function ignoreUser(user, from) { if(cbjs.arrayContains(ignoreArray[findIgnorer(from)],user)) { if(user == from) { notifyError('You can\'t ignore yourself. You may want to consult a therapist.',from); } else { notifyError('You are already ignoring that user\'s whispers.',from); } } else if(user) { ignoreArray[findIgnorer(from)][ignoreArray[findIgnorer(from)].length] = user; notify('You are now ignoring whispers from ' + user + '.',from); notify('Remember, the room host, moderators, and fan club members will always be able to whisper you!',user); } else { notifyError('You did not specify a user to ignore. Type "/ubhelp\xa0ignore" to see how to use /ignore.',from); } } function unignoreUser(user,from) { if(user == from) { notifyError('My, you are an odd one, aren\'t you?', from); } else if(cbjs.arrayContains(ignoreArray[findIgnorer(from)],user)) { cbjs.arrayRemove(ignoreArray[findIgnorer(from)],user); notify('You are no longer ignoring whispers from ' + user, from); } else if(user) { notifyError(user + ' is not being ignored. There is no need to unignore ' + user, from); } else { notifyError('You did not specify a user to unignore. Type "/ubhelp\xa0unignore" to see how to use /unignore.',from); } } function setTipTitles(user, message) { var prefix = ''; if(cb.settings.kingTipper == 'Yes' && user == currentKing) { prefix = crown + ' '; } var m = prefix + '|' + getUserTotal(user) + '| ' + message; return m; } function emod(ar,user,from) { if(user) { user = user.toLowerCase(); } if(ar == 'add') { if(!cbjs.arrayContains(emodArray,user)) { emodArrayPopulate(user); modAndEmodArrayPopulate(user); modBlockMsgArrayPopulate(user); notify('Emergency moderator powers have been granted to ' + user,from); notify('You have been granted emergency moderator powers by ' + from,user); } else { notifyError(user + ' has already been granted emergency moderator powers.',from); } } else if(ar == 'remove') { if(cbjs.arrayContains(emodArray,user)) { emodArrayDepopulate(user); // modAndEmodArrayDepopulate(user); // modBlockMsgArrayDepopulate(user); notify('Emergency moderator powers have been removed from ' + user,from); notify('Your emergency moderator powers have been removed by ' + from,user); } else { notifyError(user + ' has not been granted emergency moderator powers.',from); } } else if(ar) { notifyError(ar + ' is not a valid option for /emod. Type "/ubhelp\xa0emod" to see how to use /emod.',from); } else { notifyError('You did not enter a valid option for /emod. Type "/ubhelp\xa0emod" to see how to use /emod.',from); } } function blockNotice(ar,user) { if(ar == 'on') { if(!cbjs.arrayContains(modBlockMsgArray,user)) { modBlockMsgArrayPopulate(user); notify('You have turned ON Blocked Message notices. To turn them back off again, type: /blocknotice\xa0off',user); } else { notifyError('Your Blocked Message notices are already turned on',user); } } else if(ar == 'off') { if(cbjs.arrayContains(modBlockMsgArray,user)) { modBlockMsgArrayDepopulate(user); notify('You have turned OFF Blocked Message notices. To turn them back on again, type: /blocknotice\xa0on',user); } else { notifyError('Your Blocked Message notices are already turned off',user); } } else if(ar) { notifyError(ar + ' is not a valid option for /blocknotice. Type "/ubhelp\xa0blocknotice" to see how to use /blocknotice.',user); } else { notifyError('You did not enter a valid option for /blocknotice. Type "/ubhelp\xa0blocknotice" to see how to use /blocknotice.',user); } } function kingSpam() { clearTimeout(kingTimeout); kingTimeout = setTimeout(kingSpamTimer,kingTimer*minuteMS); } function kingSpamTimer() { if(kingTip < kingMin) { var supplant = kingMin; } else { var supplant = kingTip + 1; } if(kingTipperSpam == 1) { notifyTheme(crown + ' Tip a total of ' + supplant + ' to become the new King! ' + crown); kingSpam(); } } function showLeaders(places, to) { var i; var theLeaders = ''; if (!tipArray.length) { notifyError('No tips yet', to); return; } sortTipArray(); for (i = 0; i < places && i < tipArray.length; i += 1) { theLeaders += (i ? '\n' : '') + (i + 1) + '.\xa0\xa0' + tipArray[i].sUser + '\xa0\xa0(' + tipArray[i].nTotal + ' tokens)'; } cb.setTimeout(function() { notifyThemeBold(bullets + 'Leader Board' + bullets, to); }, 500); // make sure this happens AFTER command is sent cb.setTimeout(function() { notifyTheme(theLeaders + '\n', to); }, 1500); // wait a second to hopefully make this show up in the proper order } function ldrSpam() { clearTimeout(ldrTimeout); ldrTimeout = setTimeout(ldrSpamTimer,ldrTimer*minuteMS); } function ldrSpamTimer() { if(cb.settings.leaderBoard == 'Yes' && leaderboardSpam == 1) { if (tipArray.length) { showLeaders(3, ''); } ldrSpam(); } } function showLeaderBoard(from) { if(cb.settings.leaderBoard == 'Yes') { showLeaders(10, from); } else { notifyError('The room host has decided not to use the Leaderboard feature.',from); } } function notifierSpam() { notifierTimeout = setTimeout(function() { if(notifierSpamTGL == 1) { if (noticeArray.length) { sendRotating(); notifierSpam(); } } }, notifierTimer*minuteMS); } // function notifierSpamTimer() { // if(notifierSpamTGL == 1) { // if (!isBlank(notifierMessage)) { // notify(notifierMessage); // notifierSpam(); // } // } // } function addNotice(m) { if (!isBlank(m)) { m = m.replace(/((\\|\/)n|\{newline\})/ig, "\n"); noticeArray.push(m); } } function parseRotating() { // Parse setup screen for rotating notices addNotice(cb.settings.spamMessage1); addNotice(cb.settings.spamMessage2); addNotice(cb.settings.spamMessage3); addNotice(cb.settings.spamMessage4); addNotice(cb.settings.spamMessage5); addNotice(cb.settings.spamMessage6); addNotice(cb.settings.spamMessage7); addNotice(cb.settings.spamMessage8); } function sendRotating() { // Send the next rotating notice if (noticeArray.length) { // Since we pushed, there should be no gaps, even if there were some // in the GUI. But check that it's valid, just in case. if (noticeArray[noticeNum]) { notifyThemePlain(noticeArray[noticeNum]); } noticeNum += 1; if (noticeNum >= noticeArray.length) { noticeNum = 0; } } } function parseWordlist() { if (!isBlank(cb.settings.customWordlist)) { customWordlistRegex = cb.settings.customWordlist.replace(/^(\s|,|\|)+|(\s|,|\|)+$/gm, ''); //trim leading/trailing spaces, commas, or pipes from string customWordlistRegex = customWordlistRegex.replace(/\s*(,|\|)\s*/gm, '|'); // replace commas or pipes surrounded by spaces with pipes customWordlistRegex = customWordlistRegex.replace(/[^\w|\s]/gm, ' '); // replace anything that's not a letter or a pipe with a space customWordlistRegex = customWordlistRegex.replace(/(\w)/gm, '$1+' ); //add a + between each letter customWordlistRegex = customWordlistRegex.replace(/\s+/gm, '\\s*' ); // replace spaces with \s* } } function doWordlist(msg) { var m = msg.trim().replace(/([^\w\s\u0027\u2019\[\]]|_)/ig, ' '); // Reusable RegEx //split demandverbs into sex demandverbs and "wanna" demand verbs? var demandverbs = '\\b(w+a+n|g+o+i*n|n+e+e+d|(c+a+n+|m+a+y+)\\s(i+|w+e+|[^\\s]*u+)|l+e+t*s*\\s*m+e+(\\s*(s+e+e+|c+))*|g+i+(m+|v+e+)\\s*m+e|p+l+a+y\\w*\\s*w|p+u+t|e+a+t|s+h+o+w|m+o+r+e|f+l+a+s+h|f+e+e+l|r+i+d+e|s+l+i+d|t+a+k+e+\so+u+t|o+p+e+n|c+l+o+s|c+u+m|s+h+a+k|d+o+g+(y|i)|s+p+(a|u)+n+k|s+q+u*e*z|p+o+u+n+d|s+h+o+v+e|s+m+a+c+k|f+i+n+g+e+r|b+l+o+w|(f|s)+u+c*k|f+c+k|l+i+c+k|k+i+s+s|m+a+s+t\\w*b+a+t|w+a+n+k|j+e+r+k|(j+|w+h*)a+c+k)\\w*\\b'; var girlyparts = '\\b(p+u+s|v+a+(g|j)|t+w+a+t|k+i+t+t|(c|s)+l+i+t|l+i+p|b+o+b|n+i+p|t+i+t|[^w\\s]*h+o+l+e|c+u+n+t|f+i+n+g+e+r|m+o+u+t+h|t+o+n+g+u|t+o*u+n+g|a+r+m+\\s*p+i+t)\\w*\\b' + '|'; girlyparts += '\\b(a+s+s|b+u+t+t|m+u+f+f|b+o+o+t+(y|i)|a+n+u+s|l+e+g+s*)\\b'; var guyparts = '\\b(d+i+c+k|b+o+n+e+r|c+o+c*(c|k)|p+e+n+i+s|m+e+a+t|bbc)\\w*\\b'; var toys = '\\b(d+i+l+d+o|t+o+y|b+u+t+t+\s*p+l+u+g|v+i+b|h*i*t+a+c+h+i)\\w*\\b' var naked = '\\b(n+a*k+e*d+|n+u+d+e+|b+a+r+e+)\\b'; var clothing = '(c+l+o+t+h|b+r+a+|(p+a+n+t+(i|y)*|s+(h|k)+i+r+t|d+r+e+s|s+t*o+(c+k|x)|s+h+o+e)\\w*\\b)'; var removeit = '(r+e+m+o+v+e+|t+a+k+e\\s*o+f+f+)'; var tmi_iam = '\\b(i+.{0,1}a*m+|i+|a+m+|i+s+|s+o+)\\b'; var tmi_adj = '\\b(h+a*r+d|w+e+t|h+o+r+n|t+h+i+c+k)\\w*\\b'; var tmi_intent = '\\b((l+o+v+e|l+u+v|g+o+i+n)\\w*\\s*(2+|t+o+)|l+e+(t|m)+\\s*m+e+|m+a+y+|c+a+n+)\\b' + '|'; tmi_intent += '\\b(g+o+t+|w+a+n|g+o+n|w+i+s+h)\\w*\\b'; var tmi_verb = '\\b(m+a+s+t\\w*b+a+t|w+a+n+k|j+e+r+k|(j+|w+h*)a+c+k|t+a+s+t|e+a+t|c+u+m|i+n+s+i+d+e|s+m+e+l+l|s+n+i+f+f|l+i+c+k|(f|s)+u+c*k|f+c+k)\\w*\\b'; var tmi_cum = '\\b(c+u+m|s+e+m+e+n|s+p+e+r+m|b+u+s+t.*n+u+t)\\w*\\b'; // Workaround (Block anything people try to space out to get around rules) var list_workaround = new RegExp('((^|\\s)[^\\s]\\s[^\\s]\\s[^\\s]($|\\s))', 'i'); // this matches 3 or more single spaced-out characters // No sexual words in a REALLY short message var list_directness = new RegExp('\\b(' + girlyparts + '|' + guyparts + '|' + demandverbs + '|' + naked + '|' + tmi_verb + '|' + tmi_cum + '|p+l+e*a*i*(s|z)+e*)\\b', 'i'); // Non-English characters var non_english = new RegExp('[^\\x00-\\xAE\\u2000-\\u206F]'); // BB var list_bb = new RegExp('\\b(b+(a|e)*b+(y|e)*)\\b', 'i'); // Rude var list_rude = new RegExp('\\b(h+o+e+s*)\\b|'+ '(c+u+n+t|s+l+u+t|s+k+a+n+k|w+h+o+r+e|b+i+t+c+h|n+i+g+g+e+r|t+r+a+n+n+(y|i))' , 'i'); // Sticky/Annoying var list_annoying = new RegExp('\\b([a-g|i-z]*(h+u+)*m+m+h*|u+f+)\\b', 'i'); // Spam var list_spam = new RegExp('(s+k+(y|i)*p+e|s+k+y*p|(f+r+e+e|unlimited).*t+o+k+e+n|t+o+k+e+n.*(f+r+e+e|generator)|erotimo|freecambook|webcam23|hotjenny|fucktubate|gaysexrooms|fastsexnow|alva lanus|Delorge942|Glasford597|sk .*y p e|\\[LEAK(ED)*\\]|SwipeGirls)', 'i'); // Demands var list_demands = new RegExp('\\b('+ 'p+\\s*m+|p+v+t|p+l+e*a*i*(s|z)+|a+n+a+l+|(m+a+s+t\\w*b|s+q\\w*r+t|f+i+s+t|q+u*e+a*f+)\\w*|' + '(' + demandverbs + '|p+l+e*a*i*(s|z)+e*)\\s*(i+t+|(t+h+|d+)a+t+|.*(y*o*u+r*|(f+o*r+|4+)*\\s*m+(y|e|i)+|' + girlyparts + '|' + guyparts + '|' + toys + ')|p+l+e*a*i*(s|z)+e*)|'+ '(' + girlyparts + '|' + guyparts + '|' + toys + '|' + naked + '|g+e+t+|m+(y|e|i)+|p+l+e*a*i*(s|z)+e*).*(' + demandverbs + '|' + naked + '|p+l+e*a*i*(s|z)+e*)' + ')\\b|' + '(' + removeit + '.*' + clothing + ')|(' + clothing + '.*' + removeit + ')|(t+a+k+e.*' + clothing + '.*o+f+f)|' + '(z+o+o+m|s+p+r+e+a+d|f+a+r+t|c+2+c|(w+a+t+c+h|l+o+o+k|o+p+e+n|v+i+e+w|c+l+i+c+k).*(c+a+m|p+r+o+f|r+o+o+m)\\w*)' , 'i'); // TMI var list_tmi = new RegExp('\\b('+ '\\d\\s*(i+n|c+m)\\w*|'+ '(' + demandverbs + ').*(' + tmi_cum +')|' + '(' + tmi_iam + ').*(' + tmi_adj +')|' + '(' + tmi_adj +').*f+o*r+\\s*y*o*u+r*|' + '(' + tmi_iam + '|' + tmi_intent + '|m+(y|e|i)+).*(' + tmi_verb + '|' + tmi_cum + '|' + guyparts +'|\\bs+i+s\\w*)' + ')\\b|' + '(s+t+r+o+k|t+h+r+o+b|c+i+r+c+u+m)' , 'i'); // Feet var list_feet = new RegExp('\\b(s+o+l+e+s*|t+o+e+s*)\\b|' + '(f+e+e+t|p+e+d+i+c+u|f+o+t+j+o+b)' , 'i'); // Creepy var list_creepy = new RegExp('(d+a+d|(s+t+e+p+)*d+a+u+g+h+t+e+r)' , 'i'); // Poo/Pee var list_poopee = new RegExp('\\b(p+o+o+p*\\w*|p+e+e+(i+n+g)*)\\b|' + '(t+u+r+d|e+n+e+m+a|d+e+f+e+c+a+t|(s+h+i+t|c+r+a+p|p+i+s+s+)\\w*\\s*(o|i)+n)' , 'i'); var reason = null; //convert to .match instead? can possibly use more regular-looking regex // .indexOf might be fastest switch(true) { case msg.length <= 1 || msg.length > 500 : reason = 'Length'; break; case m.search(list_workaround) != -1 : reason = 'Workaround'; break; case m.search(list_directness) != -1 && (msg.match(/\s+/gi)||[]).length < 3 : reason = 'Directness'; break; case m.search(non_english) != -1 : reason = 'Non-English'; break; case m.search(list_bb) != -1 : reason = 'BB'; break; case m.search(list_rude) != -1 : reason = 'Rudeness'; break; case m.search(list_annoying) != -1 : reason = 'Annoying'; break; case m.search(list_spam) != -1 : reason = 'Spam'; break; case m.search(list_demands) != -1 : reason = 'Demands'; break; case m.search(list_tmi) != -1 : reason = 'TMI'; break; case m.search(list_feet) != -1 : reason = 'Feet'; break; case m.search(list_creepy) != -1 : reason = 'Creepy'; break; case m.search(list_poopee) != -1 : reason = 'Poo/Pee'; break; } return reason; } function doCustomWordlist(m, u) { // Remove everything but alphanumeric characters to evaluate it var m = m.replace(/[^\w]|_/ig, ''); // Custom Wordlist var customwordlist = new RegExp('(' + customWordlistRegex + ')', 'i'); if ( m.search(customwordlist) != -1 || u.replace(/[^\w]|\d|_/ig, '').search(customwordlist) != -1 ) { return 'blocked'; } } function addWord(m) { cb.settings.customWordlist += ','+m; parseWordlist(); } function niceList(user,mod,ar) { if(user) { user = user.toLowerCase(); if(ar == 'a') { if(!cbjs.arrayContains(niceArray,user)) { niceArrayPopulate(user); notify('You have added ' + user + ' to the nice list.', mod); notify(mod + ' has added you to the nice list. You will be able to chat and use graphics regardless of the global room settings. Thank you for being nice!',user); } else { notifyError(user + ' is already on the nice list.', mod); } } else if(ar == 'r') { if(cbjs.arrayContains(niceArray,user)) { niceArrayDepopulate(user); notify('You have removed ' + user + ' from the nice list.', mod); notify(mod + ' has removed you from the nice list.', user); } else { notifyError(user + ' is not on the nice list.', mod); } } } else { notifyError('Uh oh. You didn\'t specify a user.\nType "/ubhelp\xa0nicelist" to see how to use the nice list.',mod); } } function greyList(user,mod,ar) { if(user) { user = user.toLowerCase(); if(ar == 'a') { if(!cbjs.arrayContains(greyArray,user)) { greyArrayPopulate(user); notify('You have added ' + user + ' to the grey list.', mod); } else { notifyError(user + ' is already on the grey list.', mod); } } else if(ar == 'r') { if(cbjs.arrayContains(greyArray,user)) { greyArrayDepopulate(user); notify('You have removed ' + user + ' from the grey list.', mod); } else { notifyError(user + ' is not on the grey list.', mod); } } } else { notifyError('Uh oh. You didn\'t specify a user.\nType "/ubhelp\xa0greylist" to see how to use the grey list.',mod); } } function vip (user, mod, ar) { if (ar == 'a') { if (user != null && (user != "" || user != " " || user != "\u00a0")) { if (user != cb.room_slug || !cbjs.arrayContains(modArray, user) || cbjs.arrayContains(eModArray, user)) { if (!cbjs.arrayContains(vipArray, user)) { vipArrayPopulate(user); notify('You have added ' + user + ' to the VIP list.', mod, purple); notify(mod + ' has added you to the VIP list. You will have free access to any future "CrazyTicket" show.', user, "#efe"); } else { notify(user + ' is already on the VIP list.', mod, "#fee"); } } else { notify("Room hosts, moderators, and emergency moderators don't need to be added to the VIP List.", mod, "#fee"); } } else { notify("You didn't specify who you want to add to the VIP list.\nType \"/ubhelp addvip\" to see how to use /addvip.\n" + "Additionally, check the viplist help section for more info.", mod, "#fee"); } } else if (ar == "r") { if (user != null && (user != "" || user != " " || user != "\u00a0")) { if (vipArray.length > 0) { if (user == "all") { notify("You have removed all users from the VIP list.", mod, purple); for (var i = 0; i < vipArray.length; i++) notify(mod + " has removed you from the VIP list.", vipArray[i], "#fee"); vipArray.length = 0; } else { if (cbjs.arrayContains(vipArray, user)) { cbjs.arrayRemove(vipArray, user); notify('You have removed ' + user + ' from the VIP list.', mod, purple); notify(mod + ' has removed you from the VIP list.', user, "#fee"); } else { notify(user + ' is not on the VIP list.', mod, "#fee"); } } } else { notify("The VIP list is currently empty.", mod, "#fee"); } } else { notify("You didn't specify who you want to remove from the VIP list.\nType \"/ubhelp removevip\" to see how to use /removevip.\n" + "Additionally, check the viplist help section for more info.", mod, "#fee"); } } } function kingSpamToggle(option, mod) { if(cb.settings.kingTipper != 'Yes') { notifyError('The room host has decided not to use the King Tipper feature',mod); } else if(option == 'on') { if(kingTipperSpam == 1) { notifyError('The King Tipper spam is already turned on.',mod); } else { kingTipperSpam = 1; kingSpam(); notify('You have turned on King Tipper spam.',mod); } } else if(option == 'off') { if(kingTipperSpam == 0) { notifyError('The King Tipper spam is already turned off.',mod); } else { kingTipperSpam = 0; notify('You have turned off the King Tipper spam.',mod); } } else if(option != null) { notifyError(option + ' is not a valid option for /kingspam.\nType "/ubhelp\xa0kingspam" to see how to use /kingspam.',mod); } else if(option == null) { notifyError('You did not enter a valid option for /kingspam.\nType "/ubhelp\xa0kingspam" to see how to use /kingspam.',mod); } } function notifierSpamToggle(option, mod) { if(option == 'on') { if(notifierSpamTGL == 1) { notifyError('The Notifier spam is already turned on.',mod); } else { notifierSpamTGL = 1; notify('You have turned on the Notifier spam.',mod); } } else if(option == 'off') { if(notifierSpamTGL == 0) { notifyError('The Notifier spam is already turned off.',mod); } else { notifierSpamTGL = 0; notify('You have turned off the Notifier spam.',mod); } } else if(option != null) { notifyError(option + ' is not a valid option for /notifierspam.\nType "/ubhelp\xa0notifierspam" to see how to use /notifierspam.',mod); } else if(option == null) { notifyError('You did not enter a valid option for /notifierspam.\nType "/ubhelp\xa0notifierspam" to see how to use /notifierspam.',mod); } } function leaderboardSpamToggle(option, mod) { if(option == 'on') { if(leaderboardSpam == 1) { notifyError('The Leaderboard spam is already turned on.',mod); } else { leaderboardSpam = 1; ldrSpam(); notify('You have turned on the Leaderboard spam.',mod); } } else if(option == 'off') { if(leaderboardSpam == 0) { notifyError('The Leaderboard spam is already turned off.',mod); } else { leaderboardSpam = 0; notify('You have turned off the Leaderboard spam.',mod); } } else if(option != null) { notifyError(option + ' is not a valid option for /leaderboardspam.\nType "/ubhelp\xa0leaderboardspam" to see how to use /leaderboardspam.',mod); } else if(option == null) { notifyError('You did not enter a valid option for /leaderboardspam.\nType "/ubhelp\xa0leaderboardspam" to see how to use /leaderboardspam.',mod); } } function isBlank(cbsetting) { var s; if(cbsetting) { s = cbsetting.trim(); } if(s == null || s == '' || s.substr(0,9) == '[Optional') { return true; } else { return false; } } function isValidColor(color) { var c = color; var cString = '0123456789abcdefABCDEF'; var valid = true; if (c.charAt(0) == '#') { c = c.substr(1); } if (c && c.length == 6) { for(var i = 0; i < 6; i++) { if(cString.indexOf(c.charAt(i)) == -1) { valid = false; } else { } } } else { valid = false; } if(valid) { return true; } else { notifyErrorBold('"' + color + '" is not a valid color option.', roomHost); notifyError( 'Use color-hex.com to find the code for the color you want.\n' + 'Reverting to default color.', roomHost); return false; } } function setColor() { var c = cb.settings.colorscheme; var t = cb.settings.darkcolor.trim(); var b = cb.settings.lightcolor.trim(); var textvalid = true; var bgvalid = true; if (c && c.substr(0,6) == 'Custom') { if(isBlank(b) && isBlank(t)) { notifyErrorBold('Whoops. You selected a custom color scheme but you didn\'t fill in the colors. Reverted to default color scheme.', roomHost); } else if (isBlank(t)) { notifyErrorBold('Whoops. You selected a custom color scheme but you didn\'t select a text color. Reverted to default color scheme.', roomHost); } else if (isBlank(b) && !isBlank(t)) { if (t && t.charAt(0) != '#') { t = '#' + t; } if (isValidColor(t)) { theme_dark = t; theme_light = white; } } else if (!isBlank(b) && !isBlank(t) ) { if (t && t.charAt(0) != '#') { t = '#' + t; } if (b && b.charAt(0) != '#') { b = '#' + b; } if (isValidColor(t) && isValidColor(b)) { theme_dark = t; theme_light = b; } } } else { if (!isBlank(t) || !isBlank(b)) { notifyErrorBold('You defined custom colors, but your color scheme is set to "' + c +'". In order to use your custom colors, please set your color scheme to "Custom"', roomHost); } if (c == 'Purple') { theme_dark = purple_dark; theme_light = purple_light; } else if (c == 'Pink') { theme_dark = pink_dark; theme_light = pink_light; } else if (c == 'Orange') { theme_dark = orange_dark; theme_light = orange_light; } else if (c == 'Red') { theme_dark = red_dark; theme_light = red_light; } else if (c == 'Green') { theme_dark = green_dark; theme_light = green_light; } else if (c == 'Teal') { theme_dark = teal_dark; theme_light = teal_light; } else if (c == 'Grey') { theme_dark = grey_dark; theme_light = grey_light; } } } function help(option,from) { var valid = 0; if(option == null){ option = ''; } switch(option) { case '': { valid = 1; notifyBold('UltraBot Ultra Help Menu',from); notify( 'Type "/ubhelp\xa0x", where x is one of the following choices, for more detailed information.' + '\nEx: /ubhelp\xa0commands' ,from); notifyPlain( 'commands\n' + 'nicelist\n' + 'greylist\n' + 'about' ,from); break; } case 'commands': { valid = 1; notifyBold('UltraBot Ultra Command List',from); notify( 'Type "/ubhelp\xa0x", where x is one of the following commands, for more detailed information.' + '\nEx: /ubhelp\xa0silencelevel' ,from); notifyPlain( '/silencelevel\n' + '/graphiclevel\n' + '/silence\n' + '/unsilence\n' + '/starttimer\n' + '/addtime\n' + '/timeleft\n' + '/starttimer1\n' + '/addtime1\n' + '/timeleft1\n' + '/starttimer2\n' + '/addtime2\n' + '/timeleft2\n' + '/starttimer3\n' + '/addtime3\n' + '/timeleft3\n' + '/note\n' + '/whisper\n' + '/reply\n' + '/ignore\n' + '/unignore\n' + '/ignorelevel\n' + '/emod\n' + '/addnice\n' + '/removenice\n' + '/addvip\n' + '/removevip\n' + '/addgrey\n' + '/removegrey\n' + '/leaderboard\n' + '/kingspam' // + '\n/notifierspam' ,from); break; } case 'nicelist': { notifyBold('The Nice List',from); notify('Sometimes, there are users whose comments are desirable, but they either do not have tokens or do not tip frequently. ' + 'When rooms get rowdy, hosts and mods are forced to do things like silence users without tokens or who have not tipped and those groups often includes the users whose comments hosts would like to see. ' + 'To fix this problem, hosts and mods can add users to the Nice List. ' + 'Users who are on the nice list can send messages regardless of the global silence setting.',from); valid = 1; break; } case 'greylist': { valid = 1; notifyBold('The "Grey" List',from); notify('Sometimes, there are users whose comments are annoying, in spite of the fact that they may have tokens or even tip. ' + 'It isn\'t always desireable to silence these people entirely, especially if they\'ve been tipping, but it can be useful to apply the same word list restrictions that apply to greys, so that the more annoying messages don\'t get through to the room. ' + 'To fix this problem, hosts and mods can add users to the "Grey" List. ' + 'Users who are on the grey list will have their messages subjected to the wordlists that apply to greys.',from); notify('',from); break; } case 'viplist': { valid = 1; notifyBold('The VIP List',from); notify('Sometimes, there\'re users who are trusted regulars, and then the room host decides to do a \"CrazyTicket\" show, ' + 'but these users don\'t have tokens to buy a ticket. ' + 'It isn\'t always desirable (and it may even seem unfair) to leave these users out of the show. ' + 'To fix this problem, hosts and mods can add these users to the VIP List. ' + 'Users who are on the VIP List will have free access to any future CrazyTicket show, provided the list is exported to the app via the \"/export\" command.\n' + 'To show the VIP list at any time, type +.', from); notify("",from); break; } // ADD EXPORT HERE case 'export': { valid = 1; if (isMod || isBc || (isDev && devMode == true)) { if (vipArray.length > 0) { msg.m = '/add ' + cbjs.arrayJoin(vipArray, ', '); } else{ notify("There's no one on the VIP list.", u, "#fee"); } } else { notify('Only moderators and broadcasters are able to use that command.\nType "/ubhelp commands" to see a full list of the available commands.', u, purple); } break; } case 'about': { valid = 1; notifyBold('About UltraBot Ultra',from); notify('UltraBot Ultra is a fork of Ultra Bot, with continuing development by CCXK.' + '\nUltra Bot was written by Justin of the Chaturbate couple britney_and_justin.' + '\nComments, suggestions, requests, and bug reports can be communicated by either tweeting @InnocentAbby_4u, ' + 'or by posting comments on UltraBot Ultra\'s page at chaturbate.com/bots.' + '\nThe purpose of UltraBot Ultra is to make the lives of hosts and mods as easy as possible. ' + 'It adds popular features such as King Tipper, Leaderboard, and Notifier, pre-silences abusive messages, ' + 'grants quite a bit of power to moderators, and allows private messages to be sent in the main chat window.',from); notify('',from); break; } case 'silencelevel': { valid = 1; notifyBold('/silencelevel Help',from); notify('/silencelevel is a command that is usable by moderators and room hosts.' + '\nThe syntax for using silencelevel is "/silencelevel\xa0x", where x is a number between 0 and 3.' + '\nSetting the Silence Level to 0 will grant voice privileges to all users, ' + 'setting it to 1 will revoke voice privileges from greys, ' + 'setting it to 2 will revoke voice privileges from greys and light blues, ' + 'setting it to 3 will revoke voice privileges from users who have not tipped,' + 'and setting it to 4 will revoke voice privileges from everyone other than mods and fans.' + '\nThe default setting for /silencelevel is 0.' + '\nRoom hosts, moderators, and fan club members are unaffected by the Silence Level.',from); notify('',from); break; } case 'graphiclevel': { valid = 1; notifyBold('/graphiclevel Help',from); notify('/graphiclevel is a command that is usable by moderators and room hosts.' + '\nThe syntax for using graphiclevel is "/graphiclevel\xa0x", where x is a number between 0 and 3.' + '\nSetting the Graphic Level to 0 will grant graphic privileges to all users, ' + 'setting it to 1 will revoke graphic privileges from greys, ' + 'setting it to 2 will revoke graphic privileges from greys and light blues, ' + 'setting it to 3 will revoke graphic privileges from users who have not tipped,' + 'and setting it to 4 will revoke graphic privileges from everyone other than mods and fans.' + '\nThe default setting for /graphiclevel is 1.' + '\nRoom hosts, moderators, and fan club members are unaffected by the Graphic Level.',from); notify('',from); break; } case 'silence': { valid = 1; notifyBold('/silence Help',from); notify('/silence is a command that is usable by moderators and room hosts.' + '\nThe syntax for using silence is "/silence x", where x is the username of the user you want to silence.' + '\nThe effect of /silence is the same as Chaturbate\'s silence feature, ' + 'except that it lasts for the duration of the current session instead of for six hours.' + '\nThe effect of /silence can be reversed by using the command /unsilence.',from); notify('',from); break; } case 'unsilence': { valid = 1; notifyBold('/unsilence Help',from); notify('/unsilence is a command that is usable by moderators and room hosts.' + '\nThe syntax for using unsilence is "/unsilence x", where x is the username of the user you want to unsilence.' + '\nunsilence simply grants voice privileges back to a user who was previously silenced.' + '\nNOTE: /unsilence WILL NOT undo the effect of Chaturbate\'s silence feature!' + '\n/unsilence WILL ONLY reverse the effect of /silence!',from); notify('',from); break; } case 'starttimer': { valid = 1; notifyBold('/starttimer Help',from); notify('/starttimer is a command that is usable by moderators and room hosts.' + '\nThe syntax for using starttimer is "/starttimer x", where x is the desired duration of the timer in minutes.' + '\n/starttimer will accept whole numbers only.' + '\nThe timer will make announcements at five minutes remaining and at one minute remaining.' + '\n/addtime can be used to add time to a currently running timer.' + '\n/timeleft can be used to display the amount of time remaining on the timer.',from); notify('',from); break; } case 'addtime': { valid = 1; notifyBold('/addtime Help',from); notify('/addtime is a command that is usable by moderators and room hosts.' + '\nThe syntax for using addtime is "/addtime\xa0x", where x is the amount of time you want to add in minutes.' + '\n/addtime will accept whole numbers only.' + '\nSee the help section for starttimer for more information on timers.',from); notify('',from); break; } case 'timeleft': { valid = 1; notifyBold('/timeleft Help',from); notify('/timeleft is a command that is usable by everyone.' + '\nThe syntax for using timeleft is /timeleft' + '\n/timeleft will display the amount of time left on the timer in the format 00:00:00' + '\nSee the help section for starttimer for more information on timers.',from); notify('',from); break; } case 'starttimer1': { valid = 1; notifyBold('/starttimer1 Help',from); notify('/starttimer1 is a command that is usable by moderators and room hosts.' + '\nThe syntax for using starttimer1 is "/starttimer1 x", where x is the desired duration of Timer1 in minutes.' + '\n/starttimer1 will accept whole numbers only.' + '\nTimer1 will make announcements at five minutes remaining and at one minute remaining.' + '\n/addtime1 can be used to add time to Timer1 currently running timer.' + '\n/timeleft1 can be used to display the amount of time remaining on Timer1.',from); notify('',from); break; } case 'addtime1': { valid = 1; notifyBold('/addtime1 Help',from); notify('/addtime1 is a command that is usable by moderators and room hosts.' + '\nThe syntax for using addtime1 is "/addtime1\xa0x", where x is the amount of time you want to add to Timer1 in minutes.' + '\n/addtime1 will accept whole numbers only.' + '\nSee the help section for starttimer1 for more information on Timer1.',from); notify('',from); break; } case 'timeleft1': { valid = 1; notifyBold('/timeleft1 Help',from); notify('/timeleft1 is a command that is usable by everyone.' + '\nThe syntax for using timeleft1 is /timeleft1' + '\n/timeleft1 will display the amount of time left on Timer1 in the format 00:00:00' + '\nSee the help section for starttimer1 for more information on Timer1.',from); notify('',from); break; } case 'starttimer2': { valid = 1; notifyBold('/starttimer2 Help',from); notify('/starttimer2 is a command that is usable by moderators and room hosts.' + '\nThe syntax for using starttimer2 is "/starttimer2 x", where x is the desired duration of Timer2 in minutes.' + '\n/starttimer2 will accept whole numbers only.' + '\nTimer2 will make announcements at five minutes remaining and at one minute remaining.' + '\n/addtime2 can be used to add time to Timer2 currently running timer.' + '\n/timeleft2 can be used to display the amount of time remaining on Timer2.',from); notify('',from); break; } case 'addtime2': { valid = 1; notifyBold('/addtime2 Help',from); notify('/addtime2 is a command that is usable by moderators and room hosts.' + '\nThe syntax for using addtime2 is "/addtime2\xa0x", where x is the amount of time you want to add to Timer2 in minutes.' + '\n/addtime2 will accept whole numbers only.' + '\nSee the help section for starttimer2 for more information on Timer2.',from); notify('',from); break; } case 'timeleft2': { valid = 1; notifyBold('/timeleft2 Help',from); notify('/timeleft2 is a command that is usable by everyone.' + '\nThe syntax for using timeleft2 is /timeleft2' + '\n/timeleft2 will display the amount of time left on Timer2 in the format 00:00:00' + '\nSee the help section for starttimer2 for more information on Timer2.',from); notify('',from); break; } case 'starttimer3': { valid = 1; notifyBold('/starttimer3 Help',from); notify('/starttimer3 is a command that is usable by moderators and room hosts.' + '\nThe syntax for using starttimer3 is "/starttimer3 x", where x is the desired duration of Timer3 in minutes.' + '\n/starttimer3 will accept whole numbers only.' + '\nTimer3 will make announcements at five minutes remaining and at one minute remaining.' + '\n/addtime3 can be used to add time to Timer3 currently running timer.' + '\n/timeleft3 can be used to display the amount of time remaining on Timer3.',from); notify('',from); break; } case 'addtime3': { valid = 1; notifyBold('/addtime3 Help',from); notify('/addtime3 is a command that is usable by moderators and room hosts.' + '\nThe syntax for using addtime3 is "/addtime3\xa0x", where x is the amount of time you want to add to Timer3 in minutes.' + '\n/addtime3 will accept whole numbers only.' + '\nSee the help section for starttimer3 for more information on Timer3.',from); notify('',from); break; } case 'timeleft3': { valid = 1; notifyBold('/timeleft3 Help',from); notify('/timeleft3 is a command that is usable by everyone.' + '\nThe syntax for using timeleft3 is /timeleft3' + '\n/timeleft3 will display the amount of time left on Timer3 in the format 00:00:00' + '\nSee the help section for starttimer3 for more information on Timer3.',from); notify('',from); break; } case 'note': { valid = 1; notifyBold('/note Help',from); notify('/note is a command that is usable by moderators and room hosts.' + '\nThe syntax for using note is "/note\xa0x", where x is the message you want to send.' + '\n/note, /notice, and /n are all available commands that will send a notice.' + '\nA note is a public notification that will be sent to everyone in the main chat window.',from); notify('',from); break; } case 'whisper': { valid = 1; notifyBold('/whisper Help',from); notify('/whisper is a command that is usable by everyone.' + '\nThe syntax for using whisper is "/whisper\xa0x\xa0y", where x is the username of the user you want to send a whisper and y is the message you want to send.' + '\n/whisper, /w, /tell, /t, and /pm are all available commands that will send a whisper.' + '\nA whisper is a private message that will be sent in the main chat window.' + '\nOther related commands are /reply, /ignore, /unignore, and /ignorelevel.',from); notify('',from); break; } case 'reply': { valid = 1; notifyBold('/reply Help',from); notify('/reply is a command that is usable by everyone.' + '\nThe syntax for using whisper is "/reply\xa0x", where x is message that you want to whisper to the user who most recently sent a whisper to you.' + '\n/reply and /r are available commands that will send a whisper in reply.' + '\nSee the help section for whisper for more information on whispers.' + '\nOther related commands are /whisper, /ignore, /unignore, and /ignorelevel.',from); notify('',from); break; } case 'ignore': { valid = 1; notifyBold('/ignore Help',from); notify('/ignore is a command that is usable by everyone.' + '\nThe syntax for using ignore is "/ignore\xa0x", where x is the user from whom you wish to ignore whispers.' + '\nIgnoring a user will prevent him from sending you whispers, but it will not prevent him from talking normally in chat.' + '\n/unignore will reverse the effect of /ignore.' + '\nSee the help section for whisper for more information on whispers.' + '\nOther related commands are /whisper, /reply, /unignore, and /ignorelevel.',from); notify('',from); break; } case 'unignore': { valid = 1; notifyBold('/unignore Help',from); notify('/unignore is a command that is usable by everyone.' + '\nThe syntax for using unignore is "/unignore\xa0x", where x is the user you wish to remove from your ignore list.' + '\nSee the help section for ignore for more information on ignoring users.' + '\nSee the help section for whisper for more information on whispers.' + '\nOther related commands are /whisper, /reply, /ignore, and /ignorelevel.',from); notify('',from); break; } case 'ignorelevel': { valid = 1; notifyBold('/ignorelevel Help',from); notify('/ignorelevel is a command that determines which users you accept whispers from. It is usable by everyone.' + '\nThe syntax for using ignorelevel is "/ignorelevel\xa0x", where x is a number between 0 and 4.' + '\nSetting it to 0 will allow all users to send you whispers.' + '\nSetting it to 1 will prevent greys from sending you whispers.' + '\nSetting it to 2 will prevent greys and light blues from sending you whispers.' + '\nSetting it to 3 will prevent users who have not tipped in the room from sending you whispers.' + '\nSetting it to 4 will prevent all users from sending you whispers.' + '\nModerators and fan club members can send whispers regardless of whisper level.' + '\nThe default setting for /ignorelevel is 4 for the broadcaster, and 0 for everyone else. (This broadcaster\'s level is set higher by default to prevent abuse of this feature.)' + '\nSee the help section for whisper for more information on whispers' + '\nOther related commands are /whisper, /reply, /ignore, and /unignore.',from); notify('',from); break; } case 'emod': { valid = 1; notifyBold('/emod Help',from); notify('/emod is a command that is usable by moderators and room hosts.' + '\nThe syntax for using emod is "/emod\xa0x\xa0y", where x is either "add" or "remove" and y is the username of the user you want to either grant or revoke emergency moderator powers.' + '\n/emod allows moderators to quickly grant other users access to moderator-only commands in the event that he is having difficulty controlling the room by himself.' + '\nEmergency moderators have access to all moderator-only commands with the exceptions of /emod, /addnice, and /removenice.',from); notify('',from); break; } case 'blocknotice': { valid = 1; notifyBold('/blocknotice Help',from); notify('/blocknotice is a command that is usable by moderators and room hosts.' + '\nThe syntax for using blocknotice is "/blocknotice\xa0x", where x is either "on" or "off".' + '\n/blocknotice toggles the blocked message notices that appear by default for moderators when the wordlist is being used' + '\nThe blocked message notifications are toggled on a per-user basis. (Toggling it for yourself does not toggle it for everyone.)',from); notify('',from); break; } case 'addnice': { valid = 1; notifyBold('/addnice Help',from); notify('/addnice is a command that is usable by moderators and room hosts.' + '\nThe syntax for using addnice is "/addnice x", where x is the username of the user you want to add to the nice list.' + '\nAdding a user to the nice list guarantees that user voice and graphic usage privileges regardless of the silence, graphic, and ignore level settings. ' + 'Using /silence or /ignore will still silence or ignore a user on the nice list.' + '\nUsers can be removed from the nice list by using the command /removenice.' + '\nSee the help sections for silencelevel, graphiclevel, and ignorelevel for more information on the global settings or the help section for nicelist for more information on the nice list.',from); notify('',from); break; } case 'removenice': { valid = 1; notifyBold('/removenice Help',from); notify('/removenice is a command that is usable by moderators and room hosts.' + '\nThe syntax for using removenice is "/removenice x", where x is the username of the user you want to remove from the nice list.' + '\nSee the help section for nicelist for more information on the nice list.',from); notify('',from); break; } case 'addgrey': case 'addgray': { valid = 1; notifyBold('/addgrey Help',from); notify('/addgrey is a command that is usable by moderators and room hosts.' + '\nThe syntax for using addgrey is "/addgrey x", where x is the username of the user you want to add to the grey list.' + '\nAdding a user to the grey list subjects them to the same wordlists that apply to greys. ' + '\nUsers can be removed from the grey list by using the command /removegrey.' + '\nSee the help section for greylist for more information on the grey list.',from); notify('',from); break; } case 'removegrey': case 'removegray': { valid = 1; notifyBold('/removegrey Help',from); notify('/removegrey is a command that is usable by moderators and room hosts.' + '\nThe syntax for using removegrey is "/removegrey x", where x is the username of the user you want to remove from the grey list.' + '\nSee the help section for greylist for more information on the grey list.',from); notify('',from); break; } case 'addvip': { valid = 1; notifyBold('/addvip Help',from); notify('/addvip is a command that is usable by moderators and room hosts.' + '\nThe syntax for using addvip is "/addvip x", where x is the username of the user you want to add to the VIP list.' + '\nAdding a user to the VIP list grants them free access to a future "CrazyTicket" show. ' + '\nUsers can be removed from the VIP list by using the command /removevip.' + '\nSee the help section for viplist for more information on the VIP list.',from); notify('',from); break; } case 'removevip': { valid = 1; notifyBold('/removevip Help',from); notify('/removevip is a command that is usable by moderators and room hosts.' + '\nThe syntax for using removevip is "/removevip x", where x is the username of the user you want to remove from the VIP list.' + '\nSee the help section for viplist for more information on the VIP list.',from); notify('',from); break; } case 'ubhelp': case 'ubhelp': { valid = 1; notifyBold('/ubhelp\xa0Help',from); notify('/ubhelp\xa0is a command that is usable by everyone.' + '\nThe syntax for using ubhelp is "/ubhelp\xa0x", where x is the subsection of the help menu that you want to access.',from); notify('',from); break; } case 'leaderboard': { valid = 1; notifyBold('/leaderboard Help',from); notify('/leaderboard is a command that is usable by everyone.' + '\nThe syntax for using leaderboard is "/leaderboard".' + '\n/leaderboard shows the top 3 tippers of the current session.',from); notify('',from); break; } case 'kingspam': { valid = 1; notifyBold('/kingspam Help',from); notify('/kingspam is a command that is usable by moderators and room hosts.' + '\nThe syntax for using kingspam is /kingspam x, where x is either on or off. ' + 'Using this command toggles the spamming of the message "Tip x to become the new King!"',from); notify('',from); break; } // case 'notifierspam': { // valid = 1; // notifyBold('/notifierspam Help',from); // notify('/notifierspam is a command that is usable by moderators and room hosts.' + // '\nThe syntax for using notifierspam is /notifierspam x, where x is either on or off. ' + // 'Using this command toggles the spamming of the periodic message defined by the host.',from); // notify('',from); // break; // } case 'leaderboardspam': { valid = 1; notifyBold('/leaderboardspam Help',from); notify('/leaderboardspam is a command that is usable by moderators and room hosts.' + '\nThe syntax for using leaderboardspam is /leaderboardspam x, where x is either on or off. ' + 'Using this command toggles the spamming of the top three tippers.',from); notify('',from); break; } } if(valid == 0) { notifyError(option + ' is not a valid subsection of the help menu. Type "/ubhelp" to access the main help menu.',from); } } /************************************************************************************************************************************ ***** onMessage ********************************************************************************************************************* ************************************************************************************************************************************/ cb.onMessage(function (msg) { var silenced = 0; //1 = user is already silenced var messageBlocked = 0; // used to determine whether a message gets blocked based on wordlist var graphicsBlocked = 0; // used to determine whether a user can use graphics var imageReplaced = 0; var symbolString = '~`!@#$%^&*()_-+={[}]|\\:;"\'<,>.?/'; // Message vars var msgString = msg['m'].trim(); var isCommand = (msgString.charAt(0) == '/'); var isGender = (msgString.charAt(0) == '/'); var isKenoCmd = (msgString.charAt(0) == '!'); var message = msgString.split(/\s+/g); //turn the message into an array // User vars var u = msg.user; var hasTipped = findTipper(u) > -1 && Number.parseInt(tipArray[findTipper(u)].nTotal) > 0; var isHost = (u == cb.room_slug); var isDev = (u == dev); var isMod = msg.is_mod; var isFan = msg.in_fanclub; var isEmod = cbjs.arrayContains(emodArray, u); var isNice = cbjs.arrayContains(niceArray, u); var isGreyish = cbjs.arrayContains(greyArray, u); var isOnVipList = cbjs.arrayContains(vipArray, u); var isSilenced = cbjs.arrayContains(silenceArray, u); var isGrey = (!msg.has_tokens && !hasTipped && !msg.tipped_recently); // technically MAY include some light blues who have tipped down to zero, but i don't think so var isBlueUp = (msg.tipped_recently || hasTipped); // Add mod to modArray if(isMod) { if (!cbjs.arrayContains(modArray,u)) { modArrayPopulate(u); modAndEmodArrayPopulate(u); if(cb.settings.wordlistShowModerators == 'Yes') { modBlockMsgArrayPopulate(u); } } } // Silencing if(isSilenced && !(isHost || isMod || isEmod || isNice || isDev) && silenced == 0) { msg['X-Spam'] = true; silenced = 1; // notifyError('Your message was not sent because you have been silenced. Be nice and don\'t make demands.',u); } // Silence Levels function doSilenceLevel(level) { var silenceNotice = 'I\'m sorry, but the silence level has been set to ' + level + '. Your message was not sent.\n'; silenceNotice += 'For more information about silence levels, type "/ubhelp silencelevel"\n'; silenceNotice += 'Please enjoy the show :smile'; msg['X-Spam'] = true; silenced = 1; notifyError(silenceNotice,u); } if(silenceLevel > 0 && !(isHost || isMod || isEmod || isFan || isNice || isDev) && silenced == 0) { switch(silenceLevel) { case 1: if(isGrey) { doSilenceLevel(silenceLevel); } break; case 2: if(!isBlueUp) { doSilenceLevel(silenceLevel); } break; case 3: if(!hasTipped) { doSilenceLevel(silenceLevel); } break; case 4: doSilenceLevel(silenceLevel); break; } } function replaceImage() { for(var i = 0; i < message.length; i++) { if(message[i].charAt(0) == ':') { if(!message[i].match(/^(:(-?|o?)(\)|\(|}|{|P|D|3|b|O|0|S|X|\$|\/|\\|\||\*))$/ig)) { // common emoticons that begin with a ":" character //replace images msg['m'] = msg['m'].replace(/:[^\s]+/g, function (match) { return '[IMG: ' + match.slice(1) + ']'; }); msg['X-Spam'] = true; return true; imageReplaced = 1; } else { return false; } } } } // Graphic Levels function doGraphicLevel(level) { var graphicNotice = 'I\'m sorry, but the graphic level has been set to ' + level + '. Your message was not sent.\n'; graphicNotice += 'For more information about graphic levels, type "/ubhelp graphiclevel"\n'; graphicNotice += 'Please enjoy the show :smile'; if (replaceImage()) { notifyError(graphicNotice,u); graphicsBlocked = 1; } } if(graphicLevel > 0 && !(isHost || isMod || isEmod || isFan || isNice || isDev) && silenced == 0) { switch(graphicLevel) { case 1: if(isGrey || isGreyish) { doGraphicLevel(graphicLevel); } break; case 2: if(!isBlueUp || isGreyish) { doGraphicLevel(graphicLevel); } break; case 3: if(!hasTipped || isGreyish) { doGraphicLevel(graphicLevel); } break; case 4: doGraphicLevel(graphicLevel); break; } } // Blocked Wordlists function blockMessage(reason) { msg['X-Spam'] = true; messageBlocked = 1; if(!isCommand && !isSilenced && silenced == 0) { silenced = 1; // //replace images -- we may not want to see the images they unsuccessfully try to use if (imageReplaced == 0) { replaceImage(); } var blockedmsg = msg['m']; for (mod = 0; mod < modAndEmodArray.length; mod++) { thisMod = modAndEmodArray[mod]; if(cbjs.arrayContains(modBlockMsgArray,thisMod)) { notifyErrorBold(bullets + 'MESSAGE BLOCKED: ' + reason + bullets, thisMod); notifyError(msg['user']+': '+blockedmsg.substring(0, 500), thisMod); } } if(cb.settings.wordlistNotice == 'Yes') { notifyError('Your message was not sent because it was flagged by the wordlist. Be nice and don\'t make demands.',u); } lastBlocked.push(msg['user']); if (lastBlocked.length == 10) { lastBlocked.shift(); } } } if(!(isHost || isMod || isEmod || isFan || isNice)) { // Custom wordlist stuff if (cb.settings.customWordlistToggle == 'Yes' && customWordlistRegex != '') { if (isGrey || isGreyish || cb.settings.customWordlistLevel == 'Everyone') { if (doCustomWordlist(msgString, u) == 'blocked') { blockMessage('Wordlist'); } } } // Regular wordlist stuff if(cb.settings.wordlistToggle == 'Yes') { if (isGrey || isGreyish || cb.settings.wordlistLevel == 'Everyone') { var blocked = doWordlist(msgString); if (blocked) { blockMessage(blocked); } } } } // Commands if(isCommand) { msg['X-Spam'] = true; //Don't send message to chat msg['background'] = bb_lt_light; msg['c'] = bb_lt_dark; var validCmd = 0; var command; // Slash + first word is the command var param; // Anything after the first word is the parameter var split_index; // Postion of the first space character // Split split_index = msgString.indexOf(' '); // Find first space character if (split_index > -1) { // Message might have a parameter (could just be padding) command = msgString.substr(0, split_index).toLowerCase(); // substr (start index, length) param = msgString.substring(split_index + 1).trim(); // Could be empty } else { // Message is a command only command = msgString.toLowerCase(); param = null; } // Host and Mod commands if(validCmd == 0 && (isHost || isMod || isDev)) { validCmd = 1; switch(command) { case '/note': case '/notice': case '/n': { if (param) { sendNote(param, u); msg['m'] = bullets + 'NOTICE SENT' + bullets; msg['c'] = theme_dark; } else { notifyError('Uh oh! You didn\'t write a note',u); } break; } case '/emod': { emod(message[1],message[2],u); break; } case '/tiptotal': { notify('Total tips: ' + tipTotal + ' tokens',u) break; } default: { validCmd = 0; break; } } } // Host, Mod, and Emod commands if(validCmd == 0 && (isHost || isMod || isEmod || isDev)) { validCmd = 1; switch(command) { case '/blocknotice': { blockNotice(param,u); break; } case '/silencelevel': { setSilenceLevel(param,u); break; } case '/greysoff': case '/greyoff': case '/graysoff': case '/grayoff': case '/silencegreys': case '/silencegrays': { setSilenceLevel(1,u); break; } case '/greyson': case '/greyon': case '/grayson': case '/grayon': case '/unsilencegreys': case '/unsilencegrays': { setSilenceLevel(0,u); break; } case '/graphiclevel': { setGraphicLevel(param,u); break; } case '/silence': { silence(param,u); break; } case '/unsilence': { unsilence(param,u); break; } case '/silencelast': case '/sl': { silenceLast(u); break; } case '/addnice': { niceList(param,u,'a'); break; } case '/removenice': { niceList(param,u,'r'); break; } case '/addvip': { niceList(param,u,'a'); break; } case '/removevip': { niceList(param,u,'r'); break; } case '/addgrey': case '/addgray': { greyList(param,u,'a'); break; } case '/removegrey': case '/removegray': { greyList(param,u,'r'); break; } case '/starttimer': { startTimer(param,u); break; } case '/addtime': case '/addtimer': { addTime(param,u); break; } case '/stoptimer': case '/endtimer': { stopTimer(u); break; } case '/starttimer1': case '/startimer1': { startTimer1(param,u); break; } case '/addtime1': case '/addtimer1': { addTime1(param,u); break; } case '/stoptimer1': case '/endtimer1': { stopTimer1(u); break; } case '/starttimer2': case '/startimer2': { startTimer2(param,u); break; } case '/addtime2': case '/addtimer2': { addTime2(param,u); break; } case '/stoptimer2': case '/endtimer2': { stopTimer2(u); break; } case '/starttimer3': case '/startimer3': { startTimer3(param,u); break; } case '/addtime3': case '/addtimer3': { addTime3(param,u); break; } case '/stoptimer3': case '/endtimer3': { stopTimer3(u); break; } case '/kingspam': { kingSpamToggle(param,u) break; } case '/notifierspam': { notifierSpamToggle(param,u) break; } case '/leaderboardspam': { leaderboardSpamToggle(param,u) break; } // case '/notifiermessage': { // if(message[1] == '' || message[1] == null) { // notifyError('You must enter a new message for the notifier feature. If you want to disable the notifications, enter /notifierspam off.',u); // } // else { // notifierMessage = msg['m'].substring(16).trim(); // notify('You have set the notifier spam message to: ' + notifierMessage,u); // } // break; // } case '/shownotices': { var noticeString = ''; if (noticeArray.length) { for (var i = 0; i < noticeArray.length; i++) { if (i > 0) { noticeString += '\n-------------------------\n'; } noticeString += '\u2022 Rotating Notice #' + (i + 1) + ': \n'; noticeString += noticeArray[i]; } notifyPlain(noticeString,u); } else { notifyPlain('There are no rotating notices set.',u); } break; } case '/removenotice': case '/removenote': { var n = parseInt(param); if (n > 0 && n <= (noticeArray.length)) { noticeArray.splice((n-1), 1); notify('You have removed notice #' + n,u); } else if(param) { notifyError('\'' + param + '\' is not a valid notice.',u); } else { notifyError('You did not enter a valid notice.',u); } break; } case '/addnotice': case '/addnote': { var noticeArrayLength = noticeArray.length; if(param) { addNotice(param); if (!noticeArrayLength) { sendRotating(); notifierSpam(); } notify('You have successfully added a new notice!',u); } else { notifyError('You did not enter a valid notice.',u); } break; } case '/addword': { if(param) { addWord(param); notify('You have successfully added \'' + param + '\' to the custom wordlist!',u); } else { notifyError('You did not enter a valid word.',u); } break; } case '/noticetimer': { var n = parseInt(param); if (n > 0) { notifierTimer = n; // clearTimeout(notifierTimeout); // notifierSpam(); notify('Rotating notices will now display every ' + n + ' minutes.',u); } else if (param) { notifyError('\'' + param + '\' is not a valid value for /noticetimer.',u); } else { notifyError('You did not enter a valid value for /noticetimer.',u); } break; } default: { validCmd = 0; break; } } } // Everybody else commands if (validCmd == 0) { validCmd = 1; switch(command) { case '/uubhelp': case '/uuhelp': case '/ubhelp': { help(param,u); break; } case '/leaderboard': { showLeaderBoard(u); break; } case '/timeleft': { timeLeft(msg['user']); break; } case '/timeleft1': { timeLeft1(msg['user']); break; } case '/timeleft2': { timeLeft2(msg['user']); break; } case '/timeleft3': { timeLeft3(msg['user']); break; } case '/whisper': case '/w': case '/tell': case '/t': case '/pm': case '/reply': case '/r': case '/ignorelevel': case '/ignore': case '/unignore': { if(cb.settings.whisperToggle.substr(0,2) == 'No') { notifyError('The broadcaster has disabled the "whisper" feature',u); } else if (command.match(/\b(whisper|w|tell|t|pm)\b/ig)) { var whisperLevel; if(isGrey && silenced == 0) { whisperLevel = 1; } else if(!isBlueUp && silenced == 0) { whisperLevel = 2; } else if(!hasTipped && silenced == 0) { whisperLevel = 3; } else { whisperLevel = 4; } if(isHost || isMod || isEmod || isFan || isNice || isDev) { sendWhisper(message,u,true,whisperLevel); msg['m'] = textReplaceWhisper(message,u); msg['background'] = bb_light; msg['c'] = bb_dark; } else if (messageBlocked == 0 && graphicsBlocked == 0) { sendWhisper(message,u,false,whisperLevel); msg['m'] = textReplaceWhisper(message,u); msg['background'] = bb_light; msg['c'] = bb_dark; } else { msg['m'] = 'Whisper not sent.'; msg['background'] = '#EEE'; msg['c'] = '#AAA'; } } else if (command.match(/\b(reply|r)\b/ig)) { if (messageBlocked == 0 && graphicsBlocked == 0) { sendReply(message,u); msg['m'] = textReplaceWhisper(message,u,true); msg['background'] = bb_light; msg['c'] = bb_dark; } else { msg['m'] = 'Reply not sent.'; msg['background'] = '#EEE'; msg['c'] = '#AAA'; } } else if (command == ('!ignorelevel')) { setIgnoreLevel(param,u); } else if (command == ('!ignore')) { ignoreUser(param,u); } else if (command == ('!unignore')) { unignoreUser(param,u); } break; } //debugging command to show variables case '!showvar': { if(isDev) { var v = param; function showVar(){ this.debug = function(sVar){ try { notifyPlain(eval(sVar), dev); } catch (e) { notifyPlain('no such variable', dev); } } } var displayVar = new showVar(); displayVar.debug(v); } else { validCmd = 0; } break; } default: { validCmd = 0; break; } } } if (validCmd == 0) { msg['background'] = '#EEE'; msg['c'] = '#AAA'; //Give Permission notice if (command.match(/\b(note|notice|n|emod|addnice|removenice|addvip|removevip|addgrey|addgray|removegrey|removegray|tiptotal|blocknotice|silencelevel|greysoff|greyoff|greyson|greyon|graphiclevel|silence|unsilence|starttimer|addtime|stoptimer|endtimer|starttimer1|addtime1|stoptimer1|endtimer1|starttimer2|addtime2|stoptimer2|endtimer2|starttimer3|addtime3|stoptimer3|endtimer3|kingspam|notifierspam|leaderboardspam|shownotices|removenotice|removenote|addnotice|addnote|noticetimer)\b/ig)) { notifyError('Only moderators and broadcasters are able to use the "' + command + '" command.\nType "/ubhelp\xa0commands" to see a full list of the available commands.',u); } //Make sure it doesn't call errors for common commands used by other apps/bots else if (command.match(/\b(b|p|lb|rewards|add|au|del|du|hilite|hl|check|plist|plistw|email|ctn|ctb|ctm|spass|tipsoff|schat|prizes|winners|startshow|showtimeleft|stopshow|showover|showend|lock|changepw|ctprice|ctreset|timeleft|showtime|sendpw|newshow|subject|printtime|addshowtime|adduser|changegoal|hide|unhide|selltickets|uacommands|cmds|cmd|luhelp|levels)\b/ig)) { // do nothinga } //Otherwise, it means the user entered an invalid command else if(cb.settings.invalidToggle == 'Yes') { notifyError('"' + command + '" is not a valid command.\nType "/ubhelp\xa0commands" to see a full list of the available commands.',u); } } } if(!(isHost || isMod || isEmod || isFan || isNice || isDev)) { //stop people from sending messages in all caps if (cb.settings.capsToggle == 'Yes' || (cb.settings.capsToggle == 'Only for greys' && (isGrey || isGreyish))) { if(msg['m'] == msg['m'].toUpperCase() && msg['m'].toUpperCase() != msg['m'].toLowerCase()) { for(var i = 0; i < msg['m'].length; i++) { if(symbolString.indexOf(msg['m'].charAt(i)) == -1) { msg['m'] = msg['m'].replace(/[^\s]+/g, function (match) { return match.indexOf(':') === 0 ? match : match.toLowerCase(); }); } } } } //convert sticky keys to max of 4 letters if (cb.settings.stickyToggle == 'Yes' || (cb.settings.stickyToggle == 'Only for greys' && (isGrey || isGreyish))) { if(msg['m'].match(/(.)\1{3,}/ig)) { message = msg['m'].trim().split(/\s+/g); // make sure we're working with the current version of our message var m = ''; for(var i = 0; i < message.length; i++) { if(i >= 0) { m += ' '; } if ((message[i].charAt(0) == ':')) { m += message[i]; } else { m += message[i].replace(/(.)\1{3,}/ig, '$1$1$1'); } } msg['m'] = m; } } } //tip titles, if turned on, as well as king's crown if(cb.settings.tipTitles == 'Yes' && hasTipped && !isCommand && !isKenoCmd) { msg['m'] = setTipTitles(msg['user'],msg['m']); } // User Gender if (cb.settings.gender_allowed == 'Yes' && !isCommand && !isKenoCmd) { var gender = msg['gender']; var genderStr = ''; switch (gender) { case 'm': genderStr = ':avatar_gen_male'; break; case 'f': genderStr = ':avatar_gen_female'; break; case 's': genderStr = ':avatar_gen_trans'; break; case 'c': genderStr = ':avatar_gen_couple'; break; default: genderStr = ':avatar_gen_unknown'; break; } msg['m'] = genderStr + ' ' + msg['m']; } return msg; }); /************************************************************************************************************************************ ***** onTip ************************************************************************************************************************* ************************************************************************************************************************************/ cb.onTip(function (tip) { var thisTip = parseInt(tip['amount']); var thisTipper = tip['from_user']; var userTotal = addTip(thisTipper, thisTip); tipNote = tip['message']; tipTotal += thisTip; if(cb.settings.notifierTip.substr(0,2) != 'No' && thisTip >= cb.settings.tipMessageMin) { var to = ''; tipMessage = cb.settings.tipMessage.replace('{username}', thisTipper); if(cb.settings.notifierTip == 'Privately to tipper only') { to = thisTipper; } notify(tipMessage,to,yellow_light,mod_orange); } if(cb.settings.kingTipper == 'Yes') { if (thisTipper == currentKing) { kingTip = userTotal; // current king, new total } else if (userTotal > kingTip && userTotal >= kingMin) { // New king currentKing = thisTipper; kingTip = userTotal; notifyTheme(crown + ' We have a new ' + (tip['from_user_gender'] === 'f' ? 'Queen' : 'King') + '! All hail ' + thisTipper + '! ' + crown, ''); } } }); /************************************************************************************************************************************ ***** onEnter *********************************************************************************************************************** ************************************************************************************************************************************/ cb.onEnter(function(user) { var u = user['user']; if (!isBlank(cb.settings.enterMessage)) { var enterMessage = cb.settings.enterMessage.replace(/{newline}/gi, "\n"); notifyTheme(enterMessage,u); } // Add mod to modArray if(user['is_mod']) { if (!cbjs.arrayContains(modArray,u)) { modArrayPopulate(u); modAndEmodArrayPopulate(u); if(cb.settings.wordlistShowModerators == 'Yes') { modBlockMsgArrayPopulate(u); } } if(cb.settings.wordlistToggle == 'Yes') { //Send notice to moderators as they enter notifyErrorBold(bullets + 'UltraBot Ultra - MODERATOR NOTICE' + bullets,u); var modMessage = 'Welcome to ' + cb.room_slug + '\'s room. ' + cb.room_slug + ' is running UltraBot Ultra. This bot automatically blocks certain messages that contain words and phrases that are deemed abusive, inappropriate, or annoying.\n'; if (cbjs.arrayContains(modBlockMsgArray,u)) { modMessage += 'Your blocked message notices are currently ON. To stop seeing them, type: /blocknotice\xa0off.\n'; } else { modMessage += 'Your blocked message notices are currently OFF. To see them again, type: /blocknotice\xa0on.\n'; } modMessage += 'To silence an abusive user using the bot, type: /silence\xa0[username]'; notifyError(modMessage,u); } } }); /************************************************************************************************************************************ ***** Initialize ******************************************************************************************************************** ************************************************************************************************************************************/ if(initialize == 0) { if(cb.settings.colorscheme) { setColor(); } if(cb.settings.wordlistToggle == 'Yes') { parseWordlist(); } if(cb.settings.defaultSilenceLevel) { silenceLevel = parseInt(cb.settings.defaultSilenceLevel.charAt(0)); if(silenceLevel == 4) { notifyErrorBold('No one will be able to chat except for your mods and fan club members. Did you mean to do this?\nFor more information, type "/ubhelp\xa0silencelevel" ', cb.room_slug); } } if(cb.settings.defaultGraphicLevel) { graphicLevel = parseInt(cb.settings.defaultGraphicLevel.charAt(0)); } if(cb.settings.notifierSpam == 'Yes') { parseRotating(); notifierSpamTGL = 1; cb.setTimeout(function() { sendRotating(); notifierSpam(); // random amount of time not more than chosen interval }, Math.floor((Math.random() * notifierTimer) + 1)*minuteMS); } if(cb.settings.kingTipper == 'Yes' && cb.settings.kingTipperSpam == 'Yes') { kingTipperSpam = 1; cb.setTimeout(function() { kingSpamTimer(); // random amount of time not more than chosen interval, plus 20 seconds }, Math.floor((Math.random() * kingTimer) + 1)*minuteMS/3); } if(cb.settings.leaderBoard == 'Yes' && cb.settings.leaderBoardSpam == 'Yes') { leaderboardSpam = 1; cb.setTimeout(function() { ldrSpamTimer(); // random amount of time not more than chosen interval, plus 40 seconds }, Math.floor((Math.random() * ldrTimer) + 1)*minuteMS*2/3); } if(cb.settings.wordlistShowBroadcaster == 'Yes') { modBlockMsgArrayPopulate(cb.room_slug); } if(!isBlank(cb.settings.silenceList)) { var s = cb.settings.silenceList.replace(/\s+/g, ''); silenceArray = s.replace(/^,+|,+$/g,'').split(','); } if(!isBlank(cb.settings.niceList)) { var n = cb.settings.niceList.replace(/\s+/g, ''); niceArray = n.replace(/^,+|,+$/g,'').split(','); } if(!isBlank(cb.settings.greyList)) { var g = cb.settings.greyList.replace(/\s+/g, ''); greyArray = g.replace(/^,+|,+$/g,'').split(','); } if(!isBlank(cb.settings.hostWhisperLevel)) { ignoreArray[findIgnorer(cb.room_slug)][1] = parseInt(cb.settings.hostWhisperLevel.charAt(0)); // setting whisper ignore level for broadcaster } if(cb.settings.wordlistToggle == 'Yes') { //Send notice to moderators notifyErrorBold(bullets + 'UltraBot Ultra - MODERATOR NOTICE' + bullets,'onlyMods'); var modMessage = cb.room_slug + ' has just started UltraBot Ultra. This bot automatically blocks certain messages that contain words and phrases that are deemed abusive, inappropriate, or annoying.\n'; if(cb.settings.wordlistShowModerators == 'Yes') { modMessage += 'Your blocked message notices are currently ON. To stop seeing them, type: /blocknotice\xa0off.\n'; } else { modMessage += 'Your blocked message notices are currently OFF. To see them again, type: /blocknotice\xa0on.\n'; } modMessage += 'To silence an abusive user using the bot, type: /silence\xa0[username]'; notifyError(modMessage,'onlyMods'); if(cb.settings.wordlistShowBroadcaster == 'Yes') { notifyErrorBold(bullets + 'UltraBot Ultra - BROADCASTER NOTICE' + bullets,'roomHost'); // var modMessage = cb.room_slug + ' has just started UltraBot Ultra. This bot automatically blocks certain messages that contain words and phrases that are deemed abusive, inappropriate, or annoying.\n'; var modMessage = 'You have chosen to see blocked message notices. This has the potential to be distracting. It is recommended that let your moderators handle these blocked messages instead.\n'; modMessage += 'To stop seeing them, type "/blocknotice\xa0off"\n'; modMessage += 'Or set "Notify broadcaster" to "No" under Section 3 of the bot launch screen.'; // modMessage += 'To silence an abusive user using the bot, type: /silence\xa0[username]'; notifyError(modMessage,'roomHost'); } } //Initialize initialize = 1; }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.