Apps Home
|
Create an App
multi app test
Author:
scipio1
Description
Source Code
Launch App
Current Users
Created by:
Scipio1
/********** App Data **********/ var app = { name : "'CrazyKeno'", /* Script name */ type : 'App', /* Script type: bot|app */ version : '1', /* Internal: Script version number */ build : '1', /* Internal: Script build number */ date : '10.21.2017', /* Internal: Script build date */ }; /***** App colors *****/ var COLOR = { DEVELOPER : '#D9F7F7', /* Very light blue: Highlight colour for developers */ BRED : '#FF1407', /* Bright red: Timer notice, misc. important messages */ MRED : '#D80A00', /* Medium red */ HIGHLIGHT : '#EEE5FF', /* Pastel purple: Highlight colour for ticket holders */ SUCCESS : '#468847', /* Green: Everything is fine */ ERROR : '#B94A48', /* Red: Everything fails */ INFO : '#144D8C', /* Blue-grey: Help and misc info */ NOTICE : '#6900CC', /* Bluish purple: General chat notice */ DPURPLE : '#663399', /* Dark purple */ LPURPLE : '#8041BF', /* Lighter purple */ BLUE : '#000099', /* Dark blue */ MOD : '#DC0000', /* Moderator red */ FAN : '#009900', /* Fan green */ SYNTAX : '#995B00', /* Brownish: Usage notice colour and messages to broadcaster on mod-action */ HVTEXT : '#D80A00', /* Reddish: Text colour for Hi-Vis notices */ HVBACK : '#FFFFBF', /* Light yellow: Backbround colour for Hi-Vis notices */ MAG : '#E509E5', /* Magenta */ BLI : '#DDFFCC', /* Pastel green - Birdy */ BF : '#FFE0EA' /* Pastel pink - Blaze */ }; /***** App commands *****/ var COMMAND = { // Viewer Commands: CMDS : 'cmds', /* List of these commands */ TICKETS : 'tickets', /* Lists users who paid for a ticket */ PASSWORD : 'pass', /* Sends pass or Notice to ticket holder */ TIMELEFT : 'timeleft', /* Check time remaining on goal timer */ SHOWTIME : 'showtime', /* Displays current hidden cam show length */ USETICKET : 'useticket', /* Allows Viewer to use an OTS ticket */ SAVETICKET : 'saveticket', /* Allows Viewer to save a ticket to OTS */ // Moderator Commands, IF broadcaster set include-mods to 'Yes': ADD : 'add', /* Add one or more Viewers to ticket list */ AU : 'au', /* Add user(s) alias */ DEL : 'del', /* Delete a user */ DU : 'du', /* Del user alias */ // Moderator Commands: OTS : 'ots', /* Manipulates the OTS */ SENDPW : 'sendpw', /* Send pass to all or to a user */ ADDP : 'addp', /* Add Viewer to array paidList */ ADDOTS : 'addots', /* Add Viewer(s) to otsTickets. */ DELP : 'delp', /* Delete Viewer from array paidList */ DELOTS : 'delots', /* Delete Viewer from array otsTickets */ HILITE : 'hilite', /* Text highlighting toggler */ HL : 'hl', /* Alias for HILITE command */ STARTSHOW : 'startshow', /* Start the limited feed show */ STOPSHOW : 'stopshow', /* Stops the limited feed show */ SHOWOVER : 'showover', /* Notifies entering Viewers the show is ending. */ SHOWEND : 'showend', /* Notifies Viewers the show has ended. */ NEWSHOW : 'newshow', /* Resets for a new show after show is over. */ ViewerS : 'Viewers', /* Toggles display of ticket holders in room ON/OFF */ SUBJECT : 'subject', /* Change room subject - plain */ CTSUBJECT : 'ctsubject', /* Change room subject - 'CT says:' */ LOCK : 'lock', /* Toggler to tell script we're in PWed room */ CHECK : 'check', /* Check if the Viewer has a ticket (supports multiple users) */ FAQ : 'faq', /* FAQ about the script, for the staff */ CTN : 'ctn', /* Sends a notice to the chat. */ CTB : 'ctb', /* Sends a notice to the broadcaster. */ CTM : 'ctm', /* Sends a notice to the mods as a group. */ CTT : 'ctt', /* Sends a notice to the ticket holders. */ CTV : 'ctv', /* Sends a notice to a Viewer. */ SCHAT : 'schat', /* Suppresses public chat during 'hidden cam'. */ SPASS : 'spass', /* Suppresses password send during ticket sales for a 'hidden cam' show. */ TIPSOFF : 'tipsoff', /* Suppresses tip total info. */ STARTTIMER : 'starttimer', /* Start an x minute timer */ ADDTIME : 'addtime', /* Add time in minutes to the timer. */ PLIST : 'plist', /* List only paid ticket holders list format */ PLISTW : 'plistw', /* List only paid ticket holders wide format */ VLIST : 'vlist', /* List only Viewers watching the show */ NRLIST : 'nrlist', /* List ticket holders who have left the room */ ALIST : 'alist', /* List only manually added Viewers. */ AALIST : 'aalist', /* List only auto-added Viewers. */ EMLIST : 'emlist', /* List recorded emails */ OTSLIST : 'otslist', /* List Viewers on the outstanding ticket list. */ USEDOTS : 'usedots', /* List used OTS tickets. */ NEW : 'new', /* Display 'What's New' text. */ EMAIL : 'email', /* Detect email in tip note */ SIL : 'sil', UNSIL : 'unsil', SLIST : 'slist', // Broadcaster Only Commands: CHANGEPW : 'changepw', /* Change the password */ CTPRICE : 'ctprice', /* Change the ticket price */ CTRESET : 'ctreset' /* Resets CT for a new show */ }; /***** common txt *****/ var TXT = { cmdPrefix : '/', dashLine : '------------------------------------------------------------', ONLY_ROOMHOST : "* Command is only available to the room host.", ONLY_MODS : "* Command is only available to moderators and the room host.", otsMsg : "You have an outstanding ticket that you can use for this show.\n* To use your ticket simply type /useticket in the chat and you will be added to the ticket holders list for this show.\n* If you change your mind BEFORE the show starts simply type /saveticket in the chat, and your ticket will become available for another time.\n", otsNE : "\n* The Outstanding Ticket System is not ENABLED.\n", infoStr : ' \u2007\u25CF /b = show board\n \u2007\u25CF /p = show prizes left' } /***** Flags *****/ var FLAG = { goal : false, debug : false, /* internal debug state: false (off by default) */ dev : false, /* internal dev hl state: false (off by default) */ hilite : true, /* on (true) by default for COLOR.HIGHLIGHT. */ bli : true, bf : true, lock : false, /* off (false) by default for passed room toggler. */ schat : false, /* Used by '/schat' command to suppress public chat. */ spass : false, /* Used by '/spass' command to suppress password send. */ toff : false, /* Used by '/tipsoff' to suppress the tip total info from being written to the info panel. */ timer : false, /* Indicates if timer has been started */ hcam : false, /* Indicates 'hidden cam' show is on or off. */ sover : false, /* Sell no tickets. */ end : false, /* End of show. */ email : false, /* Turns on/off email detection in tip note. */ ots : false /* Indicates if the Outstanding Ticket System is in use. Off by default. */ }; /***** Settings *****/ cb.settings_choices = [ {name: 'fg_color', label: '[GENERAL SETTINGS] ---------------------- Text color', type: 'str', defaultValue: '#800000', required: false}, {name: 'highest', label: '[KENO BOARD SETTINGS] ---------------------- Highest number', type: 'int', minValue: 1, maxValue: 250, defaultValue: 32}, {name: 'lowest', label: 'Lowest number', type: 'int', minValue: 1, maxValue: 249, defaultValue: 1}, {name: 'row_size', label: 'Numbers per row', type: 'int', minValue: 3, maxValue: 12, defaultValue: 8}, {name: 'multiples', label: 'Big tips call multiples', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'max_multiple', label: 'Maximum spots that can be called with one tip (0 = unlimited)', type: 'int', defaultValue: 0, minValue: 0, maxValue: 250}, {name: 'interval', label: 'Seconds between auto-displays (0 = off)', type: 'int', minValue: 0, defaultValue: 180}, {name: 'quarter_goal', label: '[GOAL SETTINGS] ---------------------- 25% cleared goal', type: 'str', defaultValue: 'shirt off', required: false}, {name: 'half_goal', label: '50% cleared goal', type: 'str', defaultValue: 'bra off', required: false}, {name: 'threeq_goal', label: '75% cleared goal', type: 'str', defaultValue: 'pants off', required: false}, {name: 'cleared_goal', label: '100% cleared goal', type: 'str', defaultValue: 'cum show', required: false}, {name: 'mvp_prize', label: 'Special prize for MVP', type: 'str', required: false}]; for (var i = 0; i < 100; i++){ cb.settings_choices.push({name: 'reward_' + i, label: 'Prize ' + (i+1), type: 'str', required: false}); } /***** Arrays *****/ var board = []; var prizeList = []; // List of prize objects var paidList = []; // Viewers who have paid for tickets var viewerList = []; // Ticket holders currently in the room var nirList = []; // Ticket holders currently NOT in the room var addList = []; // Manually added ticket holders var autoList = []; // Auto-added ticket holders var silList = []; // Viewers who have been muted var otsTickets = []; // Viewers who have an OTS ticket available to them var usedOTS = []; // Viewers who have used their OTS tickets var emList = { name : [], email : [] }; var startTime = new Date(); // The time the App is started. /********** Misc Variables **********/ var min = cb.settings.lowest; var max = cb.settings.highest; var roomHost = cb.settings.room_slug; var row_size = cb.settings.row_size; var blankSpot = max < 100 ? '\u2012\u2012' : '\u2012\u2012\u2012'; var typeCmds = " Type /cmds to see all commands."; var MODS = 'red'; var FANS = 'green'; var totalTipped = 0; var timerMinutes = 0; var hiddTime = 0; var rePassword; /********** objects **********/ function Viewer(username){ this.name = username; this.total_tipped = 0; this.times_tipped = 0; } function gen_Viewer(name){ } function Prize(text){ this.Prize_txt = text; this.active = true; } function Tile(number){ this.Tip_number = number; this.prize; this.active = true; } /********** ------------ PANEL ------------ **********/ cb.onDrawPanel(function () { }); function getBoardCount () { } /********** ENTER **********/ cb.onEnter(function(user) { }); /********** EXIT **********/ /********** ------------ TIPS ------------ **********/ cb.onTip((tip) => doTip(tip)); function doTip(tip) { var amt = tip.amount; var user = tip.from_user; var show = checkTip(amt, user, max_multiple); checkMVP(amt, user); checkGoal(); cb.drawPanel(); } function checkTip(amt, user, left) { var show = false; if (amt > max && cbs.multiples === 'Yes') { var arr = getListOfAvailable(); for (var i = 0; i < arr.length; i++) { if (!left) break; if (amt >= arr[i]) { checkTip(arr[i], user, left); amt = amt - arr[i]; left--; } } } else { if (prizes[amt]) { if (prizes[amt].active) { show = true; if (prizes[amt].prize) { addToWonList(user, prizes[amt].prize); roomNotice(user + ' picked ' + amt + ' and won: ' + prizes[amt].prize + '!'); } else { roomNotice(user + ' picked ' + amt + '! Sorry -- no prize there.'); } prizes[amt].active = false; tipCount += Number(amt); } } } return show; } /********** PRIZES **********/ function gen_prize_list(){ //----------------- done --------------------- ret = []; for (var i = 0; i < 100; i++){ //need to replace hard coded variable if (eval('cb.settings.reward_' + i) != ''){ eval('var prize' + i + '= new Prize(cb.settings.reward_' + i + ')'); ret.push(eval('prize' + i)); } } return ret; } function displayPrizes(user) { var arr = []; for (var i = 0; i < prizeList.length; i++) { if (prizeList[i].Prize_txt && prizeList[i].active && !arr.includes(prizeList[i].Prize_txt)) { arr.push(prizeList[i].Prize_txt); } } if (arr.length > 0) { arr = shuffle(arr); roomNotice('\u25CF --- [PRIZES LEFT] --- \u25CF\n' + arr.join('\n'), user); } } /********** BOARD **********/ function Board(){ this.Board_Arr = []; this.Shuffle = function(){ } this.get = function(){ } } Board.prototype.shuffle = function() { }; Board.prototype.display = function(user) { var vals = []; var rows = []; for (var i = 0; i < board.length; i++) board[i].active = true ? vals.push(numString(board[i].number)) : vals.push(blankSpot); //can also push \u2007\u2007 for tabular spaces for (var i = 0; i < vals.length; i = i + row_size) rows.push(vals.slice(i, i + row_size).join(' \u25E6 ')); while (rows[rows.length - 1].length < rows[0].length) rows[rows.length - 1] += ' \u25E6 ' + blankSpot; var output = rows.join('\u2007 |>\n') + '\u2007 |>\n' + TXT.infoStr + '\n'; roomNotice(output, user, 'bold'); } function gen_board(board_size){ //----------------- done --------------------- var j = 0; var ret = []; for (var i = 0; i < board_size; i ++){ eval('var tile_' + j + '= new Tile(i)'); //should tiles be named after there tip value for easy tracking? ret.push(eval('var tile_' + j)); j++; } return ret; } /*function displayBoard(user) { var vals = []; var rows = []; for (var i = 0; i < board.length; i++) board[i].active = true ? vals.push(numString(board[i].number)) : vals.push(blankSpot); //can also push \u2007\u2007 for tabular spaces for (var i = 0; i < vals.length; i = i + row_size) rows.push(vals.slice(i, i + row_size).join(' \u25E6 ')); while (rows[rows.length - 1].length < rows[0].length) rows[rows.length - 1] += ' \u25E6 ' + blankSpot; var output = rows.join('\u2007 |>\n') + '\u2007 |>\n' + TXT.infoStr + '\n'; roomNotice(output, user, 'bold'); }*/ function get_board_size(min, max){ return Math.abs(max - min); } function numString(num) { return num < 10 ? '0' + num : '' + num; } /********** MESSAGES **********/ cb.onMessage(function (msg) { if (msg.m.charAt(0) === '/' || msg.m.charAt(0) === '!') { msg['X-Spam'] = true; var str = msg.m.substring(1).trim(); var params = str.split(/\s+/); var cmd = params[0].toLowerCase().trim(); if (isCommander(msg.user)) command(cmd, params.slice(1), msg.user); switch (cmd) { case 'b': Board.display(msg.user); break; case 'p': displayPrizes(msg.user); break; }; } return msg; }); function isCommander(user) { return user === cb.room_slug || commanders.includes(user); } /*function displayWonList(user, number) { var arr = JSON.parse(JSON.stringify(won)); if (!number || isNaN(number) || number < 1) number = 15; var output = '*** LAST ' + number + ' PRIZES WON ***\n' + arr.reverse().slice(0, number).reverse().join('\n'); roomNotice(output, user); }*/ function command(cmd, params, user) { try { switch(cmd) { case 'pz': var p = Number(params[0]); roomNotice(p + ': ' + prizes[p].prize, user); break; case 'h': case 'help': var sep = '\n\u2007\u2007'; roomNotice(['\u25CF ----- [COMMANDS] ----- \u25CF', '/h or /help ' + sep + ' Show the help menu.', '/bx ' + sep + ' Show the board to everyone', '/px ' + sep + ' Show the prize list to everyone.', '/timer [X (number)] ' + sep + ' Sets a countdown timer for X minutes.', '/w or /won [X (number)] ' + sep + ' Shows model the last X prizes won. Defaults to 15.', '/addPrize [X (number)] [P (text)] ' + sep + ' Adds or overwrites prize at X with P.', '/rowSize [X (number)] ' + sep + ' Sets the number of board slots per row to X.', '/count [X (number)] ' + sep + ' Sets the number of tokens received to X.', '/kxt [X (number)] ' + sep + ' Simulates a tip of X tokens from ModelBot.', '/kx# [JavaScript] ' + sep + ' Execute JavaScript. Only use in emergencies.', ].join('\n'), user); break; case 'count': if (!Number(command[1])) break; tipCount = Number(command[1]); checkGoal(); break; case 'w': case 'won': displayWonList(user, Number(params[0])); break; case 'kxt': if (!params || !Number(params[0])) break; doTip({from_user: 'ModelBot', amount: Number(params[0])}) break; case 'bx': Board.display(user); break; case 'px': displayPrizes(); break; case 'addprize': if (params[0] && params[1]) { var num = Number(params[0]); var val = params.slice(1).join(' '); if (num && num <= max && num >= min && val.trim().length) { prizes[num] = {prize: val, active: true}; modMessage('Prize at ' + num + ' set to ' + val + '.'); } } break; case 'rowsize': if (params && params[0]) { var num = Number(params[0]); if (num) { if (num < 3) {num = 3;} else if (num > 12) {num = 12;} row_size = num; modMessage('Row size set to ' + num + '.', user); } } break; case 'kx#': try { var str = params.join(' '); var result = eval(str); var notice = 'TYPE: ' + typeof result + '\nVALUE: '; result !== void 0 ? notice += JSON.stringify(result, null, '\u2007\u2007\u2007\u2007') : notice += 'undefined'; cb.setTimeout(() => cb.sendNotice(newLines(notice), user, '', '#00CC00', '', ''), 100); } catch (e) { cb.setTimeout(() => cb.sendNotice(newLines(e.name + ': ' + e.message), user, '', '#FF0000', '', ''), 100); } break; }; } catch (e) { cb.sendNotice(e.message, '') } cb.drawPanel(); } /********** ------------ COMMUNICATION ------------ **********/ function roomNotice(text, user, weight) { cb.sendNotice(newLines(text), user, cb.settings.bg_color, cb.settings.fg_color, weight || 'bold', ''); } function modMessage (str, user) { roomNotice('MOD MESSAGE: ' + str, user); if (user !== cb.room_slug) roomNotice('MOD MESSAGE: ' + str, cb.room_slug); } function newLines(input) { return '|\u2007 ' + input.replace(/\n/g, '\n|\u2007 '); } /********** MISC **********/ function removeFromArray(array, elm) { //----------------- done -------------------- var index = array.indexOf(elm); if (index > -1) array.splice(index, 1); } function shuffle(a) { //----------------- done --------------------- var c = a.length, t, r; while (0 !== c) { r = Math.floor(Math.random() * c); c -= 1; t = a[c]; a[c] = a[r]; a[r] = t; } return a; } /********** INIT **********/ function init() { board = gen_board(get_board_size(min, max)); prizeList = gen_prize_list(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.