Apps Home
|
Create an App
SBC Tip Counter+
Author:
salserobachaterocasinero
Description
Source Code
Launch App
Current Users
Created by:
Salserobachaterocasinero
/* [APP] Title: "SBC Tip Counter+" Author: SalseroBachateroCasinero Version: 1.0.0 (3/3/2016) This app simply keeps track of your total tokens received, highest tipper, and most recent tipper (with amounts for each)... for when goals aren't specifically needed. It does however also allow the ability to manually increase (or decrease) the counter (for special circumstances, like if a room crashes or you take a break between multiple parts of a single show, and you need to set the counter to a pre-existing amount to continue where you left off). Type '/sbc-tc adjust [#]' to manually adjust the tip counter up (where [#] is a positive number) or down (with a negative number). You cannot decrease the count to below zero (even if you try). Type '/sbc-tc toptippertotal [U] [#]' to manually set the "highest total" top tipper (where [U] is the user's chat name and [#] is the amount of tokens tipped). Type '/sbc-tc toptippersingle [U] [#]' to manually set the "highest single" top tipper (where [U] is the user's chat name and [#] is the amount of tokens tipped). Type '/sbc-tc lasttipper [U] [#]' to manually set the last tipper (where [U] is the user's chat name and [#] is the amount of tokens tipped). Type '/sbc-tc title [X]' to manually change the room title (where [X] is the new room title or leave blank for the default). Type '/sbc-tc panel total' to switch the custom tip panel view to "highest total tips" only. Type '/sbc-tc panel single' to switch the custom tip panel view to "highest single tip" only. Type '/sbc-tc panel rotate' to switch the custom tip panel view to rotate between "highest total tip" and "highest single tip". Type '/sbc-tc stats' to view the running time and tipping statistics for the current session. <Broadcaster Only> Type '/sbc-tc help' if you forget the above commands. */ var App = { Name: "SBC Tip Counter+", // The name of the app Version: "1.0.0 (3/3/2016)", // The current version of the app Author: "SalseroBachateroCasinero", // The author of this version // Don't change the author unless you've modified something! Command: "sbc-tc", // The "/" command of the app } /* ************************************************** */ var DebugMode = false; var DebugCount = 1; var VerboseDebugMode = false; /* ************************************************** */ var ShowDebugMessage = function (out) { if (DebugMode) { out = out.trim(); output = '<{{0}}> Debug ~ {{1}}: '; output = output.toReplace(String(DebugCount).toPad(2), App.Name); if (out.charAt(0) == '*') { cb.sendNotice(output + String(out.substring(1).trim()), App.Author.toLowerCase(), '#FFFFFF', '#FF0000', 'bolder'); DebugCount++; } else if (VerboseDebugMode) { cb.sendNotice(output + String(out), App.Author.toLowerCase(), '#FFFFFF', '#7F0000', 'bolder'); DebugCount++; } } return DebugMode; }; String.prototype.toReplace = function () { var newString = String(this); for (var idx = 0;idx < arguments.length;idx++) { newString = newString.replace('{{' + idx + '}}', arguments[idx]); } return String(newString); }; String.prototype.toLowerCaseTrim = function () { return String(this).toLowerCase().trim(); }; String.prototype.toPad = function (digits) { var newString = String(this); while (newString.length < digits) { newString = '0' + newString; } return newString; }; Number.prototype.fromSecondsNowMilliseconds = function () { return Number(this) * 1000; // Seconds -> Milliseconds }; var TheInfo = '{{0}} v{{1}} by {{2}}'; TheInfo = TheInfo.toReplace(App.Name, App.Version, App.Author); var FormatCommand = function (info,doublespace) { var newString = "Type '/{{0}} {{1}}" + '\n'; if (doublespace) { newString += '\n'; } return String(newString.toReplace(App.Command, info)); }; var Command = {}; Command['adjust'] = 'adjust'; Command['toptipperT'] = 'toptippertotal'; Command['toptipperS'] = 'toptippersingle'; Command['lasttipper'] = 'lasttipper'; Command['title'] = 'title'; Command['panel'] = 'panel'; Command['panelT'] = 'total'; Command['panelS'] = 'single'; Command['panelR'] = 'rotate'; Command['stats'] = 'stats'; Command['help'] = 'help'; var TheCommands = '\n'; TheCommands += FormatCommand("{{0}} [#]' to manually adjust the tip counter up (where [#] is a positive number) or down (with a negative number). You cannot decrease the count to below zero (even if you try).".toReplace(Command['adjust']), true); TheCommands += FormatCommand("{{0}} [X]' to manually change the room title (where [X] is the new room title.".toReplace(Command['title']), true); TheCommands += FormatCommand("{{0}} [U] [#]' to manually set the 'highest total' top tipper (where [U] is the user's chat name and [#] is the amount of tokens tipped).".toReplace(Command['toptipperT']), false); TheCommands += FormatCommand("{{0}} [U] [#]' to manually set the 'highest single' top tipper (where [U] is the user's chat name and [#] is the amount of tokens tipped).".toReplace(Command['toptipperS']), false); TheCommands += FormatCommand("{{0}} [U] [#]' to manually set the last tipper (where [U] is the user's chat name and [#] is the amount of tokens tipped).".toReplace(Command['lasttipper']), true); TheCommands += FormatCommand("{{0}} {{1}}' to switch the custom tip panel view to 'highest total tips' only.".toReplace(Command['panel'], Command['panelT']), false); TheCommands += FormatCommand("{{0}} {{1}}' to switch the custom tip panel view to 'highest single tip' only.".toReplace(Command['panel'], Command['panelS']), false); TheCommands += FormatCommand("{{0}} {{1}}' to switch the custom tip panel view to rotate between 'highest total tip' and 'highest single tip'.".toReplace(Command['panel'], Command['panelR']), true); TheCommands += FormatCommand("{{0}}' to view the running time and tipping statistics for the current session. <Broadcaster Only>".toReplace(Command['stats']), true); TheCommands += FormatCommand("{{0}}' if you forget the above commands.".toReplace(Command['help']), false); var TheHelp = '\n' + '*** {{0}} ***' + '\n'; TheHelp += '{{1}}'; TheHelp = TheHelp.toReplace(TheInfo, TheCommands); cb.settings_choices = [ { name: 'support', type: 'choice', label: "Enable support mode?", choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, { name: 'moderation', type: 'choice', label: "Allow moderators to access this feature?", choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'alwaysallowedusers', type: 'str', required: false, label: 'List of users that will have moderator access at all times, regardless of the previous question (separate with ; for more than 1 or leave blank for none)', defaultValue: '' }, { name: 'noticebackground', type: 'str', label: 'Notification background color in hex #RrGgBb format (default is white / #FFFFFF)', defaultValue: '#FFFFFF' }, { name: 'noticetext', type: 'str', label: 'Notification text color in hex #RrGgBb format (default is red / #FF0000)', defaultValue: '#FF0000' }, { name: 'noticeweight', type: 'choice', label: 'Notification weight', choice1: 'Normal', choice2: 'Bold', choice3: 'Bolder', defaultValue: 'Bolder' }, { name: 'whichcustompanel', type: 'choice', label: "Show 'top tipper' based on 'highest total tips', 'highest single tip', or rotate between the two?", choice1: 'Highest Total Tips', choice2: 'Highest Single Tip', choice3: 'Rotate', defaultValue: 'Yes' }, { name: 'custompanelinterval', type: 'int', label: 'Interval for rotation (in seconds / minimum = 5 / maximum = 60)', minValue: 5, maxValue: 60, defaultValue: 5 }, { name: 'custompanel', type: 'choice', label: "Customize the tip token panel (using the next 4 inputs -- if any are left blank, this will default to 'No')?", choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'AllTipsLabel', type: 'str', label: '1. Label to indicate the total amount of tokens received (during this app session)', required: false, maxLength: 20, defaultValue: 'Total Tips Received' }, { name: 'hightiplabel', type: 'str', label: '2a. Label to indicate the highest total tipper', required: false, maxLength: 10, defaultValue: 'Most Tips' }, { name: 'blankhigh', type: 'str', label: '2b. What to show when there is no highest total tipper yet (upon app startup)', required: false, maxLength: 14, defaultValue: 'N/A' }, { name: 'goodtiplabel', type: 'str', label: '3a. Label to indicate the highest single tipper', required: false, maxLength: 10, defaultValue: 'Top Tipper' }, { name: 'blankgood', type: 'str', label: '3b. What to show when there is no highest single tipper yet (upon app startup)', required: false, maxLength: 14, defaultValue: 'N/A' }, { name: 'lasttiplabel', type: 'str', label: '4a. Label to indicate the most recent tipper', required: false, maxLength: 10, defaultValue: 'Latest Tip' }, { name: 'blanklast', type: 'str', label: '4b. What to show when there is no most recent tipper yet (upon app startup)', required: false, maxLength: 14, defaultValue: 'N/A' }, ]; var SupportMode = cb.settings['support'] == 'Yes'; var NoticeStyle = []; NoticeStyle['BackgroundColor'] = cb.settings['noticebackground']; NoticeStyle['TextColor'] = cb.settings['noticetext']; NoticeStyle['Weight'] = cb.settings['noticeweight']; var TheBroadcaster = cb['room_slug']; var ActiveBroadcaster = SupportMode ? App.Author.toLowerCase() : TheBroadcaster; var CurrentUser; // Moderators "Allowed" To Use This App // var ModeratorsAllowed = cb.settings['moderation'] == 'Yes'; // Moderators "Allowed" To Use This App // // Users "Always Allowed" To Use This App // var AlwaysAllowedUsers = cb.settings['alwaysallowedusers'] == null ? [] : cb.settings['alwaysallowedusers'].length == 0 ? [] : cb.settings['alwaysallowedusers'].split(';'); // Users "Always Allowed" To Use This App // var UserIs = []; UserIs.ThisUser = function (CompareUser) { return CurrentUser == CompareUser; }; // User Is The App Author // UserIs.Author = function () { return UserIs.ThisUser(App.Author.toLowerCase()); }; // User Is The App Author // // User Is The Actual Broadcaster // UserIs.TheBroadcaster = function () { return UserIs.ThisUser(TheBroadcaster); }; // User Is The Actual Broadcaster // // User Is The Active Broadcaster (Spoofed To App Author When Support Mode Is Active) // UserIs.ActiveBroadcaster = function () { return UserIs.ThisUser(ActiveBroadcaster); }; // User Is The Active Broadcaster (Spoofed To App Author When Support Mode Is Active) // // User Is An "Allowed" Moderator // UserIs.AllowedModerator = function (msg) { return (UserIs.Moderator(msg) && ModeratorsAllowed); }; // User Is An "Allowed" Moderator // // User Exists In The "Always-Allowed Users" List // UserIs.AlwaysAllowed = function () { if (SupportMode && UserIs.TheBroadcaster()) { return true; } for (i=0;i<AlwaysAllowedUsers.length;i++) { if (UserIs.ThisUser(AlwaysAllowedUsers[i].toLowerCase().trim())) { return true; break; } } return false; }; // User Exists In The "Always-Allowed Users" List // // User Is A Moderator // UserIs.Moderator = function (msg) { return msg['is_mod']; }; // User Is A Moderator // // User Is A Fan Club Member // UserIs.FanClubMember = function (msg) { return msg['in_fanclub']; }; // User Is A Fan Club Member // // User Is A Super Tipper // UserIs.SuperTipper = function (msg) { return msg['tipped_tons_recently']; }; // User Is A Super Tipper // // User Is A Big Tipper // UserIs.BigTipper = function (msg) { return msg['tipped_alot_recently']; }; // User Is A Big Tipper // // User Is A Tipper // UserIs.Tipper = function (msg) { return msg['tipped_recently']; }; // User Is A Tipper // // User Is A Token Owner // UserIs.TokenOwner = function (msg) { return msg['has_tokens']; }; // User Is A Token Owner // // User Is Gray // UserIs.Gray = function (user) { return ((!(UserIs.TokenOwner(user))) && (!(UserIs.FanClubMember(user))) && (!(UserIs.Moderator(user))) && (!(UserIs.AlwaysAllowed())) && (!(UserIs.TheBroadcaster()))); }; // User Is Gray // var SendTo = []; // Send Notice To All Or Specified User/Group As Indicated // SendTo.Default = function (msg,user,group) { if (group == null || group == '') { cb.sendNotice(msg, user, NoticeStyle['BackgroundColor'], NoticeStyle['TextColor'], NoticeStyle['Weight']); } else { cb.sendNotice(msg, user, NoticeStyle['BackgroundColor'], NoticeStyle['TextColor'], NoticeStyle['Weight'], group); } }; // Send Notice To All Or Specified User/Group As Indicated // // Send Notice To The "Always-Allowed Users" List // SendTo.AlwaysAllowedUsers = function (msg,bg,fg,wt) { for (i=0;i<AlwaysAllowedUsers.length;i++) { if (!(UserIs.AllowedModerator(msg)) || (SupportMode && UserIs.TheBroadcaster())) { cb.sendNotice(msg, AlwaysAllowedUsers[i].trim(), bg, fg, wt); } } }; // Send Notice To The "Always-Allowed Users" List // // Send Notice To Broadcaster, Moderators (If "Allowed"), And "Always-Allowed Users" List // SendTo.ImportantUsers = function (msg) { if (SupportMode) { if ((!(UserIs.TheBroadcaster(App.Author.toLowerCase()))) && (!(UserIs.Moderator(App.Author.toLowerCase()) && ModeratorsAllowed)) || (!(UserIs.AlwaysAllowed(App.Author.toLowerCase())))) { // Author Is Broadcaster? ~or~ Author Is A Moderator & Moderators Allowed? ~or~ Author Is Always-Allowed? Don't Do This. SendTo.Default(msg, App.Author.toLowerCase()); } } SendTo.Default(msg, TheBroadcaster); if (ModeratorsAllowed) { SendTo.Default(msg, null, 'red'); } SendTo.AlwaysAllowedUsers(msg, NoticeStyle['BackgroundColor'], NoticeStyle['TextColor'], NoticeStyle['Weight']); }; // Send Notice To Broadcaster, Moderators (If "Allowed"), And "Always-Allowed Users" List // // Send Special Case // SendTo.Special = function (msg,user,group) { cb.sendNotice(msg, user, '#FFFFFF', '#FF0000', 'bolder', group); }; // Send Special Case // // Feature Functions // var Feature = []; Feature.RotatePanel = function () { if (RotatePanel) { ShowGoodTipper = !ShowGoodTipper; ShowHighTipper = !ShowHighTipper; cb.drawPanel(); cb.setTimeout(Feature.RotatePanel, RotateTimer); } }; // Manually Adjust Tip Counter // Feature.ManuallyAdjustTipCounter = function (TokenCount) { /* ************************************************** */ ShowDebugMessage("* Feature.ManuallyAdjustTipCounter(TokenCount)"); ShowDebugMessage("TokenCount=" + TokenCount); /* ************************************************** */ if (TokenCount > 0) { output = '\n' + "{{0}}: {{1}} has adjusted the tip counter by adding {{2}} token{{3}}." + '\n'; output = output.toReplace(App.Name, CurrentUser, TokenCount, (TokenCount == 1 ? '' : 's')); SendTo.ImportantUsers(output); AllTipsAmount += TokenCount; cb.drawPanel(); } else if (TokenCount < 0) { TokenCount = TokenCount * -1; if (AllTipsAmount - TokenCount < 0) { output = '\n' + "{{0}}: the result would cause the tip counter to go below zero, so the amount to remove will be set to the total available." + '\n'; output = output.toReplace(App.Name); SendTo.Special(output, CurrentUser); TokenCount = AllTipsAmount; } output = '\n' + "{{0}}: {{1}} has adjusted the tip counter by removing {{2}} token{{3}}." + '\n'; output = output.toReplace(App.Name, CurrentUser, TokenCount, (TokenCount == 1 ? '' : 's')); SendTo.ImportantUsers(output); AllTipsAmount -= TokenCount; cb.drawPanel(); } else { output = '\n' + "{{0}}: you must add or remove at least 1 token." + '\n'; output = output.toReplace(App.Name); SendTo.Special(output, CurrentUser); } /* ************************************************** */ ShowDebugMessage("* Feature.ManuallyAdjustTipCounter(TokenCount) Complete"); /* ************************************************** */ }; // Manually Adjust Tip Counter // // Manually Set Top Tipper // Feature.ManuallySetTipper = function (tippertype, tipper, tippedamount) { if (tippertype == Command['toptipperT']) { HighTipAmount = tippedamount; HighTipper = tipper; } else if (tippertype == Command['toptipperS']) { GoodTipAmount = tippedamount; GoodTipper = tipper; } else if (tippertype == Command['lasttipper']) { LastTipAmount = tippedamount; LastTipper = tipper; } cb.drawPanel(); }; // Manually Set Top Tipper // // Feature Functions // // Utility Functions // var Utility = []; var StartTime = new Date(); Utility.GetUpTime = function () { var CurrentTime = new Date(); var d = (CurrentTime - StartTime) / 1000; if (d < 60) { return Math.floor(d) + " Seconds" } d /= 60; var m = Math.floor(d % 60); var h = Math.floor(d / 60); var str = ''; if (h) str += h + ' Hours, '; str += m + ' Minutes' return str; }; var TotalActualTokens = 0; // Show Session Stats // Utility.ShowStats = function () { output = 'Current Session Running Time: {{0}}' + '\n\n'; output += 'Total Tokens In Tip Counter: {{1}}' + '\n'; output += 'Total Tokens Actually Received: {{2}}' + '\n\n'; output = output.toReplace(Utility.GetUpTime(), AllTipsAmount, TotalActualTokens); output += 'Highest Total Amount Tipped: {{0}}{{1}}' + '\n'; output = output.toReplace(HighTipAmount, (HighTipper == null ? '' : ' (by {{0}})'.toReplace(HighTipper))); output += 'Highest Single Amount Tipped: {{0}}{{1}}' + '\n'; output = output.toReplace(GoodTipAmount, (GoodTipper == null ? '' : ' (by {{0}})'.toReplace(GoodTipper))); output += 'Latest Single Amount Tipped: {{0}}{{1}}' + '\n'; output = output.toReplace(LastTipAmount, (LastTipper == null ? '' : ' (by {{0}})'.toReplace(LastTipper))); return output; }; // Show Session Stats // // Hide Message From Chat Room // Utility.HideMessageFromChatRoom = function (msg) { msg['X-Spam'] = true; }; // Hide Message From Chat Room // // Command Handler // Utility.CheckForCommand = function (msg) { var CommandParamaters = msg['m'].toLowerCaseTrim().split(" "); var CommandCheck = CommandParamaters[0].substring(1); var InvalidCommand = false; /* ************************************************** */ if (DebugMode) { for (x=0;x<CommandParamaters.length;x++) { ShowDebugMessage(x + '=[' + CommandParamaters[x] + ']'); } } ShowDebugMessage("CommandParamaters[0].charAt(0)=[" + CommandParamaters[0].charAt(0) + "]"); ShowDebugMessage("CommandCheck / CommandParamaters[0].substring(1)=[" + CommandCheck + "]"); /* ************************************************** */ // All Users // switch (CommandParamaters[0].charAt(0)) { // Commands // case ('/'): if (CommandCheck == App.Command) { Utility.HideMessageFromChatRoom(msg); switch (CommandParamaters[1]) { case null: case undefined: break; default: break; } // (End Switch) } break; // Commands // } // (End Switch) // All Users // // Broadcaster, Moderators (If "Allowed"), And "Always-Allowed Users" Only // if (UserIs.TheBroadcaster() || UserIs.ActiveBroadcaster() || UserIs.AllowedModerator(msg) || UserIs.AlwaysAllowed()) { switch (CommandParamaters[0].charAt(0)) { // Commands // case ('/'): // Show "Universal" Help // if (CommandCheck == 'help') { Utility.HideMessageFromChatRoom(msg); SendTo.Default(TheHelp, CurrentUser); InvalidCommand = false; break; } // Show "Universal" Help // if (CommandCheck == App.Command) { switch (CommandParamaters[1]) { // Manually Adjust The Tip Counter // case Command['adjust']: switch (isNaN(CommandParamaters[2]) || parseInt(CommandParamaters[2])) { case true: if (!(CommandParamaters[2] == null || CommandParamaters[2] == '')) { output = '\n' + "{{0}}: '{{1}}' is not a number, but one is required for this command." + '\n'; output = output.toReplace(App.Name, CommandParamaters[2]); } else { output = '\n' + "{{0}}: you didn't supply a quantity of tokens to add or subtract." + '\n'; output = output.toReplace(App.Name); } SendTo.Special(output, CurrentUser); InvalidCommand = true; break; default: Feature.ManuallyAdjustTipCounter(parseInt(CommandParamaters[2])); InvalidCommand = false; break; } break; // Manually Adjust The Tip Counter // // Manually Set Top Tipper // case Command['toptipperT']: case Command['toptipperS']: case Command['lasttipper']: switch (CommandParamaters[2]) { case undefined: output = '\n' + "{{0}}: you didn't supply the user's name or amount of tokens tipped." + '\n'; output = output.toReplace(App.Name); SendTo.Special(output, CurrentUser); InvalidCommand = true; break; default: switch (isNaN(CommandParamaters[3]) || parseInt(CommandParamaters[3])) { case true: if (!(CommandParamaters[3] == null || CommandParamaters[3] == '')) { output = '\n' + "{{0}}: '{{1}}' is not a number, but one is required for this command." + '\n'; output = output.toReplace(App.Name, CommandParamaters[3]); } else { output = '\n' + "{{0}}: you didn't supply the amount of tokens tipped." + '\n'; output = output.toReplace(App.Name); } SendTo.Special(output, CurrentUser); InvalidCommand = true; break; default: Feature.ManuallySetTipper(CommandParamaters[1], CommandParamaters[2], parseInt(CommandParamaters[3])); output = '\n' + "{{0}}: {{1}} was set as the 'highest {{2}}' top tipper for {{3}} tokens by {{4}}." + '\n'; output = output.toReplace(App.Name, CommandParamaters[2], (CommandParamaters[1] == Command['toptipperT'] ? 'total' : 'single' ), CommandParamaters[3], CurrentUser); SendTo.ImportantUsers(output, CurrentUser); InvalidCommand = false; break; } break; } break; // Manually Set Top Tipper // // Manually Change The Room Title // case Command['title']: switch (CommandParamaters[2]) { case undefined: output = '\n' + "{{0}}: you didn't supply a new title for the room." + '\n'; output = output.toReplace(App.Name); SendTo.Special(output, CurrentUser); InvalidCommand = true; break; default: /* ************************************************** */ ShowDebugMessage("msg['m'].substring(1 + CommandParamaters[0].length + 1 + CommandParamaters[1].length + 1)=[" + msg['m'].substring(1 + CommandParamaters[0].length + 1 + CommandParamaters[1].length + 1) + ']'); /* ************************************************** */ cb.changeRoomSubject(msg['m'].substring(CommandParamaters[0].length + 1 + CommandParamaters[1].length + 1).trim()); output = '\n' + "{{0}}: room title changed by {{1}}." + '\n'; output = output.toReplace(App.Name, CurrentUser); SendTo.ImportantUsers(output); InvalidCommand = false; break; } break; // Manually Change The Room Title // // Manually Change The Custom Panel Type // case Command['panel']: switch (CommandParamaters[2]) { case undefined: output = '\n' + "{{0}}: you didn't supply the type of custom panel to use. Please choose from '{{1}}', '{{2}}', or '{{3}}'." + '\n'; output = output.toReplace(App.Name, Command['panelT'], Command['panelS'], Command['panelR']); SendTo.Special(output, CurrentUser); InvalidCommand = true; break; case Command['panelT']: ShowHighTipper = true; ShowGoodTipper = false; RotatePanel = false; cb.setTimeout(Feature.RotatePanel, RotateTimer); output = '\n' + "{{0}}: the type of custom panel has been changed to 'highest total tips' by {{1}}." + '\n'; output = output.toReplace(App.Name, CurrentUser); SendTo.ImportantUsers(output); InvalidCommand = false; break; case Command['panelS']: ShowHighTipper = false; ShowGoodTipper = true; RotatePanel = false; cb.setTimeout(Feature.RotatePanel, RotateTimer); output = '\n' + "{{0}}: the type of custom panel has been changed to 'highest single tip' by {{1}}." + '\n'; output = output.toReplace(App.Name, CurrentUser); SendTo.ImportantUsers(output); InvalidCommand = false; break; case Command['panelR']: RotatePanel = true; cb.setTimeout(Feature.RotatePanel, RotateTimer); output = '\n' + "{{0}}: the type of custom panel has been changed to 'rotating' by {{1}}." + '\n'; output = output.toReplace(App.Name, CurrentUser); SendTo.ImportantUsers(output); InvalidCommand = false; break; default: output = '\n' + "{{0}}: '{{1}}' is not a valid custom panel option. Please choose from '{{2}}', '{{3}}', or '{{4}}'." + '\n'; output = output.toReplace(App.Name, CommandParamaters[2], Command['panelT'], Command['panelS'], Command['panelR']); SendTo.Special(output, CurrentUser); InvalidCommand = true; break; } break; // Manually Change The Custom Panel Type // // Show Stats // case Command['stats']: if (UserIs.TheBroadcaster() || (SupportMode && UserIs.Author())) { output = '\n' + '{{0}}: stats for this session are shown below.' + '\n\n'; output = output.toReplace(App.Name); output += Utility.ShowStats(); SendTo.Default(output, CurrentUser); InvalidCommand = false; } break; // Show Stats // // Show Help // case undefined: case Command['help']: SendTo.Default(TheHelp, CurrentUser); InvalidCommand = false; break; // Show Help // // Toggle Support Mode (Must Be Broadcaster) // case 'support': if (UserIs.TheBroadcaster()) { SupportMode = !SupportMode; ActiveBroadcaster = SupportMode ? App.Author.toLowerCase() : TheBroadcaster; output = '\n' + '{{0}}: support mode {{1}}abled.' + '\n'; output = output.toReplace(App.Name, (SupportMode ? 'en' : 'dis' )); SendTo.Special(output, CurrentUser); if (UserIs.TheBroadcaster() != UserIs.Author()) { SendTo.Special(output, App.Author.toLowerCase()); } InvalidCommand = false; } break; // Toggle Support Mode (Must Be Broadcaster) // // Toggle Debug Mode (Must Be App Author) // case 'debug': if ((!(SupportMode)) && DebugMode && UserIs.Author()) { // Escape Debug Mode If Support Mode Is Prematurely Deactivated DebugMode = false; output = '\n' + '{{0}}: debug mode disabled.' + '\n'; output = output.toReplace(App.Name); SendTo.Special(output, CurrentUser); } if (SupportMode && UserIs.Author()) { DebugMode = !DebugMode; if (DebugMode) { DebugCount = 1; } output = '\n' + '{{0}}: debug mode {{1}}abled.' + '\n'; output = output.toReplace(App.Name, (DebugMode ? 'en' : 'dis' )); SendTo.Special(output, CurrentUser); InvalidCommand = false; } break; // Toggle Debug Mode (Must Be App Author) // // Toggle Verbose Debug Mode (Must Be App Author) // case 'verbose': if ((!(SupportMode)) && DebugMode && VerboseDebugMode && UserIs.Author()) { // Allow Verbose Debug Mode Toggle If Support Mode Is Prematurely Deactivated VerboseDebugMode = !VerboseDebugMode; output = '\n' + '{{0}}: verbose debug mode {{1}}abled.' + '\n'; output = output.toReplace(App.Name, (VerboseDebugMode ? 'en' : 'dis' )); SendTo.Special(output, CurrentUser); } if (SupportMode && UserIs.Author()) { if (DebugMode) { VerboseDebugMode = !VerboseDebugMode; } else { DebugMode = true; VerboseDebugMode = true; } output = '\n' + '{{0}}: verbose debug mode {{1}}abled.' + '\n'; output = output.toReplace(App.Name, (VerboseDebugMode ? 'en' : 'dis' )); SendTo.Special(output, CurrentUser); InvalidCommand = false; } break; // Toggle Verbose Debug Mode (Must Be App Author) // // Invalid Command Option // default: output = '\n' + "{{0}}: invalid command option: '{{1}}'." + '\n' output += '{{2}}'; output = output.toReplace(App.Name, msg['m'].substring(1), TheCommands); SendTo.Special(output, CurrentUser); InvalidCommand = true; break; // Invalid Command Option // } // (End Switch) } break; // Commands // } // (End Switch) } // Broadcaster, Moderators (If "Allowed"), And "Always-Allowed Users" Only // /* ************************************************** */ ShowDebugMessage("InvalidCommand=" + InvalidCommand); /* ************************************************** */ /* Disabled: NOT COMPATIBLE WITH MULTIPLE APP/BOT COMBINATIONS if (CommandCheck == App.Command) { output = "Command {{0}}executed: '{{1}}'"; output = output.toReplace((InvalidCommand ? 'not ' : '' ), msg['m']); msg['m'] = output; } */ }; // Command Handler // // Utility Functions // var AllTipsAmount = 0; var HighTipAmountTracker = {}; var HighTipperTracker = {}; var LengthTracker = []; var HighTipAmount = 0 var HighTipper = null; var GoodTipAmount = 0; var GoodTipper = null; var LastTipAmount = 0; var LastTipper = null; // Build Custom Info Panel // var ShowHighTipper = cb.settings['whichcustompanel'] == 'Highest Total Tips'; var ShowGoodTipper = cb.settings['whichcustompanel'] == 'Highest Single Tip'; var RotatePanel = cb.settings['whichcustompanel'] == 'Rotate'; if (RotatePanel) { ShowGoodTipper = true; ShowHighTipper = false; } var RotateTimer = 0; var NothingEmpty = (!((cb.settings['AllTipsLabel'] == null || cb.settings['AllTipsLabel'].length == 0) || (cb.settings['goodtiplabel'] == null || cb.settings['goodtiplabel'].length == 0) || (cb.settings['blankgood'] == null || cb.settings['blankgood'].length == 0) || (cb.settings['hightiplabel'] == null || cb.settings['hightiplabel'].length == 0) || (cb.settings['blankhigh'] == null || cb.settings['blankhigh'].length == 0) || (cb.settings['lasttiplabel'] == null || cb.settings['lasttiplabel'].length == 0) || (cb.settings['blanklast'] == null || cb.settings['blanklast'].length == 0))); var CustomPanel = cb.settings['custompanel'] == 'Yes'; if (NothingEmpty && CustomPanel) { var AllTipsLabel = cb.settings['AllTipsLabel']; var HighTipLabel = cb.settings['hightiplabel']; var BlankHigh = cb.settings['blankhigh']; var GoodTipLabel = cb.settings['goodtiplabel']; var BlankGood = cb.settings['blankgood']; var LastTipLabel = cb.settings['lasttiplabel']; var BlankLast = cb.settings['blanklast']; } else { var AllTipsLabel = 'Total Tokens Received'; var HighTipLabel = 'Hit It Most'; var BlankHigh = 'Wanna Ride On Top?'; var GoodTipLabel = 'Hit It Hard'; var BlankGood = 'Long-Term Lover!'; var LastTipLabel = 'Hit It Last'; var BlankLast = "I'm Still A Virgin <3"; } // Build Custom Info Panel // // Chaturbate Info Panel Handler // function onDrawPanel(user) { /* ************************************************** */ ShowDebugMessage("* onDrawPanel(user)"); /* ************************************************** */ CurrentUser = user['user']; var HighTip = HighTipper === null ? BlankHigh : '{{0}} [{{1}}]'.toReplace(HighTipper.substring(0, 14), HighTipAmount); var GoodTip = GoodTipper === null ? BlankGood : '{{0}} [{{1}}]'.toReplace(GoodTipper.substring(0, 14), GoodTipAmount); var LastTip = LastTipper === null ? BlankLast : '{{0}} [{{1}}]'.toReplace(LastTipper.substring(0, 14), LastTipAmount); /* ************************************************** */ ShowDebugMessage("* onDrawPanel(user) Complete"); /* ************************************************** */ if (ShowHighTipper) { return { 'template': '3_rows_11_21_31', 'row1_value': '{{0}}: {{1}}'.toReplace(AllTipsLabel, AllTipsAmount), 'row2_value': '{{0}}: {{1}}'.toReplace(HighTipLabel, HighTip), 'row3_value': '{{0}}: {{1}}'.toReplace(LastTipLabel, LastTip) }; } else if (ShowGoodTipper) { return { 'template': '3_rows_11_21_31', 'row1_value': '{{0}}: {{1}}'.toReplace(AllTipsLabel, AllTipsAmount), 'row2_value': '{{0}}: {{1}}'.toReplace(GoodTipLabel, GoodTip), 'row3_value': '{{0}}: {{1}}'.toReplace(LastTipLabel, LastTip) }; } } cb.onDrawPanel(function(user) { return onDrawPanel(user); }); // Chaturbate Info Panel Handler // // Chaturbate Tip Handler // function onTip(tip) { /* ************************************************** */ ShowDebugMessage("* onTip(tip)"); /* ************************************************** */ LastTipAmount = parseInt(tip['amount']); LastTipper = tip['from_user']; /* ************************************************** */ ShowDebugMessage("LastTipper=" + LastTipper); ShowDebugMessage("LastTipAmount=" + LastTipAmount); /* ************************************************** */ CurrentUser = LastTipper; AllTipsAmount += LastTipAmount; HighTipAmountTracker[LastTipper] = HighTipAmountTracker[LastTipper] >= 0 ? HighTipAmountTracker[LastTipper] + LastTipAmount : LastTipAmount; HighTipperTracker[LastTipper] = LastTipper; var DoesNotExist = true; for (i=0;i<LengthTracker.length;i++) { if (LengthTracker[i] == LastTipper) { DoesNotExist = false; break; } } if (DoesNotExist) { LengthTracker[LengthTracker.length] = LastTipper; } var HighTest = 0; for (i=0;i<LengthTracker.length;i++) { if (HighTipAmountTracker[LengthTracker[i]] > HighTest) { HighTipAmount = HighTipAmountTracker[LengthTracker[i]]; HighTipper = HighTipperTracker[LengthTracker[i]]; HighTest = HighTipAmount; } } if (LastTipAmount > GoodTipAmount) { GoodTipAmount = LastTipAmount; GoodTipper = LastTipper; } cb.drawPanel(); TotalActualTokens += LastTipAmount; /* ************************************************** */ ShowDebugMessage("* onTip(tip) Complete"); /* ************************************************** */ } cb.onTip(function(tip) { return onTip(tip); }); // Chaturbate Tip Handler // // Chaturbate Welcome Handler // function onEnter(user) { /* ************************************************** */ ShowDebugMessage("* onEnter(user)"); /* ************************************************** */ CurrentUser = user['user']; if (UserIs.Author()) { output = '{{0}} is being used by {{1}}.' + '\n'; output = output.toReplace(TheInfo, TheBroadcaster); SendTo.Special(output, App.Author.toLowerCase()); } /* ************************************************** */ ShowDebugMessage("* onEnter(user) Complete"); /* ************************************************** */ } cb.onEnter(function(user) { return onEnter(user); }); // Chaturbate Welcome Handler // // Chaturbate Message Handler // function onMessage(msg) { /* ************************************************** */ ShowDebugMessage("* onMessage(msg)"); /* ************************************************** */ CurrentUser = msg['user']; msg['m'] = msg['m'].replace(/\s\s+/g, ' '); /* ************************************************** */ ShowDebugMessage("msg=" + msg['m']); /* ************************************************** */ Utility.CheckForCommand(msg); /* ************************************************** */ ShowDebugMessage("* onMessage(msg) Complete"); /* ************************************************** */ return msg; } cb.onMessage(function (msg) { return onMessage(msg); }); // Chaturbate Message Handler // // Startup Message // var TheStartup = '\n' + '{{0}} has been activated.' + '\n'; TheStartup = TheStartup.toReplace(TheInfo); var Startup = []; Startup.Init = function () { /* ************************************************** */ ShowDebugMessage("* Startup.Init()"); /* ************************************************** */ NoticeStyle['Weight'] = NoticeStyle['Weight'].toLowerCase(); SendTo.Default(TheStartup); cb.setTimeout(Startup.Delay, 2000); /* ************************************************** */ ShowDebugMessage("* Startup.Init() Complete"); /* ************************************************** */ }; Startup.Delay = function () { /* ************************************************** */ ShowDebugMessage('* Startup.Delay()'); /* ************************************************** */ /* cb.setTimeout(SendTo.ImportantUsers(TheCommands), 2000); */ cb.setTimeout(SendTo.ImportantUsers('\n' + FormatCommand("{{0}}' to see a list of the available commands for this app.".toReplace(Command['help']), false)), 2000); RotateTimer = cb.settings['custompanelinterval'].fromSecondsNowMilliseconds(); cb.setTimeout(Feature.RotatePanel, RotateTimer); /* ************************************************** */ ShowDebugMessage('* Startup.Delay() Complete'); /* ************************************************** */ }; cb.setTimeout(Startup.Init, 1); // Startup Message //
© Copyright Chaturbate 2011- 2026. All Rights Reserved.