Bots Home
|
Create an App
CL
Author:
pjotter
Description
Source Code
Launch Bot
Current Users
Created by:
Pjotter
/* Title: "CLLS" app Authors: pjotter1234 & Corbin Black Version: 0.1 (15/02/2018) A LoveSense app created for Corbin Black's room V 0.1 - First version */ var NumTipGoals = 4; var goalSettings = []; for (var gSetting = 1; gSetting <= NumTipGoals; gSetting++) { goalSettings.push({ name: 'goal_' + gSetting + '_tokens', label: 'Goal ' + gSetting + ' Token Amount', type: 'int', minValue: 1, defaultValue: 200, required: (gSetting === 1) }); goalSettings.push({ name: 'goal_' + gSetting + '_description', label: 'Goal ' + gSetting + ' Description', type: 'str', minLength: (gSetting === 1 ? 1 : 0), maxLength: 255, required: (gSetting === 1) }); } cb.settings_choices = [ {name:'LSNotifierBool', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "1. Notices Settings -- " }, {name:'LSNotifierTitle', type:'str', required: true, label:'Title', defaultValue: 'HE LoveSense IS A SOUND SENSITIVE Toy THAT IS SET TO REACT TO YOUR TIPS. THERE ARE FIVE LEVELS OF INTENSITY AND DURATION'}, {name:'LSNotifierLev1', type:'str', required: false, label:'Level 1', defaultValue: 'Level 1 - Tip (1-14) Sweet pleasure'}, {name:'LSNotifierLev2', type:'str', required: false, label:'Level 2', defaultValue: 'Level 2 - Tip (15-99) Hard level'}, {name:'LSNotifierLev3', type:'str', required: false, label:'Level 3', defaultValue: 'Level 3 - Tip (100-499) Oh YES, I love this toy'}, {name:'LSNotifierLev4', type:'str', required: false, label:'Level 4', defaultValue: 'Level 4 - Tip (500-999) OMG! OMG!'}, {name:'LSNotifierLev5', type:'str', required: false, label:'Level 5', defaultValue: 'Level 5 - Tip (1000+) True LOVE'}, {name:'LSNotifierFColor', type:'str', label:'ForeGround Color (e.g #000000)', defaultValue: '#7B68EE'}, {name:'LSNotifierBColor', type:'str', label:'BackGround Color (e.g #000000)', defaultValue: '#000000'}, {name:'LSNotifierInterval', type:'int', minValue: 1, maxValue: 999, defaultValue: 5, label: 'Interval Time (min 1)'}, {name:'LSThanksBool', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "2. Auto Thank You -- " }, {name:'LSThanksFColorLev2', type:'str', label:'ForeGround Color (Level 2)', defaultValue: '#7B68EE'}, {name:'LSThanksBColorLev2', type:'str', label:'BackGround Color (Level 2)', defaultValue: '#000000'}, {name:'LSThanks1Lev2', type:'str', required: false, label:'Random Thank you For Level 2',defaultValue: 'LEVEL 2! Thank you for give me more pleasure, I love it!!'}, {name:'LSThanks2Lev2', type:'str', required: false, label:'Random Thank you For Level 2',defaultValue: 'LEVEL 2! Thank you sweetheart, I love it!!'}, {name:'LSThanks3Lev2', type:'str', required: false, label:'Random Thank you For Level 2',defaultValue: 'LEVEL 2! I love the vibrations, thank you!!'}, {name:'LSThanks4Lev2', type:'str', required: false, label:'Random Thank you For Level 2',defaultValue: 'LEVEL 2! Thank you!! :heart2 '}, {name:'LSThanksFColorLev3', type:'str', label:'ForeGround Color (Level 3)', defaultValue: '#7B68EE'}, {name:'LSThanksBColorLev3', type:'str', label:'BackGround Color (Level 3)', defaultValue: '#000000'}, {name:'LSThanks1Lev3', type:'str', required: false, label:'Random Thank you For Level 3',defaultValue: 'LEVEL 3! Oh YES, You know how to make me moan, thank you!!'}, {name:'LSThanks2Lev3', type:'str', required: false, label:'Random Thank you For Level 3',defaultValue: 'LEVEL 3! YES, YES YES, You know how to make me moan, thank you!!'}, {name:'LSThanks3Lev3', type:'str', required: false, label:'Random Thank you For Level 3',defaultValue: 'LEVEL 3! You know how to make me happy my love, thank you!!'}, {name:'LSThanksFColorLev4', type:'str', label:'ForeGround Color (Level 4)', defaultValue: '#7B68EE'}, {name:'LSThanksBColorLev4', type:'str', label:'BackGround Color (Level 4)', defaultValue: '#000000'}, {name:'LSThanks1Lev4', type:'str', required: false, label:'Random Thank you For Level 4',defaultValue: 'LEVEL 4! OMG! OMG! OMG! Do not stop please'}, {name:'LSThanks2Lev4', type:'str', required: false, label:'Random Thank you For Level 4',defaultValue: 'LEVEL 4! OMG! I really love this, Thank you!!!'}, {name:'LSThanksFColorLev5', type:'str', label:'ForeGround Color (Level 4)', defaultValue: '#7B68EE'}, {name:'LSThanksBColorLev5', type:'str', label:'BackGround Color (Level 4)', defaultValue: '#000000'}, {name:'LSThanks1Lev5', type:'str', required: false, label:'Random Thank you For Level 5',defaultValue: 'LEVEL 5!!!! Yeeeeeeeeeah!!!!!! , This is true love, thank you so much my love!!! '}, {name:'LSTipGoalBool', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "3. TIP GOAL -- " }, {name: 'action_on_finality', label: 'After last goal', type: 'choice', choice1: 'Default', choice2: 'Loop last goal', choice3: 'Start hidden show' }, {name: 'hidden_preshow_entry_fee', label: 'Tokens to enter hidden show before starting (if selected)', type: 'int', defaultValue: 1, required: true }, {name: 'hidden_show_entry_fee', label: 'Tokens to enter hidden show after starting (if selected)', type: 'int', defaultValue: 50, required: true }, {name: 'finality_message', label: 'Final Goal Met Subject', type: 'str', minLength: 1, maxLength: 255, defaultValue: 'Goal reached! Thanks to all tippers!' }, {name: 'progression_mode', label: 'Progression Mode', type: 'choice', choice1: 'Automatic', choice2: 'Manual', defaultValue: 'Automatic' }, {name: 'tipper_colour_scheme', label: 'Tipper Highlight Colour Scheme', type: 'choice', choice1: 'None', choice2: 'Pink', choice3: 'Forest', choice4: 'Sky', choice5: 'Purple', choice6: 'Sunshine', choice7: 'Legacy', choice8: 'Random', defaultValue: 'Legacy' }, {name: 'hide_token_haul', label: 'Hide your total token haul?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, ]; cb.settings_choices = cb.settings_choices.concat(goalSettings); var mod_allow_broadcaster_cmd = 'No'; /*----------------------------------*/ /*-- Auto Display Messages ---------*/ /*----------------------------------*/ var i=0; function chatAd() { cb.sendNotice(cb.settings.LSNotifierTitle,'',cb.settings.LSNotifierBColor,cb.settings.LSNotifierFColor,'bold'); cb.sendNotice('---------------------------------------------','',cb.settings.LSNotifierBColor,cb.settings.LSNotifierFColor,'bold'); cb.sendNotice(cb.settings.LSNotifierLev1,'',cb.settings.LSNotifierBColor,cb.settings.LSNotifierFColor,'bold'); cb.sendNotice(cb.settings.LSNotifierLev2,'',cb.settings.LSNotifierBColor,cb.settings.LSNotifierFColor,'bold'); cb.sendNotice(cb.settings.LSNotifierLev3,'',cb.settings.LSNotifierBColor,cb.settings.LSNotifierFColor,'bold'); cb.sendNotice(cb.settings.LSNotifierLev4,'',cb.settings.LSNotifierBColor,cb.settings.LSNotifierFColor,'bold'); cb.sendNotice(cb.settings.LSNotifierLev5,'',cb.settings.LSNotifierBColor,cb.settings.LSNotifierFColor,'bold'); cb.setTimeout(chatAd, (cb.settings.LSNotifierInterval * 60000)); } if (cb.settings.LSNotifierBool == 'Yes') { cb.setTimeout(chatAd, (cb.settings.LSNotifierInterval * 3000)); } /*----------------------------------*/ /*-- Auto Thank You ----------------*/ /*----------------------------------*/ function TipThanksChatAd(TipUser, TipAmount) { if (cb.settings['LSThanksBool'] == 'Yes') { if (TipAmount > 14 && TipAmount < 100) { MsgNum = Math.floor(1+Math.random() * 4); msg = cb.settings['LSThanks' + MsgNum + 'Lev2']; cb.sendNotice(msg,'',cb.settings['LSThanksbColorLev2'],cb.settings['LSThanksFColorLev2'],'bold'); } if (TipAmount > 99 && TipAmount < 500) { MsgNum = Math.floor(1+Math.random() * 3); msg = cb.settings['LSThanks' + MsgNum + 'Lev3']; cb.sendNotice(msg,'',cb.settings['LSThanksbColorLev2'],cb.settings['LSThanksFColorLev2'],'bold'); } if (TipAmount > 499 && TipAmount < 1000) { MsgNum = Math.floor(1+Math.random() * 2); msg = cb.settings['LSThanks' + MsgNum + 'Lev4']; cb.sendNotice(msg,'',cb.settings['LSThanksbColorLev2'],cb.settings['LSThanksFColorLev2'],'bold'); } if (TipAmount > 999 ) { MsgNum = Math.floor(1+Math.random() * 1); msg = cb.settings['LSThanks' + MsgNum + 'Lev5']; cb.sendNotice(msg,'',cb.settings['LSThanksbColorLev2'],cb.settings['LSThanksFColorLev2'],'bold'); } } } /*----------------------------------*/ /*-- Multigoal ---------------------*/ /*----------------------------------*/ // colours var Colours = { AliceBlue: "#F0F8FF", AntiqueWhite: "#FAEBD7", Aqua: "#00FFFF", Aquamarine: "#7FFFD4", Azure: "#F0FFFF", Beige: "#F5F5DC", Bisque: "#FFE4C4", Black: "#000000", BlanchedAlmond: "#FFEBCD", Blue: "#0000FF", BlueViolet: "#8A2BE2", Brown: "#A52A2A", BurlyWood: "#DEB887", CadetBlue: "#5F9EA0", Chartreuse: "#7FFF00", Chocolate: "#D2691E", Coral: "#FF7F50", CornflowerBlue: "#6495ED", Cornsilk: "#FFF8DC", Crimson: "#DC143C", Cyan: "#00FFFF", DarkBlue: "#00008B", DarkCyan: "#008B8B", DarkGoldenRod: "#B8860B", DarkGrey: "#A9A9A9", DarkGreen: "#006400", DarkKhaki: "#BDB76B", DarkMagenta: "#8B008B", DarkOliveGreen: "#556B2F", DarkOrange: "#FF8C00", DarkOrchid: "#9932CC", DarkRed: "#8B0000", DarkSalmon: "#E9967A", DarkSeaGreen: "#8FBC8F", DarkSlateBlue: "#483D8B", DarkSlateGrey: "#2F4F4F", DarkTurquoise: "#00CED1", DarkViolet: "#9400D3", DeepPink: "#FF1493", DeepSkyBlue: "#00BFFF", DimGrey: "#696969", DodgerBlue: "#1E90FF", FireBrick: "#B22222", FloralWhite: "#FFFAF0", ForestGreen: "#228B22", Fuschia: "#FF00FF", Gainsboro: "#DCDCDC", GhostWhite: "#F8F8FF", Gold: "#FFD700", GoldenRod: "#DAA520", Grey: "#808080", Green: "#008000", GreenYellow: "#ADFF2F", HoneyDew: "#F0FFF0", HotPink: "#FF69B4", IndianRed: "#CD5C5C", Indigo: "#4B0082", Ivory: "#FFFFF0", Khaki: "#F0E68C", Lavender: "#E6E6FA", LavenderBlush: "#FFF0F5", LawnGreen: "#7CFC00", LemonChiffon: "#FFFACD", LightBlue: "#ADD8E6", LightCoral: "#F08080", LightCyan: "#E0FFFF", LightGoldenRodYellow: "#FAFAD2", LightGrey: "#D3D3D3", LightGreen: "#90EE90", LightPink: "#FFB6C1", LightSalmon: "#FFA07A", LightSeaGreen: "#20B2AA", LightSkyBlue: "#87CEFA", LightSlateGrey: "#778899", LightSteelBlue: "#B0C4DE", LightYellow: "#FFFFE0", Lime: "#00FF00", LimeGreen: "#32CD32", Linen: "#FAF0E6", Magenta: "#FF00FF", Maroon: "#800000", MediumAquaMarine: "#66CDAA", MediumBlue: "#0000CD", MediumOrchid: "#BA55D3", MediumPurple: "#9370DB", MediumSeaGreen: "#3CB371", MediumSlateBlue: "#7B68EE", MediumSpringGreen: "#00FA9A", MediumTurquoise: "#48D1CC", MediumVioletRed: "#C71585", MidnightBlue: "#191970", MintCream: "#F5FFFA", MistyRose: "#FFE4E1", Moccasin: "#FFE4B5", NavajoWhite: "#FFDEAD", Navy: "#000080", OldLace: "#FDF5E6", Olive: "#808000", OliveDrab: "#6B8E23", Orange: "#FFA500", OrangeRed: "#FF4500", Orchid: "#DA70D6", PaleGoldenRod: "#EEE8AA", PaleGreen: "#98FB98", PaleTurquoise: "#AFEEEE", PaleVioletRed: "#DB7093", PapayaWhip: "#FFEFD5", PeachPuff: "#FFDAB9", Peru: "#CD853F", Pink: "#FFC0CB", Plum: "#DDA0DD", PowderBlue: "#B0E0E6", Purple: "#800080", Red: "#FF0000", RosyBrown: "#BC8F8F", RoyalBlue: "#4169E1", SaddleBrown: "#8B4513", Salmon: "#FA8072", SandyBrown: "#F4A460", SeaGreen: "#2E8B57", SeaShell: "#FFF5EE", Sienna: "#A0522D", Silver: "#C0C0C0", SkyBlue: "#87CEEB", SlateBlue: "#6A5ACD", SlateGrey: "#708090", Snow: "#FFFAFA", SpringGreen: "#00FF7F", SteelBlue: "#4682B4", Tan: "#D2B48C", Teal: "#008080", Thistle: "#D8BFD8", Tomato: "#FF6347", Turquoise: "#40E0D0", Violet: "#EE82EE", Wheat: "#F5DEB3", White: "#FFFFFF", WhiteSmoke: "#F5F5F5", Yellow: "#FFFF00", YellowGreen: "#9ACD32" }; var tipper_colours = { legacy: { high_tipper_colour: '#9F9', high_total_colour: '#CCF' }, pink: { high_tipper_colour: Colours.Pink, high_total_colour: Colours.Violet }, forest: { high_tipper_colour: Colours.SpringGreen, high_total_colour: Colours.LimeGreen }, sky: { high_tipper_colour: Colours.PowderBlue, high_total_colour: Colours.SkyBlue }, purple: { high_tipper_colour: Colours.Orchid, high_total_colour: Colours.MediumSlateBlue }, sunshine: { high_tipper_colour: Colours.Yellow, high_total_colour: Colours.Gold }, }; var Groups = { TokenHolders: 'cyan', Tippers: 'blue', Fans: 'green', Moderators: 'red', }; var Tipping = { CurrentGoal: { Number: 0, TargetAmount: 0, CurrentAmount: 0, Halted: false, }, Leaderboard: { Leaders: { Highest: { Username: null, Amount: 0, OptOut: false, }, HighestTotal: { Username: null, Amount: 0, OptOut: false, }, Lowest: { Username: null, Amount: 0, OptOut: false, }, MostRecent: { Username: null, Amount: 0, OptOut: false, } }, All: [], }, VirtualTotal: 0, ActualTotal: 0, Finality: false, }; var settingsHelper = { parseBoolean: function (str) { return (str == "Yes"); } }; // vars var subject_is_final = false; var final_goal_met = false; var settings = { progression_mode_manual: false, goals: [], action_on_finality: 'default', hidden_show_entry_fee: 0, finality_message: 'Goal reached! Thanks to all tippers!', highlight_theme: 'legacy', allow_mod_superuser_cmd: false, hide_token_haul: false, support_mode: false, goals_defined: 0, toString: function () { var settingsStr = ""; for (var prop in this) { if (typeof (this[prop]) == "string" || typeof (this[prop]) == "boolean" || typeof (this[prop]) == "number") { settingsStr += ", " + prop + ": '" + this[prop] + "'"; } } cb.log(settingsStr.substring(2)); return settingsStr.substring(2); } }; var caches = { panel: {} }; var Messenger = { sendModeratorNotice: function (str) { this.sendGenericMessage(str, Colours.Blue, null, cb.room_slug, Groups.Moderators); }, sendErrorMessage: function (str, recipient, group) { this.sendGenericMessage(str, Colours.Red, null, recipient, group); }, sendWarningMessage: function (str, recipient, group) { this.sendGenericMessage(str, Colours.Orange, null, recipient, group); }, sendSuccessMessage: function (str, recipient, group) { this.sendGenericMessage(str, Colours.DarkGreen, null, recipient, group); }, sendInfoMessage: function (str, recipient, group) { this.sendGenericMessage(str, Colours.Black, null, recipient, group); }, sendGenericMessage: function (str, colour, background, recipient, group) { if (recipient != null && group != null) { cb.sendNotice(str, null, background, colour, 'bold', group); cb.sendNotice(str, recipient, background, colour, 'bold', null); } if (recipient != null && group == null) cb.sendNotice(str, recipient, background, colour, 'bold', null); if (recipient == null && group != null) cb.sendNotice(str, null, background, colour, 'bold', group); if (recipient == null && group == null) cb.sendNotice(str, null, background, colour, 'bold', null); }, }; function internalGetTipperTheme() { if (settings.highlight_theme === 'random') { var themeBail = Math.floor(Math.random() * 6); var themeIndex = 1; for (var themeName in tipper_colours) { if (themeIndex == themeBail && tipper_colours[themeName] !== undefined) { return tipper_colours[themeName]; } themeIndex++; } return tipper_colours.legacy; } else { return tipper_colours[settings.highlight_theme]; } } function getTipperTheme() { var theme = internalGetTipperTheme(); return (theme === undefined || theme == null) ? tipper_colours.legacy : theme; } var hiddenShow = { enabled: false, message: '', price: 0, preshowPrice: 0, setPrice: function (price) { this.price = parseInt(price); }, setPreshowPrice: function (price) { this.preshowPrice = price; }, setMessage: function (message) { this.message = message; }, setEnabled: function (enabled) { this.enabled = enabled; }, getPrice: function () { return this.price; }, getPreshowPrice: function () { return this.preshowPrice; }, getMessage: function () { return this.message; }, getEnabled: function () { return this.enabled; }, _getTokenizedMessage: function () { return "{0}\n\n{1}".format(this.message, "Tip {0} tokens to see the show".format(this.price)); }, getIsRunning: function () { return cb.limitCam_isRunning(); }, reset: function () { if (!this.enabled) return; cb.limitCam_removeAllUsers(); if (!cb.limitCam_isRunning()) return; this.stop(); }, start: function () { if (!this.enabled) return; if (cb.limitCam_isRunning()) return; cb.limitCam_start(this._getTokenizedMessage()); }, stop: function () { if (!this.enabled) return; if (!cb.limitCam_isRunning()) return; cb.limitCam_stop(); }, addUserWithTip: function (user, tokens) { if (!this.enabled) return false; if (cb.limitCam_userHasAccess(user)) return false; if (cb.limitCam_isRunning() && tokens < this.price) return false; if (!cb.limitCam_isRunning() && tokens < this.preshowPrice) return false; this.addUser(user); return true; }, addUser: function (user) { if (cb.limitCam_userHasAccess(user)) return; cb.limitCam_addUsers([user]); }, removeUser: function (user) { if (!cb.limitCam_userHasAccess(user)) return; cb.limitCam_removeUsers([user]); }, checkUser: function (user) { return cb.limitCam_userHasAccess(user); }, getAllUsers: function () { return cb.limitCam_allUsersWithAccess(); }, }; function getCurrentGoalDescription() { return settings.goals[Tipping.CurrentGoal.Number].description; } function getPreviousGoalAmount() { return settings.goals[Tipping.CurrentGoal.Number - 1].tokens; } function getCurrentGoalAmount() { try { return settings.goals[Tipping.CurrentGoal.Number].tokens; } catch (e) { Messenger.sendErrorMessage(e.toString() + ". You have encountered an error in Tip Multi-Goal that should not happen. Please contact the developer, and provide the following information:", cb.room_slug); Messenger.sendErrorMessage(settings.toString(), cb.room_slug); Messenger.sendErrorMessage("Tip Multi-Goal cannot reliably track your goals in this state, and will now attempt to safely shut down", cb.room_slug); unload(); return 1; } } function getSumTotalGoal() { var totalGoal = 0; for (var i = 0; i < settings.goals.length; i++) { totalGoal += settings.goals[i].tokens; } return totalGoal; } function getAllGoals() { var allGoals = ""; for (var i = 0; i < settings.goals.length; i++) { allGoals += settings.goals[i].description + ' (' + settings.goals[i].tokens + ' tokens)\n'; } allGoals += "-- Tokens if all goals met: " + getSumTotalGoal(); return allGoals; } function getLeaderBoard() { var leaderboard = ""; for (var idx = 0; idx < Tipping.Leaderboard.All.length && idx < 10; idx++) { if (Tipping.Leaderboard.All[idx] !== undefined) { leaderboard += Tipping.Leaderboard.All[idx].name + ' (' + Tipping.Leaderboard.All[idx].tokens + ')\n'; } } return leaderboard; } function getTotalDollars() { return (0.05 * Tipping.VirtualTotal).toFixed(2); } function skipGoal() { Tipping.CurrentGoal.CurrentAmount = 0; nextGoal(); checkFinality(); recachePanel(); } function nextGoal() { Tipping.CurrentGoal.Number++; if (settings.goals[Tipping.CurrentGoal.Number] != undefined && settings.goals[Tipping.CurrentGoal.Number].hide) { hiddenShow.start(); } } function continueProgression() { if (!settings.progression_mode_manual || !Tipping.CurrentGoal.Halted) return; Tipping.CurrentGoal.Halted = false; skipGoal(); } function getNextGoalAnnouncement() { if (settings.goals[Tipping.CurrentGoal.Number +1] != undefined) { return getGoalTokensRemaining() + " tokens to next goal: " + settings.goals[Tipping.CurrentGoal.Number + 1].description; } else { return "It's the final goal! Keep tipping!"; } } function checkFinality() { if (Tipping.CurrentGoal.Number >= settings.goals.length) { if (settings.action_on_finality == 'loop') { Tipping.CurrentGoal.Number--; final_goal_met = false; } else if (settings.action_on_finality == 'default') { final_goal_met = true; } else if (settings.action_on_finality == 'hidden') { final_goal_met = true; hiddenShow.start(); } } else { final_goal_met = false; } } function getGoalTokensRemaining() { var r = getCurrentGoalAmount() - Tipping.CurrentGoal.CurrentAmount; return (r < 0) ? 0 : r; } function formatUsername(val) { return (val === null || val === undefined) ? "--" : val.substring(0, 12); } function recordTip(username, tokens, countsToActual) { var tipperFound = false; var actualTokens = tokens; Tipping.VirtualTotal += tokens; if (countsToActual) { Tipping.ActualTotal += actualTokens; Tipping.Leaderboard.Leaders.MostRecent.Amount = tokens; Tipping.Leaderboard.Leaders.MostRecent.Username = username; if (tokens > Tipping.Leaderboard.Leaders.Highest.Amount) { if (Tipping.Leaderboard.Leaders.Highest.Username !== username && settings.highlight_theme != 'none') { Messenger.sendInfoMessage("You are now the highest tipper. If you do not want your name highlighted in chat, simply type the command '/donotwant' (without quotes) now", username); Tipping.Leaderboard.Leaders.Highest.OptOut = false; } Tipping.Leaderboard.Leaders.Highest.Amount = tokens; Tipping.Leaderboard.Leaders.Highest.Username = username; } if (tokens <= Tipping.Leaderboard.Leaders.Lowest.Amount || Tipping.Leaderboard.Leaders.Lowest.Amount == 0) { Tipping.Leaderboard.Leaders.Lowest.Amount = tokens; Tipping.Leaderboard.Leaders.Lowest.Username = username; } var totalTokens = tokens; for (var idx = 0; idx < Tipping.Leaderboard.All.length; idx++) { if (Tipping.Leaderboard.All[idx].name == username) { Tipping.Leaderboard.All[idx].tokens += tokens; totalTokens = Tipping.Leaderboard.All[idx].tokens; tipperFound = true; break; } } if (!tipperFound) { Tipping.Leaderboard.All.push({ name: username, tokens: tokens }); } Tipping.Leaderboard.All.sort(function (a, b) { return b.tokens - a.tokens; }); if (Tipping.Leaderboard.Leaders.HighestTotal.Username !== Tipping.Leaderboard.All[0].name && settings.highlight_theme != 'none') { Messenger.sendInfoMessage("You are now the highest total tipper. If you do not want your name highlighted in chat, simply type the command '/donotwant' (without quotes) now", Tipping.Leaderboard.All[0].name); Tipping.Leaderboard.Leaders.HighestTotal.OptOut = false; } Tipping.Leaderboard.Leaders.HighestTotal.Username = Tipping.Leaderboard.All[0].name; Tipping.Leaderboard.Leaders.HighestTotal.Amount = Tipping.Leaderboard.All[0].tokens; if (hiddenShow.addUserWithTip(username, totalTokens) && hiddenShow.getEnabled()) { Messenger.sendSuccessMessage("Thanks, {0}! Your tip gets you into the hidden show!".format(username), username); tokens -= (hiddenShow.getIsRunning() ? hiddenShow.getPrice() : 0); if (Tipping.CurrentGoal.CurrentAmount + tokens < 0) tokens = Tipping.CurrentGoal.CurrentAmount * -1; } } Tipping.CurrentGoal.CurrentAmount += tokens; if (!final_goal_met) { while (Tipping.CurrentGoal.CurrentAmount >= getCurrentGoalAmount()) { if (!settings.progression_mode_manual || Tipping.CurrentGoal.Number == (settings.goals.length - 1)) { Tipping.CurrentGoal.CurrentAmount = Tipping.CurrentGoal.CurrentAmount - getCurrentGoalAmount(); Messenger.sendSuccessMessage("* Goal met: " + getCurrentGoalDescription(), cb.room_slug); Messenger.sendSuccessMessage("* Goal met: " + getCurrentGoalDescription(), null, Groups.Moderators); nextGoal(); checkFinality(); } else { if (Tipping.CurrentGoal.Halted) { } else { Messenger.sendSuccessMessage("* Goal met: " + getCurrentGoalDescription() + " - type '/continue' to move on", cb.room_slug); Messenger.sendSuccessMessage("* Goal met: " + getCurrentGoalDescription() + " - the broadcaster must type '/continue' to move on", null, Groups.Moderators); } Tipping.CurrentGoal.Halted = true; Tipping.CurrentGoal.CurrentAmount = getCurrentGoalAmount(); break; } if (final_goal_met) break; } } while (Tipping.CurrentGoal.CurrentAmount < 0) { Tipping.CurrentGoal.CurrentAmount = Tipping.CurrentGoal.CurrentAmount + getPreviousGoalAmount(); Messenger.sendSuccessMessage("* Goal unmet: " + getCurrentGoalDescription(), cb.room_slug); Messenger.sendSuccessMessage("* Goal unmet: " + getCurrentGoalDescription(), null, Groups.Moderators); Tipping.CurrentGoal.Number--; checkFinality(); } checkFinality(); recachePanel(); } function unload() { cb.onTip(function (tip) { }); cb.onDrawPanel(function () { }); cb.onMessage(function (message) { }); cb.onEnter(function (user) { }); cb.onLeave(function (user) { }); } function reset() { Tipping.Leaderboard.Leaders.Lowest.Amount = 0; Tipping.Leaderboard.Leaders.Highest.Amount = 0; Tipping.Leaderboard.Leaders.MostRecent.Amount = 0; Tipping.Leaderboard.Leaders.HighestTotal.Amount = 0; Tipping.Leaderboard.Leaders.Lowest.Username = null; Tipping.Leaderboard.Leaders.Highest.Username = null; Tipping.Leaderboard.Leaders.MostRecent.Username = null; Tipping.Leaderboard.Leaders.HighestTotal.Username = null; Tipping.CurrentGoal.Number = 0; Tipping.VirtualTotal = 0; Tipping.CurrentGoal.CurrentAmount = 0; final_goal_met = false; Tipping.Leaderboard.All = []; hiddenShow.reset(); recachePanel(); } cb.onTip(function (tip) { TipUser = tip['from_user']; TipAmount=parseInt(tip['amount']); TipThanksChatAd(TipUser, TipAmount); if (cb.settings['LSTipGoalBool'] == 'Yes') { recordTip(tip.from_user, tip.amount, true); } }); cb.onEnter(function (user) { if (user.in_fanclub || user.is_mod) { hiddenShow.addUser(user.user); } }); cb.onLeave(function (user) { if (user.in_fanclub || user.is_mod) { hiddenShow.removeUser(user.user); } }); function recachePanel() { if (final_goal_met) { caches.panel = { template: '3_rows_of_labels', row1_label: 'Tokens Received:', row1_value: Tipping.VirtualTotal, row2_label: 'Highest Tip:', row2_value: formatUsername(Tipping.Leaderboard.Leaders.Highest.Username) + ' (' + Tipping.Leaderboard.Leaders.Highest.Amount + ')', row3_label: 'Latest Tip Received:', row3_value: formatUsername(Tipping.Leaderboard.Leaders.MostRecent.Username) + ' (' + Tipping.Leaderboard.Leaders.MostRecent.Amount + ')' }; if (settings.hide_token_haul) { caches.panel.row1_label = ''; caches.panel.row1_value = ''; } } else { caches.panel = { template: '3_rows_of_labels', row1_label: 'Goal' + ' (' + getCurrentGoalDescription() + ') : ', row1_value: Tipping.CurrentGoal.CurrentAmount + ' / ' + getCurrentGoalAmount(), row2_label: 'Highest Tip:', row2_value: formatUsername(Tipping.Leaderboard.Leaders.Highest.Username) + ' (' + Tipping.Leaderboard.Leaders.Highest.Amount + ')', row3_label: 'Latest Tip Received:', row3_value: formatUsername(Tipping.Leaderboard.Leaders.MostRecent.Username) + ' (' + Tipping.Leaderboard.Leaders.MostRecent.Amount + ')' }; } cb.drawPanel(); } cb.onDrawPanel(function () { return caches.panel; }); function buildStatsOutput(includeExtraInfo) { var output = ""; output += "Sum total goal: " + getSumTotalGoal() + "\n"; output += "Total tipped so far: " + Tipping.VirtualTotal + "\n"; output += "Total goal remaining: " + (getSumTotalGoal() - Tipping.VirtualTotal) + "\n"; if (includeExtraInfo) { output += "Total actual tipped (disregarding resets): " + Tipping.ActualTotal + "\n"; output += "Total dollars (assuming $0.05/token): $" + getTotalDollars() + "\n"; } output += "Disclaimer: per minute figures EXCLUDE private shows, group shows, and other non-tip token gains\n"; output += "=== Tip Stats ===\n"; output += "Highest total tips: " + Tipping.Leaderboard.Leaders.HighestTotal.Amount + " from " + Tipping.Leaderboard.Leaders.HighestTotal.Username + "\n"; output += "Awesomest tip: " + Tipping.Leaderboard.Leaders.Highest.Amount + " from " + Tipping.Leaderboard.Leaders.Highest.Username + "\n"; output += "Stingiest tip: " + Tipping.Leaderboard.Leaders.Lowest.Amount + " from " + Tipping.Leaderboard.Leaders.Lowest.Username + "\n"; output += "Most recent tip: " + Tipping.Leaderboard.Leaders.MostRecent.Amount + " from " + Tipping.Leaderboard.Leaders.MostRecent.Username + "\n"; output += "=== Leaderboard (Top 10) ===\n\n"; output += getLeaderBoard(); return output; } function buildTicketList() { var output = ""; var tickets = hiddenShow.getAllUsers(); if (tickets.length == 0) return ""; for (var idx = 0; idx < tickets.length; idx++) { output += tickets[idx]; if ((idx % 10) == 0 && idx != 0) output += "\n"; else if (idx != tickets.length - 1) output += ", "; } return output; } String.prototype.format = function () { var newString = String(this); for (var idx = 0; idx < arguments.length; idx++) { newString = newString.replace('{' + idx + '}', arguments[idx]); } return String(newString); }; cb.onMessage(function (msg) { var i = 0; var key = null; /* Tip king highlighting */ if (settings.highlight_theme != 'null' && msg.user === Tipping.Leaderboard.Leaders.HighestTotal.Username && !Tipping.Leaderboard.Leaders.HighestTotal.OptOut) { msg.background = getTipperTheme().high_total_colour; } else if (settings.highlight_theme != 'null' && msg.user === Tipping.Leaderboard.Leaders.Highest.Username && !Tipping.Leaderboard.Leaders.Highest.OptOut) { msg.background = getTipperTheme().high_tipper_colour; } /* If it starts with a /, suppress that shit and assume it's a command */ if (msg.m.substring(0, 1) === "/") { msg["X-Spam"] = true; if (msg.user === cb.room_slug || msg.is_mod) { /* Broadcaster or mod commands */ if (msg.m.substring(1) === "stats") { Messenger.sendInfoMessage("=== Goal Statistics ===", msg.user); Messenger.sendInfoMessage(buildStatsOutput(isSuperuser(msg.user, msg.is_mod)), msg.user); } else if (msg.m.substring(1) === "goals") { Messenger.sendInfoMessage("=== All Goals ===", msg.user); Messenger.sendInfoMessage(getAllGoals(), msg.user); } else if (msg.m.substring(1, 8) === "tickets") { Messenger.sendInfoMessage("=== Hidden Show Admit List ===", msg.user); Messenger.sendInfoMessage(buildTicketList(), msg.user); } } var tokenCount = 0; if (isSuperuser(msg.user, msg.is_mod)) { /* Broadcaster only commands, unless the option to allow mods to use them is enabled */ if (msg.m.substring(1, 10) === "addtokens") { tokenCount = parseInt(msg.m.substring(11)); if (tokenCount > 0) { Messenger.sendModeratorNotice("{0} has added {1} tokens to the goal".format(msg.user, tokenCount)); Messenger.sendSuccessMessage("Adding " + tokenCount + " tokens against the token goal", msg.user); recordTip(msg.user, tokenCount, false); } else { Messenger.sendSuccessMessage("Error! You must add at least 1 token", msg.user); } } else if (msg.m.substring(1) === "reset") { Messenger.sendModeratorNotice("{0} has reset the goals".format(msg.user)); reset(); } else if (msg.m.substring(1) === "skip") { Messenger.sendModeratorNotice("{0} has skipped the current goal".format(msg.user)); skipGoal(); } else if (msg.m.substring(1) === "upnext") { Messenger.sendModeratorNotice("{0} has requested the next goal".format(msg.user)); msg.m = getNextGoalAnnouncement(); msg["X-Spam"] = false; } else if (msg.m.substring(1) === "continue") { Messenger.sendModeratorNotice("{0} has continued manual goal progression".format(msg.user)); continueProgression(); } else if (msg.m.substring(1, 10) === "setcolors") { if (msg.m.length >= 11) { var selectedTheme = msg.m.substring(11).toLowerCase(); if ((tipper_colours[selectedTheme] !== undefined && tipper_colours[selectedTheme] !== null) || selectedTheme === "random" || selectedTheme === "none") { Messenger.sendModeratorNotice("{0} has set the colour theme to '{1}'".format(msg.user, selectedTheme)); Messenger.sendSuccessMessage("Colour scheme set to " + msg.m.substring(11).toLowerCase(), msg.user); settings.highlight_theme = selectedTheme; } else { Messenger.sendErrorMessage("The colour scheme you selected does not exist. Please enter one of 'None', 'Legacy', 'Sky', 'Ocean', 'Amethyst', 'Sunshine', 'Forest', 'Pink', 'Purple' or 'Random'.", msg.user); } } else { Messenger.sendErrorMessage("You need to specify the colour scheme to use. Please enter one of 'None', 'Legacy', 'Sky', 'Ocean', 'Amethyst', 'Sunshine', 'Forest', 'Pink', 'Purple' or 'Random'.", msg.user); } } else if (msg.m.substring(1, 4) === "add" && msg.m.substring(1, 5) !== "addt") { if (msg.m.length >= 7) { var tokens = parseInt(msg.m.substring(5, msg.m.indexOf(' ', 5))); if (tokens > 0) { var description = msg.m.substring(msg.m.indexOf(' ', 5) + 1); if (addGoal(tokens, description) != undefined) { Messenger.sendModeratorNotice("{0} has added a new goal '{1}' for {2} tokens!".format(msg.user, description, tokens)); } } else { Messenger.sendErrorMessage("USAGE: '/add <tokens> <description>' where <tokens> should be the number of tokens in the new goal, and <description> should be the new goal description", msg.user); } } else { Messenger.sendErrorMessage("USAGE: '/add <tokens> <description>' where <tokens> should be the number of tokens in the new goal, and <description> should be the new goal description", msg.user); } } else if (msg.m.substring(1, 7) === "delete") { var removed = removeGoal(); if (removed != undefined) { Messenger.sendModeratorNotice("{0} has removed '{1}' from the goal list".format(msg.user, removed.description)); } } else if (msg.m.substring(1, 7) === "hidden") { if (msg.m.length >= 10) { var cmd = msg.m.substring(8).toLowerCase(); if (cmd == "on" || cmd == "off") { if (cmd == "on") { Messenger.sendModeratorNotice("Hidden show was started by {0}".format(msg.user)); hiddenShow.setEnabled(true); hiddenShow.start(); } else if (cmd == "off") { Messenger.sendModeratorNotice("Hidden show was stopped by {0}".format(msg.user)); hiddenShow.stop(); } } else { Messenger.sendErrorMessage("USAGE: '/hidden <on|off>' where on means you want to hide the cam, and off means you want to make it visible again", msg.user); } } else { Messenger.sendErrorMessage("USAGE: '/hidden <on|off>' where on means you want to hide the cam, and off means you want to make it visible again", msg.user); } } else if (msg.m.substring(1, 6) === "admit") { if (msg.m.length >= 8) { var admission = msg.m.substring(7); Messenger.sendModeratorNotice("{0} was added to the hidden show by {1}".format(admission, msg.user)); hiddenShow.addUser(admission); } else { Messenger.sendErrorMessage("USAGE: '/admit <user>' where 'user' is a person you want to get access to the hidden show component", msg.user); } } else if (msg.m.substring(1, 8) === "unadmit") { if (msg.m.length >= 10) { var unadmission = msg.m.substring(9); Messenger.sendModeratorNotice("{0} was removed from the hidden show by {1}".format(unadmission, msg.user)); hiddenShow.removeUser(unadmission); } else { Messenger.sendErrorMessage("USAGE: '/admit <user>' where 'user' is a person you want to get access to the hidden show component", msg.user); } } else if (msg.m.substring(1, 8) === "hidemsg") { if (msg.m.length >= 10) { var hideMessage = msg.m.substring(9); Messenger.sendModeratorNotice("{0} set the hidden show message to '{1}'".format(msg.user, hideMessage)); hiddenShow.setMessage(hideMessage); } else { Messenger.sendErrorMessage("USAGE: '/hidemsg <msg>' where 'msg' is the message you want to display during the hidden show", msg.user); } } } if (msg.user === cb.room_slug) { /* Broadcaster only commands at all times */ if (msg.m.substring(1, 13) === "removetokens") { tokenCount = parseInt(msg.m.substring(14)); if (tokenCount > 0) { if (Tipping.VirtualTotal - tokenCount >= 0) { Messenger.sendModeratorNotice("{0} has removed {1} tokens from the goal".format(msg.user, tokenCount)); Messenger.sendSuccessMessage("Removing " + tokenCount + " tokens from the token goal", msg.user); recordTip(msg.user, (tokenCount * -1), false); } else { Messenger.sendErrorMessage("Error! Tokens removed would result in negative total tipped", msg.user); } } else { Messenger.sendErrorMessage("Error! You must remove at least 1 token", msg.user); } } else if (msg.m.substring(1) == "support") { settings.support_mode = !settings.support_mode; Messenger.sendSuccessMessage("Support mode is now " + (settings.support_mode ? "ACTIVATED" : "DEACTIVATED") + "!", cb.room_slug); } } /* Code to allow the highest tipper and total highest tipper to opt out of highlighting */ if (msg.m.substring(1) === "donotwant") { Messenger.sendInfoMessage("Your messages will no longer be highlighted. Type '/dowant' without quotes to get it back again - if you're still on top!", msg.user); if (msg.user === Tipping.Leaderboard.Leaders.Highest.Username) { Tipping.Leaderboard.Leaders.Highest.OptOut = true; } if (msg.user === Tipping.Leaderboard.Leaders.HighestTotal.Username) { Tipping.Leaderboard.Leaders.HighestTotal.OptOut = true; } } /* Code to allow the highest tipper and total highest tipper to opt back into highlighting */ if (msg.m.substring(1) === "dowant") { Messenger.sendInfoMessage("Your messages will now be highlighted. Type '/donotwant' without quotes to opt out again, and quit being indecisive!", msg.user); if (msg.user === Tipping.Leaderboard.Leaders.Highest.Username) { Tipping.Leaderboard.Leaders.Highest.OptOut = false; } if (msg.user === Tipping.Leaderboard.Leaders.HighestTotal.Username) { Tipping.Leaderboard.Leaders.HighestTotal.OptOut = false; } } } return msg; }); function isSuperuser(username, isMod) { return (username == cb.room_slug || isMod && settings.allow_mod_superuser_cmd); } function addGoal(tokens, description) { var newGoal = { index: settings.goals.length + 1, description: description, tokens: parseInt(tokens), hide: false, }; if (newGoal.description.substring(0, 2) == "**") { newGoal.description = newGoal.description.substring(2); newGoal.hide = true; } settings.goals.push(newGoal); return newGoal; } function removeGoal() { return settings.goals.splice(-1, 1); } function isUndefined(test) { return (test == undefined || test == "" || test == 0); } function parseOptions() { settings.finality_message = cb.settings.finality_message; settings.allow_mod_superuser_cmd = settingsHelper.parseBoolean(cb.settings.mod_allow_broadcaster_cmd); settings.hide_token_haul = settingsHelper.parseBoolean(cb.settings.hide_token_haul); settings.highlight_theme = cb.settings.tipper_colour_scheme.toLowerCase(); settings.progression_mode_manual = (cb.settings.progression_mode == 'Manual'); settings.hidden_show_entry_fee = cb.settings.hidden_show_entry_fee; settings.hidden_preshow_entry_fee = cb.settings.hidden_preshow_entry_fee; var actionOnFinality = cb.settings.action_on_finality[0].toLowerCase(); switch (actionOnFinality) { case 'l': settings.action_on_finality = 'loop'; break; case 's': settings.action_on_finality = 'hidden'; break; default: settings.action_on_finality = 'default'; break; } hiddenShow.setPrice(settings.hidden_show_entry_fee); hiddenShow.setEnabled(settings.action_on_finality == 'hidden'); hiddenShow.setMessage(settings.finality_message); hiddenShow.setPreshowPrice(settings.hidden_preshow_entry_fee); for (var gIdx = 1; gIdx <= NumTipGoals; gIdx++) { if (!isUndefined(cb.settings['goal_' + gIdx + '_description']) && !isUndefined(cb.settings['goal_' + gIdx + '_tokens'])) { var description = cb.settings['goal_' + gIdx + '_description']; var hide = false; if (description.substring(0, 2) == "**") { description = description.substring(2); hide = true; } var repeatTest = /^(\d+)\/(.*)/i; var goalRepeat = repeatTest.exec(description); if (goalRepeat != null) { description = goalRepeat[2]; for (var repeat = 0; repeat < goalRepeat[1]; repeat++) { settings.goals.push({ index: settings.goals.length + 1, description: description, tokens: parseInt(cb.settings['goal_' + gIdx + '_tokens']), hide: hide, }); } } else { settings.goals.push({ index: settings.goals.length + 1, description: description, tokens: parseInt(cb.settings['goal_' + gIdx + '_tokens']), hide: hide, }); } } } } function init() { if (cb.settings['LSTipGoalBool'] == 'Yes') { parseOptions(); reset(); } } if (cb.settings.goal_1_tokens !== null && cb.settings.goal_1_tokens !== undefined) { init(); }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.