Apps Home
|
My Uploads
|
Create an App
GinApp
Author:
onesinmiedo
Description
Source Code
Launch App
Current Users
Created by:
Onesinmiedo
App Images
/** * Title: "Tip Menu Single Line / List " bot * Author: onesinmiedo (one.mb@protonmail.com) * Version: 0.1 (10/18/2019) */ const MAX_TIP_MENU_ITEMS = 20; const MAX_LOVENSE_MENU_ITEMS = 8; const MAX_LOVENSE_COMMANDS_MENU_ITEMS = 5; var lineBreak = '\n'; var everyone = ''; const panel = { dev : 'bb0e8e9a-d856-4afe-b961-09e3bc06f9f2', prod : '34520fe2-1511-4a64-8f4d-8c1fbe9f4faf', } const panelImage = panel.dev; // status var Status = { DISABLED : -1, STOPPED : 0, RUNNING : 1, PAUSED : 2 }; // colors var colors = { wine : '#722f37', wine2 : '#aa2222', orange : '#dc5500', red : '#ff0000', green : '#009900', darkpurple : '#5f497a' , lightpurple : '#be6aff', darkblue : '#1f497d', lightblue : '#6699aa', gray : '#494949', white : '#ffffff', }; // unicodes var unicodeChars = { space : '\u0020', dot : '\u22c5', // dot heart : '\u2665', // heart star : '\u2605', // filled star whiteStar : '\u2606', // white star square : '\u25fc', triangleRight : '\u25b6', dashChar : '\u2500', whiteHeart : '\u2661', arrow : '\u2192', triangleDown : '\u25bc', }; var emojis = { lifter : ':minilifter', heart : ':heart2', } // bots unicodes var botsUnicodes = { fitMenuBot : emojis.lifter, normalMenuBot : unicodeChars.heart, }; var defaultSettings = { backgroundColor: '', foregroundColor : colors.wine, commandFeedbackBackgroundColor: '', commandFeedbackForegroundColor: colors.gray, room : { subject : 'Welcome to my secret space ', tags : ['latin', 'latina', 'sensual', 'bigass', 'buttplug', 'redhair', 'petite', 'fitness', 'fit', 'biceps', 'thighs', 'muscles', 'friendly', 'natural', 'squirt', 'anal', 'clit', 'tattoos', 'shaved', 'dance'], }, multiGoal : { enabled : true, noticeTimeout: 60, noticeTimeoutTimes: 3, repeat: true, goals: [ {name: 'Sensual show', value: '1111'}, {name: 'Hot show', value: '1111'}, ], foregroundColor : colors.wine, backgroundColor : undefined, }, tippers : { unicode : undefined, prependTipCount : false, bombTipperMinValue : 1000, foregroundColor : undefined, backgroundColor : undefined, emotes : { kingTipper : ':osmking', bombTipper : ':osmbomb', } }, lovense : { enabled : true, noticeTimeout: 90, noticeTimeoutTimes: 3, lush : { levels : [ {description: 'LEVEL 1', min: 1, time: 3, power: 'low'}, {description: 'LEVEL 2', min: 15, time: 6, power: 'medim'}, {description: 'LEVEL 3', min: 100, time: 10, power: 'medium'}, {description: 'LEVEL 4', min: 500, time: 60, power: 'high'}, {description: 'LEVEL 5', min: 1000, time: 180, power: 'high'}, ], specialCommands : [ {description: 'RANDOM LEVEL', price: undefined, time: undefined}, {description: 'WAVE', price: undefined, time: undefined}, {description: 'PULSE', price: undefined, time: undefined}, {description: 'EARTHQUAKE', price: undefined, time: undefined}, {description: 'FIREWORKS', price: undefined, time: undefined}, ] } }, tipMenu : { tipMenuEnabled : true, normalMenuEnabled : true, fitMenuEnabled : true, fitUnicode : botsUnicodes.fitMenuBot, normalUnicode : botsUnicodes.normalMenuBot, format : "line", tips : { normalMenu : [ {name:'Kiss', value:5}, {name:'PM', value:7}, {name:'Suck finger', value:10}, {name:'Flash feet', value:18}, {name:'Twerk dressed', value:19}, {name:'Flash ass', value:20}, {name:'Spank ass', value:27}, {name:'Flash boobs', value:30}, {name:'Blow job', value:35}, {name:'Flash pussy', value:45}, {name:'Lick nipples', value:50}, {name:'Spank pussy', value:55}, {name:'Ass hole closeup', value:60}, {name:'Pussy closeup', value:65}, {name:'Finger in pussy', value:90}, {name:'Naked', value:120}, {name:'Twerk naked', value:130}, {name:'Dildo in pussy', value:150}, {name:'Butt plug', value:400}, {name:'Dildo in pussy + butt plug', value:550}, {name:'2 lush in pussy', value:1300}, {name:'2 lush in pussy + butt plug', value:1500}, {name:'Control toy 5 minutes (ASK FIRST)', value:1200}, {name:'1 lush in pussy + 1 lush in ass', value:1100}, {name:'Make my day', value:2000}, ], fitMenu : [ {name:'Biceps', value:11}, {name:'Triceps', value:12}, {name:'Shoulders', value:13}, {name:'Legs', value:14}, {name:'Abs', value:15}, {name:'Back', value:16}, {name:'Glutes', value:17}, {name:'5 push-ups', value:51}, {name:'5 sit-ups', value:52}, //{name:'5 pull-ups', value:61}, {name:'10 squats', value:62}, {name:'5 burpees', value:71}, {name:'5 pistols', value:72}, {name:'5 knee pull-ups', value:73}, {name:'10 chair-dips', value:81} ], }, happyTimeEnabled : false, happyTimeLength : 60, happyTimeTriggerTip : 1000, happyTimeDiscount : 50, fanClubDiscount : 20, noticeTimeout : 180, noticeTimeoutTimes : 1, tipForegroundColor : colors.white, tipBackgroundColor : colors.green, foregroundColor : colors.wine, backgroundColor : undefined, }, }; var botsData = { bots : { /////////////////////// // room title data // /////////////////////// roomSubject: undefined, ////////////////////// // goals // ////////////////////// multiGoal: { status: Status.DISABLED, name: 'Single/Multi-goal bot', goalsBucket : { done: { }, pending: { } }, currentGoalsListSum : 0, totalSum: 0, }, ////////////////////// // tippers bot data // ////////////////////// tippers : { status : Status.DISABLED, name : 'Tippers bot', bombTip : 0, minBombTip : 0, bombTipper : '', kingTipperSum : 0, kingTipper : '', tippers : {}, tipCount : 0, tipSum : 0, emotes : { kingTipper : undefined, bombTipper : undefined, }, }, ////////////////// // lovense // ////////////////// lovense : { foregroundColor: undefined, backgroundColor: undefined, lush: { icon: ':lushsm', levels : [], specialCommands : [], }, }, /////////////////////// // tip menu bot data // /////////////////////// tipMenu : { status : Status.DISABLED, name : 'Tip menu bot', enabled : false, fanClubDiscount : 0, discount : 0, timeoutId : undefined, timeout : 10, history : [], tips : {normalMenu : [], fitMenu: []}, happyTimeEnabled : false, happyTimeTriggered : false, happyTimeEnd : 0, happyTimeTimeoutId : undefined, happyTimeElapsedTimeoutId : undefined, happyTimeTriggerTip : 0, happyTimeLength : 0, happyTimeDiscount : 1, }, }, start : 0, commandsConfig : { "/fmb": { cmd: "tipmenu all" }, "/ht": { cmd: "tipmenu happytime" }, "/fm": { cmd: "tipmenu" }, "/fitmenu":{ cmd: "tipmenu" }, "/menu": { cmd: "tipmenu" }, "/title": { cmd: "title" }, "/tag": { cmd: "title tag" }, "/goal": { cmd: "multigoal"}, }, helpMessages : { tipMenu : [ ['bmr', repeat(botsUnicodes.tipMenuBot,5) + ' COMMANDS FOR THE FIT MENU BOT' + repeat(botsUnicodes.tipMenuBot,5) ], ['bmr', botsUnicodes.tipMenuBot + ' "/fm help" : shows this help text'], ['bmr', botsUnicodes.tipMenuBot + ' "/fm or /fitmenu" : shows the fit menu'], ['bm', botsUnicodes.tipMenuBot + ' "/fm history" : shows the tip menu history'], ['bm', botsUnicodes.tipMenuBot + ' "/fm counter" : shows the tip menu counter'], ['bm', botsUnicodes.tipMenuBot + ' "/fm rm <normal|fit> <index>" : Removes from the menu the item with the index <index>'], ['bm', botsUnicodes.tipMenuBot + ' "/fm add <normal|fit> <amount> <description>" : adds a new item to the tip menu'], ['bm', botsUnicodes.tipMenuBot + ' "/fm off" : stops tip menu bot'], ['bm', botsUnicodes.tipMenuBot + ' "/fm on" : starts the tip menu bot if it is not running'], ['bm', botsUnicodes.tipMenuBot + ' "/fm <norma|fit> show" : shows the normal|fit tip menu if it is hidden'], ['bm', botsUnicodes.tipMenuBot + ' "/fm <normal|fit> hide" : hides the normal|fit menu if it is not hidden'], ['bm', botsUnicodes.tipMenuBot + ' "/ht on" : enable happy time feature'], ['bm', botsUnicodes.tipMenuBot + ' "/ht off" : disable happy time feature'], ['bm', botsUnicodes.tipMenuBot + ' "/ht <percentage>" : sets percentage discount for happy time'], ['bm', botsUnicodes.tipMenuBot + ' "/ht time <seconds>" : sets happy time length in seconds'], ['bm', botsUnicodes.tipMenuBot + ' "/fm fan off" : disable fan club discount'], ['bm', botsUnicodes.tipMenuBot + ' "/fm fan on <amount>" : enable fan club discount'], ['bm', botsUnicodes.tipMenuBot + ' "/fm fan <percentage>" : sets percentage discount for fan club'], // broadcast messages ['bm', botsUnicodes.tipMenuBot + ' "/fmb" : shows the fit menu to everyone'], ['bm', botsUnicodes.tipMenuBot + ' "/fmb off" : stops the fit menu periodic notice'], ['bm', botsUnicodes.tipMenuBot + ' "/fmb on <minutes>" : shows the fit menu to everyone every <minutes> minutes'] ], title: [ ['bm', botsUnicodes.tipMenuBot + ' "/title <newTitle>" : sets new title'], ['bm', botsUnicodes.tipMenuBot + ' "/tag add <tag>" : adds tag to the end of the title'], ['bm', botsUnicodes.tipMenuBot + ' "/tag rm <tag>" : removes tag from title'], ], multigoal: [ ['bm', botsUnicodes.multiGoalBot + ' "/goal set <amount> <goalDescription> : sets a new goal'], ['bm', botsUnicodes.multiGoalBot + ' "/goal add <amount> <goalDescription> : adds a new goal to the end of the list'], ['bm', botsUnicodes.multiGoalBot + ' "/goal repeat on : sets repeat mode on'], ['bm', botsUnicodes.multiGoalBot + ' "/goal repeat off : sets repeat mode off'], ] }, welcomeMessages : [ ['', ' Welcome to my room $user ! :gingerdancetime'], ['', ' > type /fm or /menu for my tip menu'], ['', ' > type /lv or /levels for my lovense toy menu'], ], }; cb["settings_choices"] = []; cb.settings_choices.push( { name : "roomSubject", label : "*** TITULO DEL CHAT **************************************", type : "str", minLength : 10, maxLength : 255, defaultValue : defaultSettings.room.subject + defaultSettings.room.tags.map((item) => {return `#${item}`}).join(' '), required : false }, { name : "multiGoalEnabled", label : "SECCION MULTI-GOAL ...................... Multi-goal activado ", type : "choice", choice1 : 'yes', choice2 : 'no', defaultValue : defaultSettings.lovense.enabled ? "yes" : "no", required : true }, { name : "multiGoalList", label : "Lista de objetivos en orden, separados por ':' y su valor entre [ y ] ", type : "str", minlegth : 0, maxLength : 255, defaultValue : defaultSettings.multiGoal.goals.map(goal => `[${goal.value}] ${goal.name}`).join(' : '), required : false }, { name : "lovenseMenuEnabled", label : "SECCION LOVENSE ...................... Menu del Lovense activado ", type : "choice", choice1 : 'yes', choice2 : 'no', defaultValue : defaultSettings.lovense.enabled ? "yes" : "no", required : true }); for(i = 0; i < MAX_LOVENSE_MENU_ITEMS; i++) { cb.settings_choices.push({ name : "lovenseMenuItemDescription" + i, label : "Nombre del nivel " + (i+1) + " ----> ", type : "str", minLength : 3, maxLength : 255, defaultValue : defaultSettings.lovense.lush.levels[i] && defaultSettings.lovense.lush.levels[i].description ? defaultSettings.lovense.lush.levels[i].description : '', required : false }, { name : "lovenseMenuItemAmount" + i, label : "tokens minimos ", type : "str", minLength : 1, maxLength : 4, defaultValue : defaultSettings.lovense.lush.levels[i] && defaultSettings.lovense.lush.levels[i].min ? defaultSettings.lovense.lush.levels[i].min : '', required : false }, { name : "lovenseMenuItemTime" + i, label : "duracion (segundos) ", type : "str", minLength : 1, maxLength : 4, defaultValue : defaultSettings.lovense.lush.levels[i] && defaultSettings.lovense.lush.levels[i].time ? defaultSettings.lovense.lush.levels[i].time : '', required : false }, { name : "lovenseMenuItemPower" + i, label : "intensidad ", type : "choice", choice1 : "low", choice2 : "medium", choice3 : "high", choice4 : "ultra high", defaultValue : defaultSettings.lovense.lush.levels[i] && defaultSettings.lovense.lush.levels[i].power ? defaultSettings.lovense.lush.levels[i].power : '', required : false } )}; for(i = 0; i < MAX_LOVENSE_COMMANDS_MENU_ITEMS; i++) { cb.settings_choices.push({ name : "lovenseSpecialCommandDescription" + i, label : "Nombre del patron especial " + (i+1) + " ----> ", type : "str", minLength : 3, maxLength : 255, defaultValue : defaultSettings.lovense.lush.specialCommands[i].description ? defaultSettings.lovense.lush.specialCommands[i].description : '', required : false }, { name : "lovenseSpecialCommandAmount" + i, label : "tokens ", type : "str", minLength : 1, maxLength : 4, defaultValue : defaultSettings.lovense.lush.specialCommands[i].price ? defaultSettings.lovense.lush.specialCommands[i].price : '', required : false }, { name : "lovenseSpecialCommandTime" + i, label : "duracion (segundos) ", type : "str", minLength : 1, maxLength : 4, defaultValue : defaultSettings.lovense.lush.specialCommands[i].time ? defaultSettings.lovense.lush.specialCommands[i].time : '', required : false } )}; cb.settings_choices.push( { name : "tipMenuEnabled", label : "3) SECCION MENU ............................................. menu activado ", type : "choice", choice1 : 'yes', choice2 : 'no', defaultValue : defaultSettings.tipMenu.fitMenuEnabled ? "yes" : "no", required : true }, { name : "showNormalMenu", label : "Mostrar menu normal ", type : "choice", choice1 : 'yes', choice2 : 'no', defaultValue : defaultSettings.tipMenu.normalMenuEnabled ? "yes" : "no", required : true }, { name : "showFitMenu", label : "Mostrar fit-menu ", type : "choice", choice1 : 'yes', choice2 : 'no', defaultValue : defaultSettings.tipMenu.normalMenuEnabled ? "yes" : "no", required : true }, { name : "happyTimeEnabled", label : "Habilitar caracterisitica happy-time ", type : "choice", choice1 : "yes", choice2 : "no", defaultValue : defaultSettings.tipMenu.happyTimeEnabled ? "yes" : "no", required : true, }, { name : "happyTimeLength", label : "Duracion en segundos del happy-time (30 - 300)", type : "int", minValue : 30, maxValue : 300, defaultValue : defaultSettings.tipMenu.happyTimeLength, required : false }, { name : "happyTimeTriggerTip", label : "Propina en tokens que activa el happy-time ", type : "int", minValue : 0, maxValue : 10000, defaultValue : defaultSettings.tipMenu.happyTimeTriggerTip, required : false }, { name : "happyTimeDiscount", label : "Descuento que se aplica cuando es happy-time (0 - 50)%", type : "int", minValue : 0, maxValue : 50, defaultValue : defaultSettings.tipMenu.happyTimeDiscount, required : false }, { name : "fanClubDiscount", label : "Descuento que se aplica al club de fans (0 - 50)% ", type : "int", minValue : 0, maxValue : 50, defaultValue : defaultSettings.tipMenu.fanClubDiscount, required : false }); const tipCount = defaultSettings.tipMenu.tips.normalMenu.length + defaultSettings.tipMenu.tips.fitMenu.length + 3, tipLimit = (MAX_TIP_MENU_ITEMS > tipCount ? MAX_TIP_MENU_ITEMS : tipCount); for(let i = 0; i < tipLimit; i++) { let type, index, name, value; if (i < defaultSettings.tipMenu.tips.normalMenu.length){ type = 'normal'; name = defaultSettings.tipMenu.tips.normalMenu[i].name; value = defaultSettings.tipMenu.tips.normalMenu[i].value }else if (i < (defaultSettings.tipMenu.tips.normalMenu.length + defaultSettings.tipMenu.tips.fitMenu.length)){ type = 'fit'; index = i - defaultSettings.tipMenu.tips.normalMenu.length; name = defaultSettings.tipMenu.tips.fitMenu[index].name; value = defaultSettings.tipMenu.tips.fitMenu[index].value }else{ type = 'normal'; name = ''; description = ''; } cb.settings_choices.push({ name : "tipMenuItemName" + i, label : "Descripcion " + (i+1) + " ----> ", type : "str", minLength : 3, maxLength : 255, defaultValue : name , required : false }, { name : "tipMenuItemValue" + i, label : "precio ", type : "str", minLength : 1, maxLength : 255, defaultValue : value, required : false }, { name : "tipMenuItemType" + i, label : "tipo (normal|fit) ", type : "choice", choice1 : "normal", choice2 : "fit", defaultValue : type, required : false, }); } function elapsed(begin, end) { var milliseconds = end - begin; //Get hours from milliseconds var hours = milliseconds / (1000*60*60); var absoluteHours = Math.floor(hours); // var h = absoluteHours > 9 ? absoluteHours : '0' + absoluteHours; //Get remainder from hours and convert to minutes var minutes = (hours - absoluteHours) * 60; var absoluteMinutes = Math.floor(minutes); // var m = absoluteMinutes > 9 ? absoluteMinutes : '0' + absoluteMinutes; //Get remainder from minutes and convert to seconds var seconds = (minutes - absoluteMinutes) * 60; var absoluteSeconds = Math.floor(seconds); // var s = absoluteSeconds > 9 ? absoluteSeconds : '0' + absoluteSeconds; return {hours: absoluteHours , minutes: absoluteMinutes , seconds: absoluteSeconds}; } ////////////////////////////////////// // welcome and help message methods // ////////////////////////////////////// function getWelcomeMessage(user) { var resultString = lineBreak; botsData.welcomeMessages.forEach(function(item){ if(item[0].length == 0 || item[0].indexOf("m") >= 1 && user.is_mod || item[0].indexOf("r") >= 1) resultString += item[1].replace('$user', user.user) + lineBreak ; }); return resultString; } function getFullHelp(message) { return getTipMenuHelp(message) + getRoomTitleHelp(message); } function getRoomTitleHelp(message) { var resultString = lineBreak, isOwner = (message.user == cb.room_slug), isMod = (message.is_mod); botsData.helpMessages.title.forEach(function(item){ if(item[0].length == 0 || item[0].indexOf("m") >= 0 && isMod || item[0].indexOf("b") >= 0 && isOwner || item[0].indexOf("r") >= 0 && (!isOwner && !isMod)) resultString += item[1] + lineBreak ; }); return resultString.trim().length == 0? "" : resultString; } function getTipMenuHelp(message) { var resultString = lineBreak, isOwner = (message.user == cb.room_slug), isMod = (message.is_mod); botsData.helpMessages.tipMenu.forEach(function(item){ if(item[0].length == 0 || item[0].indexOf("m") >= 0 && isMod || item[0].indexOf("b") >= 0 && isOwner || item[0].indexOf("r") >= 0 && (!isOwner && !isMod)) resultString += item[1] + lineBreak ; }); return resultString.trim().length == 0? "" : resultString; } //////////// // Events // //////////// /** user: user who entered the room in_fanclub: is the user in the broadcaster’s fan club has_tokens: does the user have at least 1 token is_mod: is the user a moderator tipped_recently: is the user a “dark blue”? tipped_alot_recently: is the user a “purple”? tipped_tons_recently: is the user a “dark purple”? gender: “m” (male), “f” (female), “s” (trans), or “c” (couple) */ cb.onEnter(function(user){ sendWelcomeMessage(user); }); function sendWelcomeMessage(user) { sendBoldNotice(user.user, getWelcomeMessage(user), botsData.foregroundColor, botsData.backgroundColor); } /** amount: amount of tip message: message in tip to_user: user who received tip from_user: user who sent tip from_user_in_fanclub: is the user in the broadcasters fan club from_user_has_tokens: does the user have at least 1 token from_user_is_mod: is the user a moderator from_user_tipped_recently: is the user a “dark blue”? from_user_tipped_alot_recently: is the user a “purple”? from_user_tipped_tons_recently: is the user a “dark purple”? from_user_gender: “m” (male), “f” (female), “s” (trans), or “c” (couple) */ cb.onTip(function( tipData ){ tip (tipData); }); cb.onDrawPanel(function(user){ return drawPanel(); }); /** c: message color m: the message text user: username of message sender f: message font in_fanclub: is the user in the broadcasters fan club has_tokens: does the user have at least 1 token is_mod: is the user a moderator tipped_recently: is the user a “dark blue”? tipped_alot_recently: is the user a “purple”? tipped_tons_recently: is the user a “dark purple”? gender: “m” (male), “f” (female), “s” (trans), or “c” (couple) */ cb.onMessage(function( message ){ var username = message.user, commandString = stripCommandFromMessage(message.m); // if it's a command, process it if (commandString) { var errorMsg = processCommand(message, commandString); if (errorMsg === false ) return message; if ( errorMsg ) sendErrorNotice(username, errorMsg, commandString); message['m'] = ''; message['X-Spam'] = true; return message; } if(message.in_fanclub) message.c = colors.green; return message; }); /////////// // Utils // /////////// function padRight(char, length) { return char + repeat(char, length); } function padLeft(char, length) { return repeat(char, length) + char; } function repeat(char, length) { var result = ""; while(length--) result += char; return result; } function bracket(string, unicode, length = 5, verticalPadding = 0) { var lines = string.trim().split(lineBreak), resultString = ''; lines.forEach( function( line, index ){ lines[index] = unicode + ' ' + line; }); resultString += (((unicode == '') && (unicode = '-'), length > 0 ? repeat(unicode, length) + lineBreak :'')); resultString += ((unicode == '') && (unicode = '|') , repeat((unicode + lineBreak), verticalPadding)) + lines.join('\n') + ((unicode == '') && (unicode = '|') , repeat((lineBreak + unicode), verticalPadding)) resultString += (((unicode == '') && (unicode = '-'), length > 0 ? (lineBreak + repeat(unicode, length)) :'')); return resultString; } function fanPrice(amount) { var fansDiscount = botsData.bots.tipMenu.fanClubDiscount; return Math.floor(amount * (1 - fansDiscount/100)); } function happyTimePrice(amount) { var happyTimeDiscount = botsData.bots.tipMenu.happyTimeDiscount; return Math.floor(amount * (1 - happyTimeDiscount/100)); } function objectSize(object) { var result = 0; for (var item in object) { if(object.hasOwnProperty(item)){ result++; } } return result; } function capitalize(str) { return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); } ///////////////// // draw panel // ///////////////// function center(value) { if (Math.floor(value/10) == 0) { return 157; } if (Math.floor(value/100) == 0){ return 153; } if (Math.floor(value/1000) == 0){ return 149; } if (Math.floor(value/10000) == 0){ return 146; } if (Math.floor(value/100000) == 0) { return 142; } } function drawPanel() { const tippersBot = botsData.bots.tippers, tipSum = tippersBot.tipSum, kingTipper = (tippersBot.kingTipper == '') ? 'There\'s no king tipper yet' : tippersBot.kingTipper , kingTipperSum = tippersBot.kingTipperSum, bombTip = botsData.bots.tippers.bombTip, bombTipper = botsData.bots.tippers.bombTipper, fontSize = 11, fontSizeBig = 13, fontSizeSmall = 10, template = { "template" : "image_template", "layers": [ {'type': 'image', 'fileID': panelImage}, { 'type': 'text', 'text': 'Tokens earned:', 'top': 5, 'left': 113, 'font-size': fontSizeBig, 'font-weight': 'bold', 'color': 'orange', }, { 'type' : 'text', 'text' : tipSum, 'top' : 22, 'left' : center(tipSum), 'font-size' : fontSizeBig, 'color': 'black', }, { 'type': 'text', 'text': 'Biggest Tip:', 'top': 40, 'left': 75, 'font-size': fontSize, 'font-weight': 'bold', 'color': 'orange', }, { 'type': 'text', 'text': 'Best Tipper:', 'top': 53, 'left': 75 , 'font-size': fontSize, 'font-weight': 'bold', 'color': 'orange', }, { 'type': 'text', 'text': `${bombTip == 0 ? 0 : bombTip + '(' + bombTipper + ')'}`, 'top': 40, 'left': 140, 'font-size': fontSize, 'color': 'black', }, { 'type': 'text', 'text': `${kingTipperSum == 0 ? 0 : kingTipperSum + '(' + kingTipper + ')'}`, 'top': 53, 'left': 140, 'font-size': fontSize, 'color': 'black', }, ], }; return template; } ///////////////// // Send notice // ///////////////// function sendNotice(user, message, foregroundColor, backgroundColor, group) { var fg = foregroundColor || botsData.foregroundColor; var bg = backgroundColor|| botsData.backgroundColor; var grp = group || ""; cb.sendNotice(message, user, bg, fg, 'normal', grp); } function sendBoldNotice(user, message, foregroundColor, backgroundColor, group) { var fg = foregroundColor || botsData.foregroundColor; var bg = backgroundColor|| botsData.backgroundColor; var grp = group || ""; cb.sendNotice(message, user, bg, fg, 'bold', grp); } function sendBoldNoticeInverse(user, message, foregroundColor, backgroundColor, group) { var bg = foregroundColor || botsData.foregroundColor; var fg = backgroundColor == '' ? '#fff' : backgroundColor; var grp = group || ""; cb.sendNotice(message, user, bg, fg, 'bold', grp); } function sendCommandFeedback(user, message) { cb.sendNotice(message, user, botsData.commandFeedbackBackgroundColor, botsData.commandFeedbackForegroundColor, 'normal'); } function sendErrorNotice(username, message, commandString) { message = lineBreak + ' Error command : /' + commandString + lineBreak + unicodeChars.square + message + lineBreak; sendBoldNotice(username, message); } function log(message) { cb.sendNotice('LOG:: '+message, cb.room_slug, botsData.commandFeedbackBackgroundColor, botsData.commandFeedbackForegroundColor, 'normal'); } ///////// // tip // ///////// function checkTipMenu(user, amount) { var tipMenuBot = botsData.bots.tipMenu, happyTimeTriggered = tipMenuBot.happyTimeTriggered, tipMenuList = tipMenuBot.tips.normalMenu, fitMenuList = tipMenuBot.tips.fitMenu; tipMenuBot.status == Status.RUNNING && tipMenuBot.showNormalMenu && tipMenuList.forEach(function(item, index) { if (discountPrice(item.value, user) == amount) { tipMenuList[index].times += 1; tipMenuBot.history.push({user: user.user, description:item.name, type: item.type, time: new Date().getTime(), happyTime: happyTimeTriggered}); sendTipMenuNotice( user, item.name, item.type); } }); tipMenuBot.status == Status.RUNNING && tipMenuBot.showFitMenu && fitMenuList.forEach(function(item, index) { if (discountPrice(item.value, user) == amount) { fitMenuList[index].times += 1; tipMenuBot.history.push({user: user.user, description:item.name, type: item.type, time: new Date().getTime(), happyTime: happyTimeTriggered}); sendTipMenuNotice( user, item.name, item.type); } }); } function checkLovense(user, amount) { var lovenseBot = botsData.bots.lovense, lovenseList = lovenseBot.lush, reversed = lovenseList.levels.reverse(); found = false; if (lovenseBot.status == Status.RUNNING) { found = lovenseList.specialCommands.some(function(item, index) { if (item.amount == amount) { sendLovenseNotice( user.user, item.time, item.description); return true; } }); }; lovenseBot.status == Status.RUNNING && !found && reversed.some(function(item) { if (amount >= item.min ) { sendLovenseNotice( user.user, item.time, item.description); return true; } }); lovenseList.levels.reverse(); } function checkHappyTime(amount) { var tipMenuBot = botsData.bots.tipMenu; if (tipMenuBot.happyTimeEnabled && (amount == tipMenuBot.happyTimeTriggerTip)) { triggerHappyTime(); } } function tip(tipData) { var amount = tipData.amount, user = { user : tipData.from_user, in_fanclub : tipData.from_user_in_fanclub, // TODO change this is_mod : tipData.from_user_is_mod, has_tokens : tipData.from_user_has_tokens, tipped_recently : tipData.from_user_tipped_recently, tipped_alot_recently : tipData.from_user_tipped_alot_recently, tipped_tons_recently : tipData.from_user_tipped_tons_recently, gender : tipData.from_user_gender, }; // currentKingTipper = botsData.bots.tippersBot.kingTipper, // currentBombTipper = botsData.bots.tippersBot.bombTipper, // message = []; updateGlobalTipCounter(amount); updateTippersList(user, amount); checkHappyTime(amount); checkLovense(user,amount); checkTipMenu(user, amount); updateMultiGoal(user, amount); cb.drawPanel(); } function updateGlobalTipCounter( amount) { botsData.bots.tippers.tipSum += amount; botsData.bots.tippers.tipCount += 1; } function updateTippersList(user, amount) { const tippersBot = botsData.bots.tippers, currentKingTipper = tippersBot.kingTipper, currentBombTipper = tippersBot.bombTipper; if ( user.user in tippersBot.tippers ) { tippersBot.tippers[user.user].sum += amount; } else { tippersBot.tippers[user.user] = { sum : amount, data: user }; } // update bomb tip data if ( amount > tippersBot.bombTip ) { tippersBot.bombTip = amount; tippersBot.bombTipper = user.user; } // update king tipper data if (tippersBot.tippers[user.user].sum > tippersBot.kingTipperSum) { tippersBot.kingTipperSum = tippersBot.tippers[user.user].sum; tippersBot.kingTipper = user.user; } const message = []; // if there's a new king, compose message if ( tippersBot.kingTipper != currentKingTipper) { message.push(`${tippersBot.emotes.kingTipper} ${user.user} is our new KING. All glory to ${user.user}! ${tippersBot.emotes.kingTipper}`); } // if there's a new bomb, compose message if ( tippersBot.bombTipper != currentBombTipper) { message.push(`${tippersBot.emotes.bombTipper} ${user.user} is our new BOMB tipper!!. Thank you, ${user.user}! ${tippersBot.emotes.bombTipper}`); } // if there's something to be shown, show it message.length && sendBoldNotice(everyone, message.join(lineBreak), tippersBot.foregroundColor, tippersBot.background); } //////////////////////// // Commands procesing // //////////////////////// function stripCommandFromMessage(originalMessage) { // cycle through the commands list for (var command in botsData.commandsConfig){ var index = originalMessage.toLowerCase().indexOf(command); // find alias in the message if (index >= 0) { // if alias is found var commandArray = splitBySpaces(originalMessage.substring(index)); // cut into pieces the message starting from the command return originalMessage.substring(index).replace(commandArray[0], botsData.commandsConfig[command]['cmd']); // return the message but replaced the alias for the command } } } function processCommand(message, commandString) { var commandArray = splitBySpaces(commandString.toLowerCase()), command = commandArray[0]; if ( command == 'tipmenu') { return processTipMenuCommand(message, commandArray, commandString); } if ( command == 'title') { return processTitleCommand(message, commandArray, commandString); } if ( command == 'multigoal') { return processMultiGoalCommand(message, commandArray, commandString); } return void 0; } function processTitleCommand(message, commandArray) { if (message.user !== cb.room_slug && !message.is_mod) { return false; } ///////////////////////////////////////////// // then: commands for mods and broadcaster // ///////////////////////////////////////////// if (commandArray.length > 3 && commandArray[1].toLowerCase() == 'tag' && commandArray[2].toLowerCase() == 'add' ) { const tags = commandArray.splice(3); tags.forEach((element) => { element = (element.indexOf('#') == 0)? element: `#${element}`; if (botsData.bots.roomSubject.search(`(^|\\s)${element}(\\s|$)`) < 0) botsData.bots.roomSubject = `${botsData.bots.roomSubject} ${element}`; }); cb.changeRoomSubject(botsData.bots.roomSubject); sendBoldNotice(message.user, "tag added to subject", colors.wine, ''); } if (commandArray.length > 3 && commandArray[1].toLowerCase() == 'tag' && commandArray[2].toLowerCase() == 'rm' ) { const tags = commandArray.splice(3); tags.forEach((element) => { element = (element.indexOf('#') == 0)? element: `#${element}`; let test = new RegExp(`(^|\\s)${element}(\\s|$)`); botsData.bots.roomSubject = botsData.bots.roomSubject.replace(test,' ').trim(); }); cb.changeRoomSubject(botsData.bots.roomSubject); sendBoldNotice(message.user, "tag removed from subject", colors.wine, ''); } } function processTipMenuCommand(message, commandArray) { var tipMenuBot = botsData.bots.tipMenu; ////////////////////////////////// // first: commands for everyone // ////////////////////////////////// if (commandArray.length == 2 && commandArray[1] == 'help') { sendTipMenuHelp(message); return; } if (commandArray.length == 1) { sendTipMenu(message); return; } if (message.user !== cb.room_slug && !message.is_mod) { return false; } ///////////////////////////////////////////// // then: commands for mods and broadcaster // ///////////////////////////////////////////// // Add item to menu if (commandArray.length > 4 && commandArray[1] == 'add' && ['normal','fit'].includes(commandArray[2]) &&!isNaN(parseInt(commandArray[3]))){ var menuItem = commandArray.slice(4).join(' '), index = insertInTipMenu(commandArray[2], commandArray[3], menuItem); sendAddTipMenuResult(message.user, menuItem, commandArray[2], commandArray[3], index); return; } // Edit menu item if (commandArray.length > 5 && commandArray[1] == 'edit' && ['normal','fit'].includes(commandArray[2]) &&!isNaN(parseInt(commandArray[3])) &&!isNaN(parseInt(commandArray[4]))){ var menuItem = commandArray.slice(5).join(' '); if(updateTipMenu(commandArray[2], commandArray[3], commandArray[4], menuItem)) sendUpdateTipMenuResult(message.user, commandArray[2], menuItem, commandArray[4], commandArray[3]); return; } // remove item from menu if (commandArray.length == 4 && commandArray[1] == 'rm' && ['normal','fit'].includes(commandArray[2]) && !isNaN(parseInt(commandArray[3]))) { removeFromTipMenu(commandArray[2], parseInt(commandArray[3])); sendRemoveTipMenuResult(message.user, commandArray[2], commandArray[3]); return; } // show history if (commandArray.length == 2 && 'history'.indexOf(commandArray[1].toLowerCase()) == 0) { sendTipMenuHistory(); return; } // show counter if (commandArray.length == 2 && 'counter'.indexOf(commandArray[1].toLowerCase()) == 0) { sendTipMenuCounter(); return; } // stop showing a tip menu if (commandArray.length == 3 && ['normal', 'fit'].includes(commandArray[1]) && 'hide'.indexOf(commandArray[2]) == 0) { setMenuVisibility(message.user, commandArray[1], false); return; } // stop hiding a tip menu if (commandArray.length == 3 && ['normal', 'fit'].includes(commandArray[1]) && 'show'.indexOf(commandArray[2]) == 0) { setMenuVisibility(message.user, commandArray[1], true); return; } // stop running bot if (commandArray.length == 2 && ['off','on','pause'].includes(commandArray[1])) { setBotStatus(message.user, 'tipMenu', commandArray[1]); return; } // turn off happy time if (commandArray.length == 3 && 'happytime'.indexOf(commandArray[1].toLowerCase()) == 0 && commandArray[2] == 'off') { disableHappyTime(); return; } // turn on happy time if (commandArray.length >= 3 && 'happytime'.indexOf(commandArray[1].toLowerCase()) == 0 && commandArray[2] == 'on') { var discount = commandArray[3] && !isNaN(parseInt(commandArray[3])) ? (parseInt(commandArray[3]) > 99 ? 99 : parseInt(commandArray[3])) : undefined, trigger = commandArray[4] && !isNaN(parseInt(commandArray[4])) ? (parseInt(commandArray[4]) > 1000 ? 1000 : parseInt(commandArray[4])) : undefined; time = commandArray[5] && !isNaN(parseInt(commandArray[5])) ? (parseInt(commandArray[5]) > 300 ? 300 : parseInt(commandArray[5])) : undefined; botsData.bots.tipMenu.happyTimeDiscount = discount ? discount : defaultSettings.tipMenu.happyTimeDiscount; botsData.bots.tipMenu.happyTimeLength = time ? time : defaultSettings.tipMenu.happyTimeLength; botsData.bots.tipMenu.happyTimeTriggerTip = trigger ? trigger : defaultSettings.tipMenu.happyTimeTriggerTip; enableHappyTime(); return; } // broadcast tip menu if (commandArray.length == 2 && 'all'.indexOf(commandArray[1].toLowerCase()) == 0) { broadcastTipMenu(); return; } // stop periodic notice if (commandArray.length == 3 && 'all'.indexOf(commandArray[1].toLowerCase()) == 0 && commandArray[2] == 'off') { tipMenuBot.timeoutId = cb.cancelTimeout(tipMenuBot.timeoutId); sendTipMenuBroadcastOff(message.user); return; } // start periodic notice if (commandArray.length == 4 && commandArray[1] == 'all' && commandArray[2] == 'on' && !isNaN(parseInt(commandArray[3])) && parseInt(commandArray[3]) > 0) { tipMenuBot.timeoutId = cb.cancelTimeout(tipMenuBot.timeoutId); tipMenuBot.timeout = parseInt(commandArray[3]); broadcastTipMenuTimeout(); // feedback to user sendTipMenuBroadcastOn(message.user, parseInt(tipMenuBot.timeout)); return; } // show menu in a list if (commandArray.length == 2 && 'list'.indexOf(commandArray[1].toLowerCase().substring(2)) == 2) { botsData.bots.tipMenu.format = "list"; // feedback to user sendTipMenuFormat(message.user, "list"); return; } // show menu in a line if (commandArray.length == 2 && 'line'.indexOf(commandArray[1].toLowerCase().substring(2)) == 2) { botsData.bots.tipMenu.format = "line"; // feedback to user sendTipMenuFormat(message.user, "line"); return; } // enable fan discount if (commandArray.length >= 3 && 'fan'.indexOf(commandArray[1].toLowerCase()) == 0 && commandArray[2] == 'on') { var discount = commandArray[3] && !isNaN(parseInt(commandArray[3])) ? (parseInt(commandArray[3]) > 99 ? 99 : parseInt(commandArray[3])) : undefined; botsData.bots.tipMenu.fanClubDiscount = discount ? discount : defaultSettings.tipMenu.fanClubDiscount; enableFanClubDiscount(); return; } // disable fan discount if (commandArray.length == 3 && 'fan'.indexOf(commandArray[1].toLowerCase()) == 0 && commandArray[2] == 'off') { disableFanClubDiscount(); return; } // change fan club percentage if (commandArray.length == 3 && 'fan'.indexOf(commandArray[1].toLowerCase()) == 0 && !isNaN(parseInt(commandArray[2]))) { var discount = commandArray[2] ? (parseInt(commandArray[2]) > 99 ? 99 : parseInt(commandArray[3])) : undefined; botsData.bots.tipMenu.fanClubDiscount = discount ? discount : defaultSettings.tipMenu.fanClubDiscount; enableFanClubDiscount(); return; } return false; } function processMultiGoalCommand(message, commandArray) { if (message.user !== cb.room_slug && !message.is_mod) { return false; } ///////////////////////////////////////////// // then: commands for mods and broadcaster // ///////////////////////////////////////////// // add goal to list if (commandArray.length > 3 && 'add'.indexOf(commandArray[1].toLowerCase())==0 && !isNaN(parseInt(commandArray[2])) ) { const goal = commandArray.slice(3).join(' '), value = parseInt(commandArray[2]), index = insertInGoalList(value, goal); sendCommandFeedback(message.user, `Se ha agregado la meta '${goal.toUpperCase()}' por ${value} tokens a la lista en la posicion ${index}`); return ; } // set goal if (commandArray.length > 3 && 'set'.indexOf(commandArray[1].toLowerCase())==0 && !isNaN(parseInt(commandArray[2])) ) { const goal = commandArray.slice(3).join(' '), value = parseInt(commandArray[2]); setGoal(value, goal); sendCommandFeedback(message.user, `Se ha establecido la meta '${goal.toUpperCase()}' por ${value} tokens`); cb.changeRoomSubject(`${botsData.bots.roomSubject} :: ${goal} [${value} tokens left]`); return; } // set repeat flag if (commandArray.length == 3 && 'repeat'.indexOf(commandArray[1].toLowerCase())==0 && ['on', 'off'].includes(commandArray[1].toLowerCase())) { const value = parseInt(commandArray[2]); botsData.bots.multiGoal.repeat = (commandArray[2]=='on' ? true : false); sendCommandFeedback(message.user, `Las metas ${commandArray[2]=='on'?'SI':'NO'} se repiten a partir de ahora`); return; } } function splitBySpaces(string) { return string.trim().replace(/\s+/g, ' ').split(' '); } function setBotStatus(username, botId, status) { const statusName = ['stopped','running','paused'], bot = botsData.bots[botId], oldStatus = bot.status; bot.status = status=='pause' ? Status.PAUSED : (status=='on' ? Status.RUNNING : Status.STOPPED); sendCommandFeedback(username, `${bot.name} is ${statusName[bot.status]}`); } /************* tip menu **************/ function sendTipMenuHelp( message ) { sendNotice(message.user, getTipMenuHelp(message) ); } function insertInTipMenu( type, value, name ) { var normalMenuList = botsData.bots.tipMenu.tips.normalMenu, fitMenuList = botsData.bots.tipMenu.tips.fitMenu, targetList = ('normal'.indexOf(type) == 0) ? normalMenuList : fitMenuList; var index = targetList.findIndex(function(item) { return value <= item.value; }); if (index < 0) { targetList.push({value: value, name: name}); return targetList.length-1; } tipMenuList.splice(index, 0, {value: value, name: name}); return index; } function updateTipMenu(type, index, value, name) { var normalMenuList = botsData.bots.tipMenu.tips.normalMenu, fitMenuList = botsData.bots.tipMenu.tips.fitMenu, targetList = ('normal'.indexOf(type) == 0) ? normalMenuList : fitMenuList; if (targetList[index]){ targetList[index] = {name: name, value: value}; return true; } return false; } function removeFromTipMenu( type, index ) { var normalMenuList = botsData.bots.tipMenu.tips.normalMenu, fitMenuList = botsData.bots.tipMenu.tips.fitMenu, targetList = ('normal'.indexOf(type) == 0) ? normalMenuList : fitMenuList; return ((targetList.splice(index, 1)).length == 1); } function setMenuVisibility(username, type, status) { botsData.bots.tipMenu['show' + capitalize(type) + 'Menu'] = status; const result = `${capitalize(type)} menu visibility has been set to ${!status ? 'hidden' : 'visible'}`; sendCommandFeedback(username, result); } function sendAddTipMenuResult( username, item, type, price, index ) { const resultString = `"${item}" (${price}) has been added to the ${type == 'normal'? 'normal tip menu':'fit menu'} in position ${index}`; sendCommandFeedback(username, resultString); } function sendUpdateTipMenuResult(username, type, name, value, index) { const resultString = `"Item in position #${index} of the ${type == 'normal'? 'normal tip menu':'fit menu'} has been updated with "${name}" (${value})`; sendCommandFeedback(username, resultString); } function sendRemoveTipMenuResult( username, type, index ) { const resultString = `Item #${index} has been removed from the ${type == 'normal'? 'normal tip menu':'fit menu'}`; sendCommandFeedback(username, resultString); } function sendTipMenu(message) { if (message == everyone) message = {user:'', is_mod: false, in_fanclub: false}; var resultString = '', tipMenuBot = botsData.bots.tipMenu, normalUnicode = tipMenuBot.normalUnicode||'*', fitUnicode = tipMenuBot.fitUnicode||'*', tipMenuListNormal = tipMenuBot.tips.normalMenu, tipMenuListFit = tipMenuBot.tips.fitMenu, happyTimeMsg = `Happy time is enabled. Tip ${tipMenuBot.happyTimeTriggerTip} tokens and every item in the tip menu will be ${tipMenuBot.happyTimeDiscount}% cheaper for ${tipMenuBot.happyTimeLength} seconds.`; if (tipMenuBot.status != Status.RUNNING) { resultString = "The fit menu is not running"; sendBoldNotice(message.user, resultString, tipMenuBot.foregroundColor, tipMenuBot.backgroundColor); return; } (message.is_mod || message.user == cb.room_slug || tipMenuBot.showNormalMenu) && tipMenuListNormal.forEach(function(item, index){ var indexPrefix = ((message.user == cb.room_slug) || message.is_mod) ? '-[ ' + index +' ]- ' :'', amount = discountPrice(item.value), fanAmount = fanPrice(amount), amountString; resultString += index == 0 ? `${lineBreak} ${repeat('-', 5)} MY TIP MENU ${repeat('-', 5)}${(tipMenuBot.format == "line" ? '> ' : '')}`:''; if (botsData.bots.tipMenu.format == "list") { amountString = ((amount == fanAmount)? amount : (message.in_fanclub ? fanAmount : (amount + " (" + fanAmount + " fan club members)"))) + (tipMenuBot.happyTimeTriggered ? ' ON SALE!!' : ''); resultString += `${lineBreak} ${normalUnicode} -${indexPrefix}- ${amountString} | ${item.name}`; // TODO add more unicodes here } else { amountString = ((amount == fanAmount)?amount : (message.in_fanclub ? fanAmount : (amount + " | " + fanAmount + " fan club"))) + (tipMenuBot.happyTimeTriggered ? ' ON SALE!!' : ''); resultString += ` ${normalUnicode} ${indexPrefix} ${item.name} (${amountString}) `; // TODO add more unicodes here } }); (message.is_mod || message.user == cb.room_slug || tipMenuBot.showFitMenu) && tipMenuListFit.forEach(function(item, index){ var indexPrefix = ((message.user == cb.room_slug) || message.is_mod) ? '-[ ' + index +' ]- ' :'', amount = discountPrice(item.value), fanAmount = fanPrice(amount), amountString; resultString += index == 0 ? `${(message.is_mod || message.user == cb.room_slug || tipMenuBot.showNormalMenu) ? lineBreak : ''}${lineBreak} ${repeat('-', 5)} MY FIT MENU ${repeat('-', 5)}${(tipMenuBot.format == "line" ? '> ' : '')}`:''; if (botsData.bots.tipMenu.format == "list") { amountString = ((amount == fanAmount)? amount : (message.in_fanclub ? fanAmount : (amount + " (" + fanAmount + " fan club members)"))) + (tipMenuBot.happyTimeTriggered ? ' ON SALE!!' : ''); resultString += `${lineBreak} ${fitUnicode} -${indexPrefix}- ${amountString} | ${item.name}`; // TODO add more unicodes here } else { amountString = ((amount == fanAmount)?amount : (message.in_fanclub ? fanAmount : (amount + " | " + fanAmount + " fan club"))) + (tipMenuBot.happyTimeTriggered ? ' ON SALE!!' : ''); resultString += ` ${fitUnicode} ${indexPrefix} ${item.name} (${amountString}) `; // TODO add more unicodes here } }); if (resultString.length == 0) { resultString = "The fit menu is empty"; sendBoldNotice(message.user, resultString, tipMenuBot.foregroundColor, tipMenuBot.backgroundColor); return; } sendBoldNotice(message.user, resultString + lineBreak, tipMenuBot.foregroundColor, tipMenuBot.backgroundColor); tipMenuBot.happyTimeEnabled && (tipMenuBot.status == Status.RUNNING && (tipMenuBot.showNormalMenu || tipMenuBot.showFitMenu)) && sendBoldNotice(message.user, normalUnicode + ' ' + happyTimeMsg.toUpperCase(), colors.white, tipMenuBot.foregroundColor); } function sendTipMenuHistory( username ) { var resultString = '', tipMenuBot = botsData.bots.tipMenu, unicode = tipMenuBot.normalUnicode, history = tipMenuBot.history.reverse(), now = new Date().getTime(); history.forEach( function( item ){ var lapse = elapsed(item.time, now), seconds = lapse.seconds > 0 ? lapse.seconds + 'seconds ' : '', minutes = lapse.minutes > 0 ? lapse.minutes + 'minutes ' : '', hours = lapse.hours > 0 ? lapse.hours + 'hours ' : '', lapseString = hours + minutes + seconds + 'ago'; resultString += (tipMenuBot[`${item.type}Unicode`] + ' ---- ' + item.description + ' : ' + item.user + ' : ' + lapseString + lineBreak); }); resultString = (resultString.length == 0 ? repeat(unicode, 5) + " Tip menu history is empty " + repeat(unicode, 5) : resultString); sendBoldNotice(username, resultString, tipMenuBot.foregroundColor, tipMenuBot.backgroundColor); } function sendTipMenuCounter( username ) { var resultString = '', tipMenuBot = botsData.bots.tipMenu, tipMenuCounter = tipMenuBot.tips.normalMenu.concat(tipMenuBot.tips.fitMenu).sort(function(a,b) { return (parseInt(b.times) - parseInt(a.times)); }); tipMenuCounter.forEach(function(item){ resultString += item.times > 0 ? ( tipMenuBot[`${item.type}Unicode`] + ' ---- ' + item.times + ' | ' + item.name + lineBreak) : ''; // TODO add more unicodes here }); resultString = (resultString.length == 0 ? repeat(unicode, 5) + " Nobody has tipped for an item in the tip menu " + repeat(unicode, 5) : resultString); sendBoldNotice(username, resultString, tipMenuBot.foregroundColor, tipMenuBot.backgroundColor); } function sendTipMenuNotice( user, description, type) { var unicode = botsData.bots.tipMenu[type+'Unicode'], showFanRemark = user.in_fanclub && botsData.bots.tipMenu.fanClubDiscount > 0, resultString = `${unicode} ${user.user.toUpperCase()} HAS TIPPED FOR ${description.toUpperCase()}${showFanRemark?' (FANCLUB PRICE)':''}`; sendBoldNotice(everyone, resultString, botsData.bots.tipMenu.tipForegroundColor, botsData.bots.tipMenu.tipBackgroundColor); } /************* multi goal **************/ function insertInGoalList(value, goal) { const multiGoalBot = botsData.bots.multiGoal; //log(JSON.stringify(multiGoalBot)); multiGoalBot.goals.push({name: goal, value: value, times: 0}); return multiGoalBot.goals.length - 1; } function setGoal(value, goal) { const multiGoalBot = botsData.bots.multiGoal; multiGoalBot.goals = [{name: goal, value: value}]; multiGoalBot.index = 0; multiGoalBot.currentGoalsListSum = 0; } /************* lovense **************/ /////////////////////// // commands feedback // /////////////////////// function sendTipMenuBroadcastOff( user ) { var tipMenuBot = botsData.bots.tipMenu, resultString = 'The tip menu will not be shown to the users'; sendCommandFeedback(user, resultString); } function sendTipMenuBroadcastOn( user, minutes ) { var tipMenuBot = botsData.bots.tipMenu, resultString = 'The tip menu will be shown to the users every ' + minutes + ' minutes' ; sendCommandFeedback(user, resultString); } function sendTipMenuFormat( user, format ) { var tipMenuBot = botsData.bots.tipMenu, resultString = 'The tip menu will be shown to the users as a ' + format ; sendCommandFeedback(user, resultString); } function broadcastTipMenu() { sendTipMenu ( everyone ); } function broadcastTipMenuNotice() { var tipMenuBot = botsData.bots.tipMenu; sendBoldNoticeInverse(everyone, `My tip menu is enabled. Type /menu to see it.`, tipMenuBot.foregroundColor, tipMenuBot.backgroundColor); } function broadcastTipMenuTimeout() { var tipMenuBot = botsData.bots.tipMenu; if (tipMenuBot.noticeTimeoutCounter != 0){ broadcastTipMenuNotice(); tipMenuBot.noticeTimeoutCounter = (tipMenuBot.noticeTimeoutCounter < tipMenuBot.noticeTimeoutTimes) ? tipMenuBot.noticeTimeoutCounter + 1 : 0; }else{ broadcastTipMenu(); tipMenuBot.noticeTimeoutCounter = 1; } tipMenuBot.timeout > 0 && (tipMenuBot.timeoutId = cb.setTimeout(broadcastTipMenuTimeout, tipMenuBot.noticeTimeout * 1000)); } //-- Happy time --// function discountPrice(amount, user) { var tipMenuBot = botsData.bots.tipMenu, isHappyTime = tipMenuBot.happyTimeTriggered, isFan = user ? user.in_fanclub : false; if (isHappyTime && isFan){ return fanPrice(amount) > happyTimePrice(amount)? happyTimePrice(amount) : fanPrice(amount); } if (isHappyTime){ return happyTimePrice(amount); } if (isFan){ return fanPrice(amount); } return amount; } function sendHappyTimeTriggeredNotice() { var tipMenuBot = botsData.bots.tipMenu, timeLeft = Math.ceil((tipMenuBot.happyTimeEnd - Date.now()) / 1000), msg = `Happy time is on for the next ${timeLeft} seconds!. Everything in the tip menu has a discount of ${tipMenuBot.happyTimeDiscount}% !!!`; sendBoldNotice('', msg, colors.white, tipMenuBot.foregroundColor); } function sendHappyTimeInfoNotice() { var tipMenuBot = botsData.bots.tipMenu, timeLeft = Math.ceil((tipMenuBot.happyTimeEnd - Date.now()) / 1000), msg = `Happy time is on for the next ${timeLeft} seconds!. Everything in the tip menu has a discount of ${tipMenuBot.happyTimeDiscount}% !!!`; sendBoldNotice('', msg, colors.white, tipMenuBot.foregroundColor); tipMenuBot.happyTimeElapsedTimeoutId = cb.cancelTimeout(tipMenuBot.happyTimeElapsedTimeoutId); if (timeLeft > 30) { tipMenuBot.happyTimeElapsedTimeoutId = cb.setTimeout(sendHappyTimeInfoNotice, 30 * 1000); } } function enableHappyTime() { var tipMenuBot = botsData.bots.tipMenu, message, message1 = `Happy time is enabled${lineBreak}Tip ${tipMenuBot.happyTimeTriggerTip} tokens to start it up for ${tipMenuBot.happyTimeLength} seconds`, message2 = `Happy time is enabled but the tip menus are disable temporarily`; tipMenuBot.happyTimeTimeoutId = undefined; tipMenuBot.happyTimeTimeoutId = undefined; tipMenuBot.happyTimeEnd = 0; tipMenuBot.happyTimeTriggered = false; tipMenuBot.happyTimeEnabled = true; message = tipMenuBot.status != Status.RUNNING || (!tipMenuBot.showNormalMenu && !tipMenuBot.showFitMenu)?message2:message1; sendBoldNotice('', message , colors.white, tipMenuBot.foregroundColor); } function disableHappyTime() { var tipMenuBot = botsData.bots.tipMenu; tipMenuBot.happyTimeTimeoutId && (tipMenuBot.happyTimeTimeoutId = cb.cancelTimeout(tipMenuBot.happyTimeTimeoutId)); tipMenuBot.happyTimeElapsedTimeoutId && (tipMenuBot.happyTimeElapsedTimeoutId = cb.cancelTimeout(tipMenuBot.happyTimeElapsedTimeoutId)); tipMenuBot.happyTimeTriggered = false; tipMenuBot.happyTimeEnabled = false; sendBoldNotice('', 'Happy time has been turned off', tipMenuBot.foregroundColor, tipMenuBot.backgroundColor); } function enableFanClubDiscount() { var tipMenuBot = botsData.bots.tipMenu; tipMenuBot.fanClubDiscount = (tipMenuBot.fanClubDiscount > 0 && tipMenuBot.fanClubDiscount < 100)? tipMenuBot.fanClubDiscount : defaultSettings.fanClubDiscount ; sendBoldNotice('', 'Fan club discount is set to ' + tipMenuBot.fanClubDiscount + '%', tipMenuBot.foregroundColor, tipMenuBot.backgroundColor); } function disableFanClubDiscount() { var tipMenuBot = botsData.bots.tipMenu; tipMenuBot.fanClubDiscount = 0 ; sendBoldNotice('', 'Fan club discount has been turned off', tipMenuBot.foregroundColor, tipMenuBot.backgroundColor); } function triggerHappyTime() { var tipMenuBot = botsData.bots.tipMenu, now = Date.now(); tipMenuBot.happyTimeEnd = tipMenuBot.happyTimeEnd - now < 0 ? now + tipMenuBot.happyTimeLength * 1000 : tipMenuBot.happyTimeEnd + tipMenuBot.happyTimeLength * 1000; tipMenuBot.happyTimeTriggered = true; tipMenuBot.happyTimeTimeoutId && (tipMenuBot.happyTimeTimeoutId = cb.cancelTimeout(tipMenuBot.happyTimeTimeoutId)); tipMenuBot.happyTimeTimeoutId = cb.setTimeout(finishHappyTime, tipMenuBot.happyTimeEnd - now); sendHappyTimeTriggeredNotice(); if (tipMenuBot.happyTimeLength > 30) { tipMenuBot.happyTimeElapsedTimeoutId && (tipMenuBot.happyTimeElapsedTimeoutId = cb.cancelTimeout(tipMenuBot.happyTimeElapsedTimeoutId)); tipMenuBot.happyTimeElapsedTimeoutId = cb.setTimeout(sendHappyTimeInfoNotice, 30 * 1000); } } function finishHappyTime() { var tipMenuBot = botsData.bots.tipMenu; tipMenuBot.happyTimeTimeoutId && (tipMenuBot.happyTimeTimeoutId = cb.cancelTimeout(tipMenuBot.happyTimeTimeoutId)); tipMenuBot.happyTimeElapsedTimeoutId && (tipMenuBot.happyTimeElapsedTimeoutId = cb.cancelTimeout(tipMenuBot.happyTimeElapsedTimeoutId)); tipMenuBot.happyTimeTriggered = false; sendBoldNotice('', `Happy time is over! tip ${tipMenuBot.happyTimeTriggerTip} tokens to start for another ${tipMenuBot.happyTimeLength} seconds!!!`, colors.white , tipMenuBot.foregroundColor); } //////////////// // multigoal // //////////////// function updateMultiGoal(user, amount) { const multiGoalBot = botsData.bots.multiGoal; let newGoal, newRemainder goalText = '', newCurrentGoalsListSum = multiGoalBot.currentGoalsListSum + amount; if (multiGoalBot.status == Status.RUNNING){ //log(JSON.stringify({newListSum: newCurrentGoalsListSum})); multiGoalBot.currentGoalsListSum = newCurrentGoalsListSum; multiGoalBot.totalSum += amount; const newData = getMultiGoalIndex(newCurrentGoalsListSum); //log(JSON.stringify({newIndex: newData.index, newAmount: newData.amount})); if (newData.index > multiGoalBot.index){ findReachedGoals(user, multiGoalBot.index, newData.index); sendReachedGoals(user); if (!multiGoalBot.repeat && !multiGoalBot.goals[newData.index]) { sendBoldNotice('',`There are no more goals to reach!!`, colors.white , multiGoalBot.foregroundColor); cb.changeRoomSubject(`${botsData.bots.roomSubject}`); multiGoalBot.status = Status.STOPPED; return; } } multiGoalBot.index = newData.index; if (newData.index >= 0){ newGoal = multiGoalBot.goals[multiGoalBot.index % multiGoalBot.goals.length]; newRemainder = newGoal.value - newData.amount; multiGoalBot.remainder = newRemainder; goalText = ` :: ${newGoal.name} [${newRemainder} tokens left]`; } cb.changeRoomSubject(`${botsData.bots.roomSubject}${goalText}`); //log(JSON.stringify(multiGoalBot.goals)); } } function findReachedGoals(user, oldIndex, newIndex) { const multiGoalBot = botsData.bots.multiGoal; while (oldIndex < newIndex) { if (!multiGoalBot.goalsBucket.pending[multiGoalBot.goals[oldIndex % multiGoalBot.goals.length].name]) multiGoalBot.goalsBucket.pending[multiGoalBot.goals[oldIndex % multiGoalBot.goals.length].name] = 0; multiGoalBot.goalsBucket.pending[multiGoalBot.goals[oldIndex % multiGoalBot.goals.length].name] +=1; oldIndex++; } } function sendReachedGoals(user) { const multiGoalBot = botsData.bots.multiGoal; for (var goal in multiGoalBot.goalsBucket.pending){ if(multiGoalBot.goalsBucket.pending.hasOwnProperty(goal)) sendBoldNotice('', `${user.user} has reached goal ${goal.toUpperCase()} ${multiGoalBot.goalsBucket.pending[goal]} time${multiGoalBot.goalsBucket.pending[goal]>1?'s':''}!!!`, colors.white , multiGoalBot.foregroundColor); if (!multiGoalBot.goalsBucket.done[goal]) multiGoalBot.goalsBucket.done[goal] = 0; multiGoalBot.goalsBucket.done[goal] += multiGoalBot.goalsBucket.pending[goal]; } multiGoalBot.goalsBucket.pending = {}; } function getMultiGoalIndex(amount) { const multiGoalBot = botsData.bots.multiGoal; let index = 0; while (amount > 0) { if (multiGoalBot.goals[index % multiGoalBot.goals.length].value > amount){ return {index, amount}; } else { amount -= multiGoalBot.goals[index % multiGoalBot.goals.length].value; index += 1; } } return {index, amount}; } function broadcastMultiGoal() { const multiGoalBot = botsData.bots.multiGoal, name = multiGoalBot.goals[multiGoalBot.index % multiGoalBot.goals.length].name; sendBoldNotice(everyone, `Current goal is ${name} [${multiGoalBot.remainder} tokens left]`, colors.orange, ''); } function broadcastMultiGoalTimeout() { var multiGoalBot = botsData.bots.multiGoal; broadcastMultiGoal(); multiGoalBot.noticeTimeout > 0 && multiGoalBot.status == Status.RUNNING && (multiGoalBot.timeoutId = cb.setTimeout(broadcastMultiGoalTimeout, multiGoalBot.noticeTimeout * 1000)); } //////////////// // lovense // //////////////// function sendLovenseMenu(message) { if (message == everyone) message = {user:'', is_mod: false, in_fanclub: false}; var resultString = '', lovenseMenuBot = botsData.bots.lovense, icon = lovenseMenuBot.lush.icon || '*', lovenseLevels = lovenseMenuBot.lush.levels, lovenseSpecialCommands = lovenseMenuBot.lush.specialCommands; (lovenseLevels.length > 0 || lovenseSpecialCommands.length > 0) && (resultString = `${lineBreak} MY LOVENSE LUSH VIBRATOR IS SET TO REACT TO YOUR TIPS. HERE ARE ${lovenseLevels.length} LEVELS OF INTENSITY.`); lovenseLevels.forEach(function(item, index, array){ var indexPrefix = ((message.user == cb.room_slug) || message.is_mod) ? '-[ ' + index +' ]- ' :''; resultString += `${lineBreak} ${icon} ${indexPrefix} ${item.description}: Tip (${item.min} - ${array[index+1]?array[index+1].min-1:item.min + '+'}) ${item.time} seconds (${item.power} vibrations)`; // TODO add more unicodes here }); lovenseSpecialCommands.forEach(function(item, index, array){ var indexPrefix = ((message.user == cb.room_slug) || message.is_mod) ? '-[ ' + index +' ]- ' :''; resultString += index == 0 ? `${lineBreak}${lineBreak} THESE ARE MY SPECIAL COMMANDS` : ''; resultString += `${lineBreak} ${icon} ${indexPrefix} ${item.amount} tokens: ${item.description} for ${item.time} seconds.`; // TODO add more unicodes here }); if (resultString.length == 0) { resultString = "The lovense menu is empty"; sendBoldNotice(message.user, resultString, lovenseMenuBot.foregroundColor, lovenseMenuBot.backgroundColor); return; } sendBoldNotice(message.user, resultString + lineBreak, lovenseMenuBot.foregroundColor, lovenseMenuBot.backgroundColor); } function sendLovenseNotice(username, time, description) { var lovenseMenuBot = botsData.bots.lovense; sendBoldNotice(everyone, `Thank you ${username}! my ${lovenseMenuBot.lush.icon} will vibrate for you for ${time} seconds!!`, lovenseMenuBot.foregroundColor, lovenseMenuBot.backgroundColor); } function broadcastLovenseNotice() { var lovenseMenuBot = botsData.bots.lovense; sendBoldNotice(everyone, `My Lovense toy menu is enabled. Type /lm to see it.`, lovenseMenuBot.foregroundColor, lovenseMenuBot.backgroundColor); } function broadcastLovenseMenu() { sendLovenseMenu ( everyone ); } function broadcastLovenseMenuTimeout() { var lovenseMenuBot = botsData.bots.lovense; // if (lovenseMenuBot.noticeTimeoutCounter < lovenseMenuBot.noticeTimeoutTimes){ // broadcastLovenseNotice(); // lovenseMenuBot.noticeTimeoutCounter = (lovenseMenuBot.noticeTimeoutCounter < lovenseMenuBot.noticeTimeoutTimes) ? lovenseMenuBot.noticeTimeoutCounter + 1 : 0; // }else{ // broadcastLovenseMenu(); // } //tusset 8 broadcastLovenseMenu(); lovenseMenuBot.noticeTimeout > 0 && (lovenseMenuBot.timeoutId = cb.setTimeout(broadcastLovenseMenuTimeout, lovenseMenuBot.noticeTimeout * 1000)); } ////////// // Init // ////////// function init() { botsData.foregroundColor = defaultSettings.foregroundColor; botsData.backgroundColor = defaultSettings.backgroundColor; botsData.commandFeedbackForegroundColor = defaultSettings.commandFeedbackForegroundColor; botsData.commandFeedbackBackgroundColor = defaultSettings.commandFeedbackBackgroundColor; botsData.start = new Date().getTime(); initBots(); } function initBots() { initMultiGoalBot(); initTippersBot(); initRoomSubject(); initFitMenuBot(); initLovenseMenu(); } function initMultiGoalBot() { var multiGoalBot = botsData.bots.multiGoal, defaults = defaultSettings.multiGoal; multiGoalBot.noticeTimeoutTimes = defaults.noticeTimeoutTimes; multiGoalBot.noticeTimeoutCounter = 0; multiGoalBot.repeat = defaults.repeat; // status settings if (cb.settings.multiGoalEnabled == 'yes') { multiGoalBot.enabled = true; multiGoalBot.status = Status.RUNNING; } // UI settings multiGoalBot.foregroundColor = defaults.foregroundColor || ''; multiGoalBot.backgroundColor = defaults.backgroundColor || ''; // parse and load multi goals multiGoalBot.goals = cb.settings.multiGoalList || ''; multiGoalBot.goals = multiGoalBot.goals.split(/\s*\:\s*/).map(goal => { let valueRegExp = /\[\s*(\d+)\s*\]/, valueArr = valueRegExp.exec(goal), value, name; if (valueArr) { value = parseInt(valueArr[1]), name = goal.replace(valueRegExp,'').trim(); } return {name, value, 'times' : 0}; }); multiGoalBot.index = 0; multiGoalBot.remainder = 0; multiGoalBot.totalSum = 0; multiGoalBot.currentGoalsListSum = 0; // set timeout and launch var timeout = parseInt(defaults.noticeTimeout); multiGoalBot.noticeTimeout = (isNaN(timeout) || timeout <= 0 )? 0 : timeout; broadcastMultiGoalTimeout(); } function initTippersBot() { var tippersBot = botsData.bots.tippers, defaults = defaultSettings.tippers; tippersBot.status = Status.RUNNING; tippersBot.foregroundColor = defaults.foregroundColor ; tippersBot.backgroundColor = defaults.backgroundColor ; tippersBot.unicode = defaults.unicode; tippersBot.emotes.kingTipper = defaults.emotes.kingTipper; tippersBot.emotes.bombTipper = defaults.emotes.bombTipper; tippersBot.minBombTip = defaults.bombTipperMinValue; tippersBot.prependTipCount = false; } function initLovenseMenu() { const defaults = defaultSettings.lovense, lovenseMenuBot = botsData.bots.lovense; lovenseMenuBot.noticeTimeoutTimes = defaults.noticeTimeoutTimes; lovenseMenuBot.noticeTimeoutCounter = 0; // status settings if (cb.settings.lovenseMenuEnabled == 'yes') { lovenseMenuBot.enabled = true; lovenseMenuBot.status = Status.RUNNING; } // UI settings lovenseMenuBot.foregroundColor = defaults.foregroundColor || ''; lovenseMenuBot.backgroundColor = defaults.backgroundColor || ''; for ( var i = 0; i < MAX_LOVENSE_MENU_ITEMS; i++ ) { var description = cb.settings["lovenseMenuItemDescription" + i] ? cb.settings["lovenseMenuItemDescription" + i].trim() : '', amount = cb.settings["lovenseMenuItemAmount" + i] ? parseInt(cb.settings["lovenseMenuItemAmount" + i]) : '', time = cb.settings["lovenseMenuItemTime" + i] ? parseInt(cb.settings["lovenseMenuItemTime" + i]) : '', power = cb.settings["lovenseMenuItemPower" + i] ? cb.settings["lovenseMenuItemPower" + i] : ''; if ( description.length > 0 && !isNaN(amount) && amount > 0 && !isNaN(time) && time > 0 && power.length > 0 ) { lovenseMenuBot.lush.levels.push({description: description, time: time, min: amount, power: power, times:0}); } } for ( var i = 0; i < MAX_LOVENSE_COMMANDS_MENU_ITEMS; i++ ) { var description = cb.settings["lovenseSpecialCommandDescription" + i] ? cb.settings["lovenseSpecialCommandDescription" + i].trim() : '', amount = cb.settings["lovenseSpecialCommandAmount" + i] ? parseInt(cb.settings["lovenseSpecialCommandAmount" + i]) : '', time = cb.settings["lovenseSpecialCommandTime" + i] ? parseInt(cb.settings["lovenseSpecialCommandTime" + i]) : ''; if ( description.length > 0 && !isNaN(amount) && amount > 0 && !isNaN(time) && time > 0 ) { lovenseMenuBot.lush.specialCommands.push({description: description, time: time, amount: amount, times: 0}); } } // set timeout and launch var timeout = parseInt(defaults.noticeTimeout); lovenseMenuBot.noticeTimeout = (isNaN(timeout) || timeout <= 0 )? 0 : timeout; broadcastLovenseMenuTimeout(); } function initRoomSubject() { const multiGoalBot = botsData.bots.multiGoal, roomSubject = cb.settings.roomSubject; let currentGoal, goal = ''; if (multiGoalBot.status == Status.RUNNING){ currentGoal = multiGoalBot.goals[multiGoalBot.index]; goal = ` :: ${currentGoal.name} [${currentGoal.value} tokens left]`; } botsData.bots.roomSubject = roomSubject; cb.changeRoomSubject(`${roomSubject}${goal}`); } function initFitMenuBot() { var tipMenuBot = botsData.bots.tipMenu, defaults = defaultSettings.tipMenu; tipMenuBot.noticeTimeoutTimes = defaults.noticeTimeoutTimes; tipMenuBot.noticeTimeoutCounter = 0; if (cb.settings.tipMenuEnabled == 'yes') { tipMenuBot.showFitMenu = cb.settings.showFitMenu == 'yes'; tipMenuBot.showNormalMenu = cb.settings.showNormalMenu == 'yes'; if (cb.settings.showNormalMenu == 'yes' || cb.settings.showFitMenu == 'yes'){ tipMenuBot.enabled = true; tipMenuBot.status = Status.RUNNING; } } // UI settings tipMenuBot.foregroundColor = defaults.foregroundColor || ''; tipMenuBot.backgroundColor = defaults.backgroundColor || ''; tipMenuBot.tipForegroundColor = defaults.tipForegroundColor || ''; tipMenuBot.tipBackgroundColor = defaults.tipBackgroundColor || ''; tipMenuBot.fitUnicode = defaults.fitUnicode; tipMenuBot.normalUnicode = defaults.normalUnicode; tipMenuBot.format = defaults.format; // happy time settings tipMenuBot.happyTimeEnabled = cb.settings.happyTimeEnabled == 'yes'? true : false; tipMenuBot.happyTimeLength = parseInt(cb.settings.happyTimeLength) || undefined; tipMenuBot.happyTimeTriggerTip = parseInt(cb.settings.happyTimeTriggerTip) || undefined; tipMenuBot.happyTimeDiscount = parseInt(cb.settings.happyTimeDiscount) || undefined; tipMenuBot.happyTimeTriggered = false; tipMenuBot.fanClubDiscount = (cb.settings.fanClubDiscount && !isNaN(parseInt(cb.settings.fanClubDiscount))) ? parseInt(cb.settings.fanClubDiscount) : defaults.fanClubDiscount; // parse menu items let itemsCount = 0; for (var key in cb.settings){ if(cb.settings.hasOwnProperty(key) && key.indexOf("tipMenuItemName") == 0) itemsCount++; } for ( var i = 0; i < itemsCount; i++ ) { let [first, second] = cb.settings["tipMenuItemName" + i] ? cb.settings["tipMenuItemName" + i].trim().split('|'): [], tipValue = cb.settings["tipMenuItemValue" + i] ? parseInt(cb.settings["tipMenuItemValue" + i]) : '', tipType = cb.settings["tipMenuItemType" + i], tipName = second == undefined ? first : second; if ( tipFilter(first, second) && !isNaN(tipValue) && tipValue > 0 ) { let priority = (second == undefined) ? true : (first.indexOf('-') >= 0 ? false : true); tipMenuBot.tips[tipType + "Menu"].push({value: tipValue, name: tipName, type: tipType, times: 0, priority}); } } // sort items tipMenuBot.tips.normalMenu = tipMenuBot.tips.normalMenu.sort(function(a,b) { return (a.value - b.value); }); tipMenuBot.tips.fitMenu = tipMenuBot.tips.fitMenu.sort(function(a,b) { return (a.value - b.value); }); // set timeout and launch var noticeTimeout = parseInt(defaults.noticeTimeout); tipMenuBot.noticeTimeout = (isNaN(noticeTimeout) || noticeTimeout <= 0 )? 0 : noticeTimeout; // tipMenuBot.noticeTimeout > 0 && (tipMenuBot.timeoutId = cb.setTimeout(broadcastTipMenuTimeout, 5 * 1000)); launchNotices(tipMenuBot, broadcastTipMenuTimeout, 10) } function tipFilter(first, second) { const options = (second != undefined) ? first.toLowerCase() : undefined, today = (new Date()).getDay(), days = 'dlmxjvsd'; // do not show (*) if (options && options.indexOf('*') >= 0) return false; // day-specific tip if (options && /[lmxjvsd]/.test(options)) { return options.indexOf(days[today]) >= 0; } return true; } function launchNotices(bot, func, seconds ) { const milliseconds = seconds ? seconds * 1000 : (bot.noticeTimeout > 0 ? bot.noticeTimeout : 0); bot.timeoutId && cb.cancelTimeout(bot.timeoutId); bot && milliseconds > 0 && (bot.timeoutId = cb.setTimeout(func, milliseconds)); } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.