Apps Home
|
My Uploads
|
Create an App
AIO test
Author:
onesinmiedo
Description
Source Code
Launch App
Current Users
Created by:
Onesinmiedo
App Images
const MAX_GROUPS = 4; const MAX_TIP_MENU_ITEMS = 23; const MAX_LOTTERY_PRIZES = 5; const MAX_LOVENSE_MENU_ITEMS = 8; const MAX_LOVENSE_COMMANDS_MENU_ITEMS = 5; const lineBreak = '\n'; const everyone = ''; const tippersList = {}; // status const Status = { DISABLED : -1, STOPPED : 0, RUNNING : 1, PAUSED : 2 }; // colors const colors = { orange : '#dc5500', red : '#ff0000', green : '#009900', darkpurple : '#5f497a' , lightpurple : '#be6aff', darkblue : '#1f497d', lightblue : '#6699aa', gray : '#494949', white : '#ffffff' }; const groupColors = { broadcaster : colors.orange, mods : colors.red, fans : colors.green, tip1000 : colors.darkpurple, tip250 : colors.lightpurple, tip50 : colors.darkblue, tokens : colors.lightblue, notokens : colors.gray }; // 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' }; // bots unicodes var botsUnicodes = { tippersBot : unicodeChars.square, fansBot : unicodeChars.star, clubsBot : unicodeChars.whiteHeart, tipMenuBot : unicodeChars.heart, lotteryBot : unicodeChars.whiteStar }; var defaultSettings = { backgroundColor : '', foregroundColor : colors.orange, room : { subject : 'Welcome to my secret space ', tags : ['buttplug', 'fitness', 'fit', 'athletic', 'big-boobs', 'shaved', 'anal', 'lush', 'domi'], }, lovense : { enabled : true, noticeTimeout: 90, 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}, ] } }, fanClub : { enabled : true, unicode : botsUnicodes.fansBot, inGreen : true, foregroundColor : groupColors.fans, backgroundColor : "", }, tippers : { unicode : botsUnicodes.tippersBot, prependTipCount : false, bombTipperMinValue : 1000, foregroundColor : undefined, backgroundColor : undefined, emotes : { kingTipper : ':osmking', bombTipper : ':osmbomb', } }, clubs : { enabled : true, unicode : botsUnicodes.clubsBot, noticeTimeout : 10, foregroundColor : undefined, backgroundColor : undefined, }, tipMenu : { enabled : true, unicode : botsUnicodes.tipMenuBot, happyTimeEnabled : false, happyTimeLength : 60, happyTimeTriggerTip : 1000, happyTimeDiscount : 50, fanClubDiscount : 20, noticeTimeout : 3, foregroundColor : undefined, backgroundColor : undefined, tipForegroundColor : "#FFF", tipBackgroundColor : "#090", }, lottery : { enabled : true, unicode : botsUnicodes.lotteryBot, min : 1, max : 100, noticeTimeout : 6, foregroundColor : undefined, backgroundColor : undefined, }, multiGoal : { enabled : true, unicode : undefined, tokensPerGoal : 100, foregroundColor : undefined, backgroundColor : undefined, } }; var wetBotData = { bots : { // default colors foregroundColor : '', backgroundColor : '', /////////////////////// // room title data // /////////////////////// roomSubject: undefined, /////////////////////// // lovense // /////////////////////// lovense : { foregroundColor: undefined, backgroundColor: undefined, lush: { icon: ':lushsm', levels : [], specialCommands : [], }, }, /////////////////// // fans bot data // /////////////////// fanClub : { status : Status.DISABLED, name : 'Fans bot', emote : '', tippers : {}, tipCount : 0, tipSum : 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, }, }, //////////////////// // clubs bot data // //////////////////// clubs : { status : Status.DISABLED, name : 'Clubs bot', clubs : {}, }, /////////////////////// // tip menu bot data // /////////////////////// tipMenu : { status : Status.DISABLED, name : 'Tip menu bot', fanClubDiscount : 0, discount : 0, timeoutId : undefined, noticeTimeout : undefined, history : [], items : [], happyTimeEnabled : false, happyTimeTriggered : false, happyTimeEnd : 0, happyTimeTimeoutId : undefined, happyTimeElapsedTimeoutId : undefined, happyTimeTriggerTip : 0, happyTimeLength : 0, happyTimeDiscount : 1, }, ////////////////////// // lottery bot data // ////////////////////// lottery : { status : Status.STOPPED, name : 'Lottery bot', timeoutId : undefined, noticeTimeout : undefined, min : 0, max : 0, prizes : {}, guesses : [], }, multiGoal : { status : Status.DISABLED, name : 'Multi goal bot', tokensPerGoal : 100, unicode : undefined, nextGoal : undefined, goals : [], currentGoalIndex : 0, currentGoalSum : 0, totalSum : 0, // panelBackgrounds : { // goal0 : 'cd4f72da-ff6b-473b-a3e5-f2eefb11b9b1', // goal10 : '088d2a8c-fbd5-47f2-ba67-19a101eca877', // goal20 : 'eb2b9cf3-75a1-4c60-8c79-e0c34166b32a', // goal30 : '838f1dc9-5ca0-450e-8386-d726fdd2d238', // goal40 : 'c4efa16f-d105-4c60-a3ae-27d46322c1bc', // goal50 : '195ba852-bc0f-40be-ac94-46a0e4f63035', // goal60 : 'fcc09ed1-85f9-489b-b067-9a8b6b30d536', // goal70 : '9069e515-2f6d-4eda-8400-9cb9c454a356', // goal80 : '7fcd77a9-540b-432c-a3f4-41ebc19e0d3d', // goal90 : 'c5b962ae-4105-4275-b206-fb257ae2fc98', // goal100 : '5af755eb-dc64-43cb-a084-f8df167db3c7', // king0 : '904bdd8a-7c49-460f-b11b-6984e167b994', // king10 : '3f11007d-df53-4e78-ad5e-ea3a209a8b26', // king20 : '07daa92f-8208-40cc-a225-77c9fa8443ee', // king30 : 'd7f22f36-50a1-4b6e-b7eb-0a808b8de25c', // king40 : '6f3dbe06-ae5e-4265-95ff-8e97fe8cc29f', // king50 : 'af48a411-ed96-4437-9b3f-a6de2497716b', // king60 : '728fb0c0-984d-4302-98ca-84e79e0fbe29', // king70 : 'd29a609b-718a-4eb1-be9e-63d390a3b2f9', // king80 : '81a725d6-12bf-484a-8767-fbaa5d6dc5bf', // king90 : '14d44490-dfe7-416d-ac1e-c9d78cbf30c5', // king100 : 'f94a457b-9988-4be7-8da0-4b9459f1092c', // } panelBackgrounds : { goal0 : '4ad5285e-9cb4-4731-9abc-c72abb0e061c', goal10 : 'fe9bdd41-2d9d-4312-8254-213af6c78781', goal20 : 'cc862331-27c1-4205-9249-b4f289091af9', goal30 : '2a0f97de-b5d0-4569-9503-c2179a83484f', goal40 : 'f46254d5-fa94-405f-a019-35446d8325d7', goal50 : 'e6eb0679-accb-4489-9af3-b0fe463f2883', goal60 : '38c63774-cb0b-4efb-9b01-40d848a38199', goal70 : '5f4dbebc-b152-437f-881d-7d5710304477', goal80 : '05ee392a-0011-46f2-9af8-187d633fbfb0', goal90 : '26c3954d-7519-436f-8176-268016c11de9', goal100 : '843efaf6-6764-4b1b-adf5-3c7a1607ecd3', king0 : '59b919de-9c00-4903-b87a-02c8f09704c0', king10 : 'bdcfae57-2346-4ee3-a56b-3191521381da', king20 : '02701011-591f-4ac3-bfa8-5e6f9730f61b', king30 : '3ecba283-26b5-47c3-8ddb-997a777e85dd', king40 : 'caebbaaa-4442-4e5d-aa0c-6fcab7110231', king50 : '97950ff4-927d-4c96-9f20-feb9223f978a', king60 : 'e2fc8bda-5015-4e4d-a6d4-5af1f453b0ee', king70 : '74bb9d2e-b2c6-4c2f-8618-7205ccc0af52', king80 : 'b81f0e5e-ad6f-47a4-adb6-1415e15de53a', king90 : '67a11cb4-812a-4386-ab13-046cafd54416', king100 : '13e99ba9-2487-4db9-a0e0-98f8ad1a0bf9', } } }, foregroundColor : colors.gray, backgroundColor : '', start : 0, commandsConfig : { "/help" : { cmd: "help" }, "/wet" : { cmd: "help" }, "/tipper" : { cmd: "tippers" }, "/clubb" : { cmd: "clubs all" }, "/club" : { cmd: "clubs" }, "/fan" : { cmd: "fans" }, "/tmb" : { cmd: "tipmenu all" }, "/tm" : { cmd: "tipmenu" }, "/tipmenu" : { cmd: "tipmenu" }, "/menu" : { cmd: "tipmenu" }, "/lotb" : { cmd: "lottery all" }, "/lot" : { cmd: "lottery" }, "/title": { cmd: "title" }, "/tag": { cmd: "title tag" }, }, helpMessages : { tippers : [ ['bmr', repeat(botsUnicodes.tippersBot,5) + ' COMMANDS FOR THE TIP BOT ' + repeat(botsUnicodes.tippersBot,5) ], ['bmr', botsUnicodes.tippersBot + ' /tipper help : shows this help text' ], ['bmr', botsUnicodes.tippersBot + ' /tipper : shows the ordered list of tippers' ], ['bmr', botsUnicodes.tippersBot + ' /tipper bomb : shows the tipper who gave the higgest tip' ], // ['bmr', botsUnicodes.tippersBot + ' /tipper prefix off : stop showing user tip counter' ], // ['bmr', botsUnicodes.tippersBot + ' /tipper prefix on : start showing user tip counter' ], ['bmr', botsUnicodes.tippersBot + ' /tipper king : shows the tipper who gave most tokens since the bot started' ] ], clubs : [ ['bmr', repeat(botsUnicodes.clubsBot,5) + ' COMMANDS FOR THE CLUBS BOT' + repeat(botsUnicodes.clubsBot,5) ], ['bmr', botsUnicodes.clubsBot + ' "/club help" : shows this help text'], ['bm', botsUnicodes.clubsBot + ' "/club " : shows the list of clubs and their members'], ['bm', botsUnicodes.clubsBot + ' "/club info" : shows the list of clubs available for joining and their joining fee'], ['r', botsUnicodes.clubsBot + ' "/club" : shows the list of clubs available for joining and their joining fee'], // ['bm', botsUnicodes.clubsBot + ' /club list <club>: shows the list of members in <club>'], ['bm', botsUnicodes.clubsBot + ' "/club user <username>" : shows the list of clubs that <username> is a member of'], ['bm', botsUnicodes.clubsBot + ' "/clubb" : shows the clubs info to everyone'], ['bm', botsUnicodes.clubsBot + ' "/clubb off" : stops the clubs info periodic notice'], ['bm', botsUnicodes.clubsBot + ' "/clubb on <minutes>" : shows the clubs info to everyone every <minutes> minutes'] ], fans : [ ['bm', repeat(botsUnicodes.fansBot,5) + ' COMMANDS FOR THE FANS BOT' + repeat(botsUnicodes.fansBot,5) ], ['bm', botsUnicodes.fansBot + ' "/fans help" : shows this help text'], ['bm', botsUnicodes.fansBot + ' "/fans" : shows the list of fans and their tips'] ], tipMenu : [ ['bmr', repeat(botsUnicodes.tipMenuBot,5) + ' COMMANDS FOR THE TIP MENU BOT' + repeat(botsUnicodes.tipMenuBot,5) ], ['bmr', botsUnicodes.tipMenuBot + ' "/tm help" : shows this help text'], ['bmr', botsUnicodes.tipMenuBot + ' "/tm or /tipmenu" : shows the tip menu'], ['bm', botsUnicodes.tipMenuBot + ' "/tm history" : shows the tip menu history'], ['bm', botsUnicodes.tipMenuBot + ' "/tm count" : shows the tip menu counter'], ['bm', botsUnicodes.tipMenuBot + ' "/tm rm <index>" : Removes from the menu the item with the index <index>'], ['bm', botsUnicodes.tipMenuBot + ' "/tm add <amount> <description>" : adds a new item to the tip menu'], ['bm', botsUnicodes.tipMenuBot + ' "/tm off" : stops tip menu bot'], ['bm', botsUnicodes.tipMenuBot + ' "/tm on" : starts the tip menu bot if it is not running'], ['bm', botsUnicodes.tipMenuBot + ' "/tm happy on" : enable happy time feature'], ['bm', botsUnicodes.tipMenuBot + ' "/tm happy off" : disable happy time feature'], // broadcast messages ['bm', botsUnicodes.tipMenuBot + ' "/tmb" : shows the tip menu to everyone'], ['bm', botsUnicodes.tipMenuBot + ' "/tmb off" : stops the tip menu periodic notice'], ['bm', botsUnicodes.tipMenuBot + ' "/tmb on <minutes>" : shows the tip 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'], ], lottery : [ ['bmr', repeat(botsUnicodes.lotteryBot,5) + ' COMMANDS FOR THE LOTTERY BOT' + repeat(botsUnicodes.lotteryBot,5) ], ['bmr', botsUnicodes.lotteryBot + ' "/lot help" : shows this help text'], ['bmr', botsUnicodes.lotteryBot + ' "/lot" : shows the lottery info'], ['b' , botsUnicodes.lotteryBot + ' "/lot prizes" : shows where the lottery prizes are'], ['bmr', botsUnicodes.lotteryBot + ' "/lot numbers": shows the lottery numbers'], ['bm' , botsUnicodes.lotteryBot + ' "/lot restart": restarts the lottery'], ['bm', botsUnicodes.lotteryBot + ' "/lot off" : stops the lottery bot'], ['bm', botsUnicodes.lotteryBot + ' "/lot on" : starts the lottery bot if it is not running'], // broadcast messages ['bm' , botsUnicodes.lotteryBot + ' "/lotb" : shows the lottery info (available prizes) to everyone'], ['bm' , botsUnicodes.lotteryBot + ' "/lotb off" : stops the lottery periodic notice'], ['bm' , botsUnicodes.lotteryBot + ' "/lotb on <minutes>": shows the lottery to everyone every <minutes> minutes'] ] }, welcomeMessages : [ ['', ' Welcome to my room $user ! :mclap'], ['', ' > type /lot for the lottery info'], ['', ' > type /tm or /tipmenu for my tip menu'], ['', ' > type /club for clubs info'], ['', ' > type /tipper for the tippers list'], ['m', ' > type /help or /wet for a full list of available commands'], ], }; 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}; } cb["settings_choices"] = [ { name : "roomSubject", label : "1) *** TITULO DEL CHAT **************************************", type : "str", minLength : 10, maxLength : 255, defaultValue : defaultSettings.room.subject + defaultSettings.room.tags.map((item) => {return `#${item}`}).join(' '), required : false }, { name : "fanClubEnabled", label : "1) FAN CLUB SETTINGS .................... Enable fan club bot ", type : "choice", choice1 : "yes", choice2 : "no", default : defaultSettings.fanClub.enabled ? "yes" : "no", required: true, }, { name : "fansInGreen", label : "Show fan's messages in green", type : "choice", choice1 : "yes", choice2 : "no", default : defaultSettings.fanClub.inGreen ? "yes" : "no", required: true, }, { name : "bombTipperMinValue", label : "2) TIP BOT SETTINGS ................... minimum value for a tip to be considered a bomb ", type : "str", minLength : 0, maxLength : 25, default : defaultSettings.tippers.bombTipperMinValue, required : true }, { name : "prependTipCount", label : "Prepend tip count to user messages ", type : "choice", choice1 : "yes", choice2 : "no", default : defaultSettings.tippers.prependTipCount? "yes" : "no", required : true, }, { name : "clubsBotEnabled", label : "3) CLUBS BOT SETTINGS ............. Clubs bot enabled", type : "choice", choice1 : "yes", choice2 : "no", default : defaultSettings.clubs.enabled ? "yes" : "no", required: true, } ]; for(var i = 0; i < MAX_GROUPS; i++) { cb.settings_choices.push({ name : "clubName" + i, label : "club " + (i+1) + " name --------------> ", type : "str", minLength : 4, maxLength : 30, default : "", required : false }); cb.settings_choices.push({ name : "clubMemebers" + i, label : "club members separated by commas (optional) " , type : "str", minLength : 4, maxLength : 255, default : "", required : false }); cb.settings_choices.push({ name : "clubFee" + i, label : "club fee ", type : "str", minLength : 2, maxLength : 250, default : "", required : false }); } cb.settings_choices.push( { name : "tipMenuEnabled", label : "4) TIP MENU BOT SETTINGS (Only items with a description and price will be considered) ............................................. Tip menu enabled ", type : "choice", choice1 : 'yes', choice2 : 'no', default : defaultSettings.tipMenu.enabled ? "yes" : "no", required : true }, { name : "happyTimeEnabled", label : "Enable happy time feature ", type : "choice", choice1 : "yes", choice2 : "no", default : defaultSettings.tipMenu.happyTimeEnabled ? "yes" : "no", required : true, }, { name : "happyTimeLength", label : "Happy time length in seconds (30 - 300)", type : "int", minValue : 30, maxValue : 300, default : defaultSettings.tipMenu.happyTimeLength, required : false }, { name : "happyTimeTriggerTip", label : "Tip amount that triggers the happy time ", type : "int", minValue : 0, maxValue : 10000, default : defaultSettings.tipMenu.happyTimeTriggerTip, required : false }, { name : "happyTimeDiscount", label : "Sale % to apply to price (0 - 100)", type : "int", minValue : 0, maxValue : 100, default : defaultSettings.tipMenu.happyTimeDiscount, required : false }, { name : "fanClubDiscount", label : "Sale % to apply to price for fan club members (0 - 100) ", type : "int", minValue : 0, maxValue : 100, default : defaultSettings.tipMenu.fanClubDiscount, required : false } ); for(i = 0; i < MAX_TIP_MENU_ITEMS; i++) { cb.settings_choices.push({ name : "tipMenuItemDescription" + i, label : " menu item " + (i+1) + " description -----------------> ", type : "str", minLength : 3, maxLength : 255, default : "", required : false }, { name : "tipMenuItemAmount" + i, label : "menu item " + (i+1) + " price ", type : "str", minLength : 1, maxLength : 255, default : "", required : false }); } cb.settings_choices.push({ name : "lotteryEnabled", label : "5) LOTTERY BOT SETTINGS (Only items with a description and amount will be considered) .................. Lottery enabled ", type : "choice", choice1 : 'yes', choice2 : 'no', default : defaultSettings.lottery.enabled ? "yes" : "no", required : true }, { name : "lotteryMin", label : "Lottery bottom number ", type : "str", minLength : 1, maxLength : 3, default : defaultSettings.lottery.min, required : false }, { name : "lotteryMax", label : "Lottery top number ", type : "str", minLength : 1, maxLength : 3, default : defaultSettings.lottery.max, required : false }); for(i = 0; i < MAX_LOTTERY_PRIZES; i++) { cb.settings_choices.push({ name : "lotteryPrizeDescription" + i, label : " lottery prize " + (i+1) + " description ----------------> ", type : "str", minLength : 3, maxLength : 255, default : "", required : false }, { name : "lotteryPrizeAmount" + i, label : "amount of prizes " + (i+1) + " ", type : "str", minLength : 1, maxLength : 255, default : "", required : false }); } cb.settings_choices.push({ name : "multiGoalEnabled", label : "5) MULTI-GOAL BOT SETTINGS .................. Multi-Goal enabled ", type : "choice", choice1 : 'yes', choice2 : 'no', default : defaultSettings.multiGoal.enabled ? "yes" : "no", required : true }, { name : "tokensPerGoal", label : "Tokens per goal", type : "str", minLength : 0, maxLength : 255, default : defaultSettings.multiGoal.tokensPerGoal, required : false }); ////////////////////////////////////// // welcome and help message methods // ////////////////////////////////////// function getWelcomeMessage(user) { let resultString = lineBreak; wetBotData.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 getTippersHelp(message) + getClubsHelp(message) + getFansHelp(message) + getTipMenuHelp(message) + getLotteryHelp(message); } function getTippersHelp(message) { let resultString = lineBreak; const isBroadcaster = (message.user == cb.room_slug), isMod = message.is_mod; wetBotData.helpMessages.tippers.forEach(function(item){ if(item[0].length == 0 || item[0].indexOf("m") >= 1 && isMod || item[0].indexOf("b") >= 0 && isBroadcaster || item[0].indexOf("r") >= 0 && (!isBroadcaster && !isMod)) resultString += item[1] + lineBreak ; }); return resultString.trim().length == 0 ? '' : resultString; } function getClubsHelp(message) { var resultString = lineBreak; const isBroadcaster = (message.user == cb.room_slug), isMod = message.is_mod; wetBotData.helpMessages.clubs.forEach(function(item){ if(item[0].length == 0 || item[0].indexOf("m") >= 1 && isMod || item[0].indexOf("b") >= 0 && isBroadcaster || item[0].indexOf("r") >= 0 && (!isBroadcaster && !isMod)) resultString += item[1] + lineBreak ; }); return resultString.trim().length == 0 ? '' : resultString; } function getFansHelp(message) { var resultString = lineBreak; const isBroadcaster = (message.user == cb.room_slug), isMod = (message.is_mod); wetBotData.helpMessages.fans.forEach(function(item){ if(item[0].length == 0 || item[0].indexOf("m") >=0 && isMod || item[0].indexOf("b") >= 0 && isBroadcaster || item[0].indexOf("r") >= 0 && (!isBroadcaster && !isMod)) resultString += item[1] + lineBreak ; }); return resultString.trim().length == 0 ? '' : resultString; } function getTipMenuHelp(message) { var resultString = lineBreak; const isBroadcaster = (message.user == cb.room_slug), isMod = message.is_mod; wetBotData.helpMessages.tipMenu.forEach(function(item){ if(item[0].length == 0 || item[0].indexOf("m") >= 0 && isMod || item[0].indexOf("b") >= 0 && isBroadcaster || item[0].indexOf("r") >= 0 && (!isBroadcaster && !isMod)) resultString += item[1] + lineBreak ; }); return resultString.trim().length == 0 ? '' : resultString; } function getLotteryHelp(message) { var resultString = lineBreak; const isBroadcaster = (message.user == cb.room_slug), isMod = message.is_mod; wetBotData.helpMessages.lottery.forEach(function(item){ if(item[0].length == 0 || item[0].indexOf("m") >= 0 && isMod || item[0].indexOf("b") >= 0 && isBroadcaster || item[0].indexOf("r") >= 0 && (!isBroadcaster && !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); user.in_fanclub && sendFanMemberNotice(user); }); /** 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){ const bombTipper = wetBotData.bots.tippers.bombTip > 0 ? `(${wetBotData.bots.tippers.bombTipper})` : '', kingTipper = wetBotData.bots.tippers.kingTipperSum > 0 ? `(${wetBotData.bots.tippers.kingTipper})` : ''; if (wetBotData.bots.multiGoal.status == Status.RUNNING) return drawMultiGoalPanel(); return { 'template': '3_rows_of_labels', 'row1_label': 'Tokens Received:', 'row1_value': `${wetBotData.bots.tippers.tipSum} (${wetBotData.bots.tippers.tipCount} tips)`, 'row2_label': `Bomb Tip (>${wetBotData.bots.tippers.minBombTip}):`, 'row2_value': `${wetBotData.bots.tippers.bombTip} ${bombTipper}`, 'row3_label': 'King Tipper:', 'row3_value': `${wetBotData.bots.tippers.kingTipperSum} ${kingTipper}`, }; }); /** 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 prefix = "", tippersBot = wetBotData.bots.tippers, fanClubBot = wetBotData.bots.fanClub, prependTipCount = tippersBot.prependTipCount, isFan = message.in_fanclub, 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; } // TODO: check this for new icons approach // it's not a command, so show it prefix += prependTipCount ? username in tippersBot.tippers? '[' + tippersBot.tippers[username].sum + '] ':'':''; // add tip counter prefix += getEmotes(username); message.m = prefix + message.m; if (isFan) { message.c = fanClubBot.foregroundColor; message.backgroundColor = fanClubBot.backgroundColor; }; return message; }); ///////////////// // Send notice // ///////////////// function sendNotice(user, message, foregroundColor, backgroundColor, group) { const fg = foregroundColor || wetBotData.foregroundColor, bg = backgroundColor|| wetBotData.backgroundColor, grp = group || ""; cb.sendNotice(message, user, bg, fg, 'normal', grp); } function sendBoldNotice(user, message, foregroundColor, backgroundColor, group) { const fg = foregroundColor || wetBotData.foregroundColor, bg = backgroundColor|| wetBotData.backgroundColor, grp = group || ""; cb.sendNotice(message, user, bg, fg, 'bold', grp); } function sendErrorNotice(username, message, commandString) { message = ` Error command : /${commandString} ${unicodeChars.square}${message} `; sendBoldNotice(username, message); } /////////// // Utils // /////////// function getEmotes(username) { const clubsArray = getClubsOf(username), clubsEmotes = []; clubsArray.includes('conquerors') && clubsEmotes.push('co'); clubsArray.includes('founders') && clubsEmotes.push('fo'); clubsArray.includes('knights') && clubsEmotes.push('kn'); clubsArray.includes('philanderers') && clubsEmotes.push('ph'); const tippersEmotes = []; isBombTipper(username) && tippersEmotes.push('bomb'); isKingTipper(username) && tippersEmotes.push('king'); return (`${clubsEmotes.length > 0 ? ' :osm' + clubsEmotes.join(''):''} ${tippersEmotes.length > 0 ? ' :osm' + tippersEmotes.join(''):''} `); } function padRight(char, txt) { return txt + repeat(char, 1); } function padLeft(char, txt) { return repeat(char, 1) + txt ; } function repeat(char, length) { var result = ""; while(length--) result += char; return result; } function bracket(string, unicode, length = 5, verticalPadding = 0) { const lines = string.trim().split(lineBreak); let 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 stopBot(username, botId ) { var bot = wetBotData.bots[botId], resultString = `${bot.name} is no longer running`; if (bot.status == Status.RUNNING || bot.status == Status.PAUSED) { bot.status = Status.STOPPED; bot.timeoutId = cb.cancelTimeout(bot.timeoutId); if (botId == 'tipMenu') { bot.happyTimeTimeoutId && (bot.happyTimeTimeoutId = cb.cancelTimeout(bot.happyTimeTimeoutId)); bot.happyTimeElapsedTimeoutId && (bot.happyTimeElapsedTimeoutId = cb.cancelTimeout(bot.happyTimeElapsedTimeoutId)); bot.happyTimeTriggered = false; } sendBoldNotice('', resultString, bot.foregroundColor, bot.background); return; } (bot.status == Status.STOPPED) && sendBoldNotice( username, `${bot.name} is already stopped`, bot.foregroundColor, bot.background); (bot.status == Status.DISABLED) && sendBoldNotice( username, `${bot.name} is OFF`, bot.foregroundColor, bot.background); } function runBot(username, botId ) { const bot = wetBotData.bots[botId], resultString = `${bot.name} is running`; if (bot.status == Status.STOPPED) { bot.status = Status.RUNNING; if (botId == 'tipMenu') { broadcastTipMenuTimeout(); } if (botId == 'lottery') { broadcastLotteryInfoTimeout(); } sendBoldNotice('', resultString, bot.foregroundColor, bot.background); return; } sendBoldNotice( username, `${bot.name} is already running`, bot.foregroundColor, bot.background); } function fanPrice(amount) { const fansDiscount = wetBotData.bots.tipMenu.fanClubDiscount; return Math.floor(amount * (1 - fansDiscount/100)); } function happyTimePrice(amount) { const happyTimeDiscount = wetBotData.bots.tipMenu.happyTimeDiscount; return Math.floor(amount * (1 - happyTimeDiscount/100)); } function drawMultiGoalPanel() { const multiGoalBot = wetBotData.bots.multiGoal, tippersBot = wetBotData.bots.tippers, tipSum = tippersBot.tipSum, kingTipper = (tippersBot.kingTipper == '') ? 'There\'s no king tipper yet' : tippersBot.kingTipper , kingTipperSum = tippersBot.kingTipperSum, currentGoal = multiGoalBot.currentGoalIndex + 1, currentGoalLimit = multiGoalBot.tokensPerGoal, currentGoalTokens = multiGoalBot.currentGoalSum, nextGoal = multiGoalBot.nextGoal, fontSize = 11, fontSizeBig = 16, fontSizeSmall = 10, percentage = Math.floor((currentGoalTokens / currentGoalLimit) * 100), remainder = percentage % 10, goalStop = percentage - remainder, template = { "template" : "image_template", "layers": [ {'type': 'image'}, { 'type': 'text', 'text': 'Total tokens earned: ' + tipSum, 'top': 5, 'left': 69, 'font-size': fontSize, 'font-weight': 'bold', 'color': 'orange', }, { 'type': 'text', 'text': 'GOAL #' + currentGoal + ': ' + currentGoalTokens + '/' + currentGoalLimit + ' [' + (currentGoalLimit - currentGoalTokens) + ' to goal]', 'top': 47, 'left': 69, 'font-size': fontSize, 'font-weight': 'bold', 'color': 'black', }, { 'type': 'text', 'text': percentage + '%', 'top': 33, 'left': 236, 'font-size': fontSize, 'color': 'orange', } ], }; if (nextGoal) { template.layers[0].fileID = multiGoalBot.panelBackgrounds["goal" + goalStop]; template.layers.push({ 'type' : 'text', 'text' : nextGoal + ' at goal!', 'top' : 22, 'left' : 69, 'font-size' : fontSizeBig, 'color': 'black', }); } else { template.layers[0].fileID = multiGoalBot.panelBackgrounds["king" + goalStop]; template.layers.push({ 'type' : 'text', 'text' : kingTipper, 'top' : 18, 'left' : 98, 'font-size' : fontSizeSmall, 'color': 'black', }, { 'type' : 'text', 'text' : '(' + kingTipperSum + ')', 'top' : 29, 'left' : 98, 'font-size' : fontSizeSmall, 'color': 'black', }); } return template; } ///////// // tip // ///////// function updateGlobalTipCounter( amount) { wetBotData.bots.tippers.tipSum += amount; wetBotData.bots.tippers.tipCount += 1; } function updateTippersList(user, amount) { const tippersBot = wetBotData.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.minBombTip && 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); } function updateFansList(user, amount) { const fansBot = wetBotData.bots.fanClub; if (user.in_fanclub){ if ( user.user in fansBot.tippers ) { fansBot.tippers[user.user].sum += amount; } else { fansBot.tippers[user.user] = { sum : amount, data: user }; } } } function updateClubsList ( user, amount ) { const clubsAvailableMap = wetBotData.bots.clubs.clubs; for ( let club in clubsAvailableMap ) { if ( clubsAvailableMap[club].fee == amount && !clubsAvailableMap[club].members.includes(user.user) ) { clubsAvailableMap[club].members.push(user.user); sendNewMemberNotice( user.user, club); } } } function checkTipMenu(user, amount) { const tipMenuBot = wetBotData.bots.tipMenu, happyTimeTriggered = tipMenuBot.happyTimeTriggered, tipMenuList = tipMenuBot.items; if (tipMenuBot.status == Status.RUNNING) { tipMenuList.forEach(function(item, index) { if (discountPrice(item.amount, user) == amount) { tipMenuList[index].times += 1; tipMenuBot.history.push({ user : user.user, description : item.description, time : new Date().getTime(), happyTime : happyTimeTriggered }); sendTipMenuNotice( user.user, tipMenuList[index].description); } }); } } function checkLotteryPrize(user, amount) { const lotteryBot = wetBotData.bots.lottery, lotteryPrizesMap = lotteryBot.prizes; if (lotteryBot.status == Status.RUNNING && amount <= lotteryBot.max && amount >= lotteryBot.min && objectSize(lotteryPrizesMap) > 0) { if ( amount in lotteryPrizesMap) { sendLotteryResultNotice(user.user, amount, lotteryPrizesMap[amount]); return; } sendLotteryResultNotice(user.user, amount); } } function checkHappyTime(amount) { const tipMenuBot = wetBotData.bots.tipMenu; if (tipMenuBot.status == Status.RUNNING && tipMenuBot.happyTimeEnabled && (amount == tipMenuBot.happyTimeTriggerTip)) { triggerHappyTime(); } } function objectSize(object) { var result = 0; for (var item in object) { if(object.hasOwnProperty(item)){ result++; } } return result; } 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 = wetBotData.bots.tippersBot.kingTipper, // currentBombTipper = wetBotData.bots.tippersBot.bombTipper, // message = []; updateGlobalTipCounter(amount); updateTippersList(user, amount); updateFansList(user, amount); updateClubsList(user, amount); checkHappyTime(amount); checkTipMenu(user, amount); checkLotteryPrize(user, amount); updateMultiGoal(user, amount); cb.drawPanel(); } function updateMultiGoal(user, amount) { const multiGoalBot = wetBotData.bots.multiGoal, goal = multiGoalBot.currentGoalIndex, goalSum = multiGoalBot.currentGoalSum, newGoal = goal + Math.floor((goalSum + amount) / multiGoalBot.tokensPerGoal), newGoalSum = (goalSum + amount) % multiGoalBot.tokensPerGoal; let message = ""; if(multiGoalBot.status == Status.RUNNING) { multiGoalBot.totalSum += amount; multiGoalBot.currentGoalSum = newGoalSum; multiGoalBot.currentGoalIndex = newGoal; if (goal < newGoal) { // send notice about goals fulfilled if ((newGoal - goal) == 1) { message = `${user.user} has reached goal #${newGoal + 1}!!`; } else { message = `${user.user} has reached goals #${goal + 1} through #${newGoal}!!`; } sendBoldNotice(everyone, message, colors.white, multiGoalBot.foregroundColor); } } } //////////////////////// // Commands procesing // //////////////////////// function stripCommandFromMessage(originalMessage) { // cycle through the commands list for (let command in wetBotData.commandsConfig){ let index = originalMessage.toLowerCase().indexOf(command); // find alias in the message if (index >= 0) { // if alias is found let commandArray = splitBySpaces(originalMessage.substring(index)); // cut into pieces the message starting from the command return originalMessage.substring(index).replace(commandArray[0], wetBotData.commandsConfig[command]['cmd']); // return the message but replaced the alias for the command } } } function processCommand(message, commandString) { const commandArray = splitBySpaces(commandString.toLowerCase()), command = commandArray[0]; if ( command == 'help') { return processHelpCommand(message, commandArray, commandString); } if ( command == 'tippers') { return processTippersCommand(message, commandArray, commandString); } if ( command == 'fans') { return processFansCommand(message, commandArray, commandString); } if ( command == 'clubs') { return processClubsCommand(message, commandArray, commandString); } if ( command == 'tipmenu') { return processTipMenuCommand(message, commandArray, commandString); } if ( command == 'lottery') { return processLotteryCommand(message, commandArray, commandString); } if ( command == 'title') { return processTitleCommand(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 (wetBotData.bots.roomSubject.search(`(^|\\s)${element}(\\s|$)`) < 0) wetBotData.bots.roomSubject = `${wetBotData.bots.roomSubject} ${element}`; }); cb.changeRoomSubject(wetBotData.bots.roomSubject); sendBoldNotice(message.user, "tag added to subject", colors.gray, ''); } 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|$)`); wetBotData.bots.roomSubject = wetBotData.bots.roomSubject.replace(test,' ').trim(); }); cb.changeRoomSubject(wetBotData.bots.roomSubject); sendBoldNotice(message.user, "tag removed from subject", colors.gray, ''); } } function processHelpCommand(message, commandArray) { // if (message.user !== cb.room_slug && !message.is_mod) // return false; if (commandArray.length == 1) { sendNotice(message.user, getFullHelp(message) ); return; } } function processTippersCommand(message, commandArray, commandString) { // if (message.user !== cb.room_slug && !message.is_mod) // return false; if ( commandArray.length == 1 ) { sendTippersList(message); return; } if (commandArray.length == 2 && commandArray[1] == "help" ) { sendTippersHelp(message); return; } if ( commandArray.length == 2 && commandArray[1] == "king" ) { sendKing(message); return; } if ( commandArray.length == 2 && commandArray[1] == "bomb" ) { sendBomb(message); return; } return `ERROR: /${commandString} is not a valid command`; } function processFansCommand(message, commandArray) { if (message.user !== cb.room_slug && !message.is_mod) return false if (commandArray.length == 2 && commandArray[1] == "help" ) { sendFansHelp(message); return; } if ( commandArray.length == 1 ) { sendFansList(message); return; } } function processClubsCommand(message, commandArray) { const clubsBot = wetBotData.bots.clubs; if (message.user !== cb.room_slug && !message.is_mod) { if (commandArray.length == 1) { sendClubsInfo(message.user); return; } return false; } if (commandArray.length == 1) { sendClubsList(message, null, null); return; } if ( commandArray.length == 2 && commandArray[1] == "help" ) { sendClubsHelp(message); return; } if ( commandArray.length == 2 && commandArray[1] == "info" ) { sendClubsInfo(message.user); return; } // if ( commandArray.length == 3 && commandArray[1] == "list" ) { // var membersList = getMembersOf(commandArray[2]); // if (membersList.length) // sendMembersList(message, membersList, commandArray[2]); // else { // var resultString = lineBreak + "THERE'S NO MEMBER IN CLUB " + commandArray[2].toUpperCase() + lineBreak; // sendBoldNotice(message.user, resultString, wetBotData.bots.clubs.colors.foregroundColor, wetBotData.bots.clubs.colors.background); // } // return; // } if ( commandArray.length == 3 && commandArray[1] == "user" ) { const clubsList = getClubsOf(commandArray[2]); if (clubsList.length) sendClubsList(message, clubsList, commandArray[2]); else { const resultString = ` ${commandArray[2].toUpperCase()} IS NOT A MEMBER OF ANY CLUB `; sendBoldNotice(message.user, resultString, clubsBot.foregroundColor, clubsBot.background); } return; } if (commandArray.length == 2 && commandArray[1] == 'all') { broadcastClubsNotice(); return; } if (commandArray.length == 3 && commandArray[2] == 'off') { clubsBot.timeoutId = cb.cancelTimeout(clubsBot.timeoutId); sendClubInfoBroadcastOff(message.user); return; } if (commandArray.length == 4 && commandArray[2] == 'on' && !isNaN(parseInt(commandArray[3])) && parseInt(commandArray[3]) > 0) { clubsBot.timeoutId = cb.cancelTimeout(clubsBot.timeoutId); clubsBot.timeout = parseInt(commandArray[3]); cb.setTimeout(broadcastClubsBotNoticeTimeout, 2000); sendClubInfoBroadcastOn(message.user, parseInt(clubsBot.timeout)); return; } else return false; } function processTipMenuCommand(message, commandArray) { var tipMenuBot = wetBotData.bots.tipMenu; 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; } if (commandArray.length > 3 && commandArray[1] == 'add' && !isNaN(parseInt(commandArray[2]))){ const menuItem = commandArray.slice(3).join(' '), index = insertInTipMenu(commandArray[2], menuItem); sendAddTipMenuResult(message.user, menuItem, commandArray[2], index); return; } if (commandArray.length == 3 && commandArray[1] == 'rm' && !isNaN(parseInt(commandArray[2]))) { removeFromTipMenu(parseInt(commandArray[2])); sendRemoveTipMenuResult(message.user, commandArray[2]); return; } if (commandArray.length == 2 && commandArray[1] == 'history') { sendTipMenuHistory(); return; } if (commandArray.length == 2 && commandArray[1] == 'counter') { sendTipMenuCounter(); return; } if (commandArray.length == 2 && commandArray[1] == 'off') { stopBot(message.user, 'tipMenu'); return; } if (commandArray.length == 2 && commandArray[1] == 'on') { runBot(message.user,'tipMenu'); return; } if (commandArray.length == 3 && commandArray[1] == 'happy' && commandArray[2] == 'off') { disableHappyTime(); return; } if (commandArray.length == 3 && commandArray[1] == 'happy' && commandArray[2] == 'on') { enableHappyTime(); return; } if (commandArray.length == 2 && commandArray[1] == 'all') { broadcastTipMenu(); return; } if (commandArray.length == 3 && commandArray[1] == 'all' && commandArray[2] == 'off') { tipMenuBot.timeoutId = cb.cancelTimeout(tipMenuBot.timeoutId); sendTipMenuBroadcastOff(message.user); return; } 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; } else return false; } function processLotteryCommand(message, commandArray) { const lotteryBot = wetBotData.bots.lottery; if (commandArray.length == 1) { sendLotteryInfoNotice(message.user); return; } if (commandArray.length == 2 && commandArray[1] == 'help') { sendLotteryHelp(message); return; } if (commandArray.length == 2 && commandArray[1] == 'numbers') { sendLotteryNumbersNotice(message.user); return; } if (message.user !== cb.room_slug && !message.is_mod) { return false; } if (commandArray.length == 2 && commandArray[1] == 'prizes') { sendLotteryPrizesNotice(message.user); return; } if (commandArray.length == 2 && commandArray[1] == 'restart') { lotteryRestart(message.user); return; } if (commandArray.length == 2 && commandArray[1] == 'off') { stopBot(message.user, 'lottery'); return; } if (commandArray.length == 2 && commandArray[1] == 'on') { runBot(message.user,'lottery'); return; } if (commandArray.length == 2 && commandArray[1] == 'all') { broadcastLotteryInfo(); return; } if (commandArray.length == 3 && commandArray[1] == 'all' && commandArray[2] == 'off') { if (lotteryBot.status != Status.RUNNING) { sendBoldNotice(message.user, 'LOTTERY BOT IS NOT RUNNING', lotteryBot.foregroundColor, lotteryBot.background); return; } lotteryBot.timeoutId = cb.cancelTimeout(lotteryBot.timeoutId); sendLotteryBroadcastOffNotice(message.user); return; } if (commandArray.length == 4 && commandArray[1] == 'all' && commandArray[2] == 'on' && !isNaN(parseInt(commandArray[3])) && parseInt(commandArray[3]) > 0) { if (lotteryBot.status != Status.RUNNING) { sendBoldNotice(message.user, 'LOTTERY BOT IS NOT RUNNING', lotteryBot.foregroundColor, lotteryBot.background); return; } lotteryBot.timeoutId = cb.cancelTimeout(lotteryBot.timeoutId); lotteryBot.noticeTimeout = parseInt(commandArray[3]); broadcastLotteryInfoTimeout(); sendLotteryBroadcastOnNotice(message.user, parseInt(commandArray[3])); return; } return false; } function splitBySpaces(string) { return string.trim().replace(/\s+/g, ' ').split(' '); } ///////////////////// // tippers // ///////////////////// function sendTippersHelp(message) { sendNotice(message.user, getTippersHelp(message) ); } function sendTippersList(message) { const tippersBot = wetBotData.bots.tippers, sorted = sortTippers(tippersBot.tippers), unicode = tippersBot.unicode; let resultString = ''; if (sorted.length == 0 ){ resultString = 'NOBODY TIPPED SINCE THE APP STARTED'; sendBoldNotice(message.user, resultString, tippersBot.foregroundColor, tippersBot.background); return; } else { resultString += ` THIS IS THE LIST OF TIPPERS SINCE THIS APP STARTED Total tips: ${tippersBot.tipCount} Total tokens: ${tippersBot.tipSum} Total tippers: ${objectSize(tippersBot.tippers)} `; sorted.forEach(function(username, index){ let isFan = tippersBot.tippers[username].data.in_fanclub; resultString += `${(index+1)}. ${tippersBot.tippers[username]['sum']} | ${username} ${getEmotes(username)} ${isFan?'(f)':''} `; }); resultString = bracket(resultString, unicode, 3, 0); } sendBoldNotice(message.user, resultString, tippersBot.foregroundColor, tippersBot.background); } function sendKing(message) { const tippersBot = wetBotData.bots.tippers; if (tippersList.length == 0) { sendBoldNotice(message.user, bracket('NOBODY TIPPED SINCE THE APP STARTED', '', 0, 0), tippersBot.foregroundColor, tippersBot.background) return; } const kingTipper = tippersBot.kingTipper, amount = tippersBot.kingTipperSum, fanEmote = ((tippersList[kingTipper] != undefined && tippersList[kingTipper].data.in_fanclub) ? " (f)" : ""), resultString = ((kingTipper == "") ? "NOBODY TIPPED SINCE THE APP STARTED" : `:osmking The king tipper is ${kingTipper} with a total of ${amount} tokens!! ${getEmotes(kingTipper)} ${fanEmote}`); sendBoldNotice(message.user, bracket(resultString, '', 0, 0), tippersBot.foregroundColor, tippersBot.background); } function sendBomb(message) { const tippersBot = wetBotData.bots.tippers; if (tippersList.length == 0) { sendBoldNotice(message.user, bracket('NOBODY TIPPED SINCE THE APP STARTED', '', 0, 0), tippersBot.foregroundColor, tippersBot.background) return; } const bombTipper = tippersBot.bombTipper, amount = tippersBot.bombTip, fanEmote = ((tippersList[bombTipper] != undefined && tippersList[bombTipper].data.in_fanclub) ? " (f)" : ""), resultString = ((bombTipper == "") ? `NOBODY SINGLE-TIPPED MORE THAN ${tippersBot.minBombTip} SINCE THE APP STARTED` : `:osmbomb The BOMB tipper is ${bombTipper} with a tip of ${amount} tokens!! ${getEmotes(bombTipper)} ${fanEmote}`); sendBoldNotice(message.user, bracket(resultString, '', 0, 0), tippersBot.foregroundColor, tippersBot.background) } function isKingTipper(username) { return username === wetBotData.bots.tippers.kingTipper; } function isBombTipper(username) { return username === wetBotData.bots.tippers.bombTipper; } ////////////////// // fans // ////////////////// function sendFanMemberNotice ( user ) { var fansBot = wetBotData.bots.fanClub, verb = 'has', subject; if ( user.gender == 'm' ) subject = 'he is a member'; else if ( user.gender == 'f' ) subject = 'she is a member'; else if ( user.gender == 'c' ) verb = 'have', subject = 'they are members'; else subject = 'is a member'; var resultString = `${user.user} ${verb} entered the room and ${subject} of your fanclub`; sendBoldNotice(cb.room_slug, bracket(resultString, fansBot.unicode, 5, 0), fansBot.foregroundColor, fansBot.background); } function sendFansHelp( message ) { sendNotice(message.user, getFansHelp(message) ); } function sendFansList( message ) { const fansBot = wetBotData.bots.fanClub, sorted = sortTippers(fansBot.tippers), unicode = fansBot.unicode; let resultString = ''; if (sorted.length == 0 ){ resultString = "NO FAN TIPPED SINCE THE APP STARTED"; sendBoldNotice(message.user, resultString, fansBot.foregroundColor, fansBot.background); return; } resultString += 'THIS IS THE LIST OF FANS WHO TIPPED SINCE THIS APP STARTED' + lineBreak; sorted.forEach(function(user, index){ resultString += `${(index+1)}. ${fansBot.tippers[user]['sum']} | ${user} ${getEmotes(user)} `; }); resultString = bracket(resultString, unicode, 3, 0); sendBoldNotice(message.user, resultString, fansBot.foregroundColor, fansBot.backgroundColor); } function sortTippers( tippersList ) { return Object.keys(tippersList).sort(function(a,b){ return tippersList[b]['sum']-tippersList[a]['sum']; }); } /////////////////// // clubs // /////////////////// function sendClubsHelp( message ) { sendNotice(message.user, getClubsHelp(message) ); } function sendClubsInfo( username ) { const clubsBot = wetBotData.bots.clubs, clubsAvailableMap = clubsBot.clubs; let resultString = ''; for ( let club in clubsAvailableMap ) { resultString += ` - ${club} ${clubsAvailableMap[club].emote} : ${clubsAvailableMap[club].fee} tokens${lineBreak}`; } resultString = resultString.length == 0 ? 'THE CLUBS LIST IS EMPTY!!' : `THESE ARE THE CLUBS AVAILABLE:${lineBreak}${resultString}`; sendBoldNotice( username, bracket(resultString, clubsBot.unicode, 3, 0), clubsBot.foregroundColor, clubsBot.background); } function sendClubsList( message, clubsList, username ) { let resultString = ''; const clubsBot = wetBotData.bots.clubs, clubsAvailableMap = clubsBot.clubs; if (clubsList == null || clubsList == undefined ) { // send full list for ( let club in clubsAvailableMap ) { resultString += `MEMBERS OF ${club.toUpperCase()} CLUB: ${clubsAvailableMap[club].emote} ${lineBreak}`; cb.log(clubsAvailableMap[club]); clubsAvailableMap[club].members.forEach(function(username){ resultString += ` - ${username} ${lineBreak}`; // TODO add more emotes here }); } resultString = resultString.length == 0 ? 'THE CLUBS ARE EMPTY!!' : `THIS IS THE CLUBS FULL LIST${lineBreak} ${resultString}`; } else { // send club list resultString += `${username.toUpperCase()} IS A MEMBER OF: ${lineBreak}`; clubsList.forEach(function(club){ resultString += ` - ${club} ${clubsAvailableMap[club].emote} ${lineBreak}`; // TODO add more emotes here }); } sendBoldNotice(message.user, bracket(resultString, clubsBot.unicode, 3, 0 ), clubsBot.foregroundColor, clubsBot.background); } function sendMembersList( message, membersList, club ) { const clubsBot = wetBotData.bots.clubs, clubsAvailableMap = clubsBot.clubs; let resultString = `THIS IS THE LIST OF MEMBERS OF ${club.toUpperCase()} ${clubsAvailableMap[club].emote}${lineBreak}`; membersList.forEach(function(username){ resultString += ` - ${username} ${lineBreak}`; // TODO add more emotes here }); sendBoldNotice(message.user, bracket(resultString, clubsBot.unicode, 3, 0), clubsBot.foregroundColor, clubsBot.background); } function sendNewMemberNotice( username, club ) { const clubsBot = wetBotData.bots.clubs, emote = clubsBot.clubs[club].emote, resultString = `${username.toUpperCase()} IS A NEW MEMBER OF THE ${club.toUpperCase()} CLUB!! ${emote}`; sendBoldNotice(everyone, resultString, clubsBot.foregroundColor, clubsBot.background); } function broadcastClubsNotice() { sendClubsInfo ( everyone ); } function sendClubInfoBroadcastOff( user ) { const clubsBot = wetBotData.bots.clubs, resultString = 'The club info will not be shown to the users'; sendBoldNotice(user, resultString, clubsBot.foregroundColor, clubsBot.background); } function sendClubInfoBroadcastOn( user, minutes ) { const clubsBot = wetBotData.bots.clubs, resultString = 'The club info will be shown to the users every ' + minutes + ' minutes' ; sendBoldNotice(user, resultString, clubsBot.foregroundColor, clubsBot.background); } function broadcastClubsBotNoticeTimeout() { const clubsBot = wetBotData.bots.clubs; broadcastClubsNotice (); clubsBot.timeout > 0 && (clubsBot.timeoutId = cb.setTimeout(broadcastClubsBotNoticeTimeout, clubsBot.timeout * 60 * 1000)); } function getMembersOf( club ) { const clubsBot = wetBotData.bots.clubs, clubsAvailableMap = clubsBot.clubs; return (clubsAvailableMap.hasOwnProperty(club.toLowerCase())) ? clubsAvailableMap[club].members : []; } function getClubsOf( username ) { const clubsBot = wetBotData.bots.clubs, clubsAvailableMap = clubsBot.clubs, clubsList = []; for (let club in clubsAvailableMap) { if (clubsAvailableMap[club].members.includes(username)) clubsList.push(club); } return clubsList; } function getClubEmotesList( username ) { const clubsList = wetBotData.bots.clubs.clubs, emotes = []; for (let clubName in clubsList) { clubsList[clubName].members.includes(username) && emotes.push(clubsList[clubName].emote); } return emotes; } ////////////////////// // tip menu // ////////////////////// function sendTipMenuHelp( message ) { sendNotice(message.user, getTipMenuHelp(message) ); } function insertInTipMenu( amount, description ) { const tipMenuList = wetBotData.bots.tipMenu.items, index = tipMenuList.findIndex(function(item) { return amount <= item.amount; }); if (index < 0) { tipMenuList.push({amount: amount, description: description}); return tipMenuList.length-1; } tipMenuList.splice(index, 0, {amount: amount, description: description}); return index; } function removeFromTipMenu( index ) { var tipMenuList = wetBotData.bots.tipMenu.items; tipMenuList.splice(index, 1); } function sendAddTipMenuResult( username, item, price, index ) { const tipMenuBot = wetBotData.bots.tipMenu, resultString = `"${item}" (${price}) has been added to the tip menu in position ${index}`; sendBoldNotice(username, resultString, tipMenuBot.foregroundColor, tipMenuBot.background); } function sendRemoveTipMenuResult( username, index ) { const tipMenuBot = wetBotData.bots.tipMenu, resultString = `Menu item #${index} has been removed from the tip menu`; sendBoldNotice(username, resultString, tipMenuBot.foregroundColor, tipMenuBot.background); } function sendTipMenu(message) { message = !message ? {user: '', is_mod: false, in_fanclub: false} : message; let resultString = ''; const tipMenuBot = wetBotData.bots.tipMenu, unicode = tipMenuBot.unicode || '*', tipMenuList = tipMenuBot.items, 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 tip menu is not running"; sendBoldNotice(message.user, resultString, tipMenuBot.foregroundColor, tipMenuBot.background); return; } tipMenuList.forEach(function(item, index){ const indexPrefix = (message.user == cb.room_slug || message.is_mod) ? `( ${index} )` :'', amount = discountPrice(item.amount), fanAmount = fanPrice(amount), amountString = `${(message.in_fanclub ? fanAmount : (amount + " (" + fanAmount + " fanclub price)"))} ${tipMenuBot.happyTimeTriggered ? ' ON SALE!!' : ''}`; resultString += ` ${unicode} -${indexPrefix}- ${amountString} | ${item.description}${lineBreak}`; // TODO add more unicodes here }); if (resultString.length == 0) { resultString = "The tip menu is empty"; sendBoldNotice(message.user, resultString, "#fff", tipMenuBot.foregroundColor); return; } resultString = `${repeat(unicode, 5)} TIP MENU: ${repeat(unicode, 5)} ${resultString}`; sendBoldNotice(message.user, resultString, tipMenuBot.foregroundColor, tipMenuBot.background); tipMenuBot.happyTimeEnabled && sendBoldNotice(message.user, `${unicode} ${happyTimeMsg.toUpperCase()}`, '#fff', tipMenuBot.backgroundColor); } function sendTipMenuHistory( username ) { let resultString = ''; const tipMenuBot = wetBotData.bots.tipMenu, unicode = tipMenuBot.unicode, history = tipMenuBot.history.reverse(), now = new Date().getTime(); history.forEach( function( item ){ const 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 += ` ${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.background); } function sendTipMenuCounter( username ) { var resultString = '', tipMenuBot = wetBotData.bots.tipMenu, unicode = tipMenuBot.unicode, tipMenuCounter = tipMenuBot.items.sort(function(a,b) { return (parseInt(b.times) - parseInt(a.times)); }); tipMenuCounter.forEach(function(item){ resultString += item.times > 0 ? `${unicode} -- ${item.times} | ${item.description}${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.background); } function sendTipMenuNotice( username, description ) { var unicode = wetBotData.bots.tipMenu.unicode, resultString = `${repeat(unicode,20)} ${unicode} ${username.toUpperCase()} Has just tipped for ${unicode} ${description.toUpperCase()} ${repeat(unicode,20)}`; sendBoldNotice(username, resultString, wetBotData.bots.tipMenu.tipForegroundColor, wetBotData.bots.tipMenu.tipBackgroundColor); } function sendTipMenuBroadcastOff( user ) { var tipMenuBot = wetBotData.bots.tipMenu, resultString = 'The tip menu will not be shown periodically to the users'; sendBoldNotice(user, resultString, tipMenuBot.foregroundColor, tipMenuBot.background); } function sendTipMenuBroadcastOn( user, minutes ) { var tipMenuBot = wetBotData.bots.tipMenu, resultString = `The tip menu will be shown to the users every ${minutes} minutes` ; sendBoldNotice(user, resultString, tipMenuBot.foregroundColor, tipMenuBot.background); } function broadcastTipMenu() { sendTipMenu ( everyone ); } function broadcastTipMenuTimeout() { var tipMenuBot = wetBotData.bots.tipMenu; broadcastTipMenu (); (tipMenuBot.noticeTimeout > 0) && (tipMenuBot.timeoutId = cb.setTimeout(broadcastTipMenuTimeout, tipMenuBot.noticeTimeout * 60 * 1000)); } //-- Happy time --// function discountPrice(amount, user) { var tipMenuBot = wetBotData.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 = wetBotData.bots.tipMenu, timeLeft = Math.floor((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, tipMenuBot.foregroundColor, tipMenuBot.background); } function sendHappyTimeInfoNotice() { var tipMenuBot = wetBotData.bots.tipMenu, timeLeft = Math.floor((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, tipMenuBot.foregroundColor, tipMenuBot.background); tipMenuBot.happyTimeElapsedTimeoutId = cb.cancelTimeout(tipMenuBot.happyTimeElapsedTimeoutId); if (timeLeft > 30) { tipMenuBot.happyTimeElapsedTimeoutId = cb.setTimeout(sendHappyTimeInfoNotice, 30 * 1000); } } function enableHappyTime() { var tipMenuBot = wetBotData.bots.tipMenu; tipMenuBot.happyTimeTimeoutId = undefined; tipMenuBot.happyTimeTimeoutId = undefined; tipMenuBot.happyTimeEnd = 0; tipMenuBot.happyTimeTriggered = false; tipMenuBot.happyTimeEnabled = true; sendBoldNotice('', 'HAPPY TIME IS ENABLED', tipMenuBot.foregroundColor, tipMenuBot.background); } function disableHappyTime() { var tipMenuBot = wetBotData.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 IS NOT ENABLED', tipMenuBot.foregroundColor, tipMenuBot.background); } function triggerHappyTime() { var tipMenuBot = wetBotData.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 = wetBotData.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!!!`, tipMenuBot.foregroundColor, tipMenuBot.background); } ///////////////// // lottery // ///////////////// function sendLotteryHelp(message) { sendNotice(message.user, getLotteryHelp(message) ); } function endOfLotteryMessage() { var resultString = 'There are no prizes left to tip for. ' + lineBreak + '-- :clap Thanks for playing, everyone!! :clap --' + lineBreak; return resultString; } function guessedFormat(value, char) { var lotteryBot = wetBotData.bots.lottery, maxLen = String(lotteryBot.max).length, resultString = ''; while(maxLen--) { resultString += char; } return '[' + resultString + '] '; } function availableFormat(value) { var lotteryBot = wetBotData.bots.lottery, padding = String(lotteryBot.max).length - String(value).length, resultString = String(value); while(padding--) { resultString = (padding % 2 ? padRight(' ', resultString): padLeft(' ', resultString)); } return '[' + resultString + '] '; } function availableNumbers() { var lotteryBot = wetBotData.bots.lottery, resultString = ''; for (let i = lotteryBot.min; i <= lotteryBot.max; i++) { resultString += (lotteryBot.guesses.includes(i) ? guessedFormat(i,'x') : availableFormat(i)) + ((i%10)?'':lineBreak); } return resultString; } function sendLotteryResultNotice(username, amount, prize) { var lotteryBot = wetBotData.bots.lottery, lotteryGuessesList = lotteryBot.guesses, lotteryPrizesMap = lotteryBot.prizes, resultString = '', destination = '', resultMessageList = []; // if number has been already guessed if (lotteryGuessesList.includes(amount)) resultMessageList.push('Somebody else has already tipped this number, so obviously '); else lotteryGuessesList.push(amount); if ( prize == undefined) { resultMessageList.push(amount + ' is not a winning number :sad_ , sorry!'); // send only to the uer who tipped destination = username; } else { delete lotteryPrizesMap[amount]; var availablePrizes = getAvailablePrizes(); resultMessageList.push('We have a winner!! ' + username + ' has guessed number ' + amount + lineBreak + 'PRIZE: ' + prize.toUpperCase() + lineBreak); if (objectSize(lotteryPrizesMap) == 0) resultMessageList.push(lineBreak + endOfLotteryMessage()); else{ for (prize in availablePrizes) { resultMessageList.push(' - ' + prize + ' (' + availablePrizes[prize].sum + ' left)'); } resultMessageList.push(lineBreak + 'Use "/lot numbers" to see the list of available numbers'); } // send to everyone destination = ''; } resultString = (destination == '' ? bracket(resultMessageList.join(lineBreak), lotteryBot.unicode, 3, 0) : resultMessageList.join(lineBreak)); sendBoldNotice(destination, resultString, lotteryBot.foregroundColor, lotteryBot.background); } function lotteryRestart(username) { var lotteryBot = wetBotData.bots.lottery; if (!lotteryBot.enabled) { sendBoldNotice(username, 'LOTTERY BOT IS NOT ENABLED', lotteryBot.foregroundColor, lotteryBot.background); return; } initLotteryBot(); // TODO MAKE THIS AN IF ELSE STATEMENT sendLotteryRestartNotice(username); } function sendLotteryRestartNotice(username) { var lotteryBot = wetBotData.bots.lottery, resultString = 'The lottery prizes have been restarted' ; sendBoldNotice(username, resultString, lotteryBot.foregroundColor, lotteryBot.background); } function sendLotteryBroadcastOffNotice(username) { var lotteryBot = wetBotData.bots.lottery, resultString = 'The lottery notice will not be shown to the users' ; sendBoldNotice(username, resultString, lotteryBot.foregroundColor, lotteryBot.background); } function sendLotteryBroadcastOnNotice(username, minutes) { var lotteryBot = wetBotData.bots.lottery, resultString = 'The lottery notice will be shown to the users every ' + minutes + ' minutes' ; sendBoldNotice(username, resultString, lotteryBot.foregroundColor, lotteryBot.background); } function sendLotteryInfoNotice(username) { var lotteryBot = wetBotData.bots.lottery, availablePrizes = getAvailablePrizes(), resultString = 'THERE ARE NO LOTTERY PRIZES AVAILABLE AT THE MOMENT'; if (!lotteryBot.enabled) { sendBoldNotice(username, 'LOTTERY BOT IS NOT ENABLED', lotteryBot.foregroundColor, lotteryBot.background); return; } else if (objectSize(availablePrizes) > 0) { resultString = 'ARE YOU FEELING LUCKY?? TIP AN AMOUNT FROM ' + lotteryBot.min + ' TO ' + lotteryBot.max + ' (included)' + lineBreak + 'Available prizes: ' + lineBreak ; for (var prize in availablePrizes) { resultString += (' - ' + prize + ' (' + availablePrizes[prize].sum + ' left)' + lineBreak); } resultString += 'Use "/lot numbers" to see the list of available numbers'; } sendBoldNotice(username, bracket(resultString, lotteryBot.unicode, 3, 0), lotteryBot.foregroundColor, lotteryBot.background); } function sendLotteryNumbersNotice(username) { var lotteryBot = wetBotData.bots.lottery, availablePrizes = getAvailablePrizes(), resultString = 'THERE ARE NO LOTTERY PRIZES AVAILABLE AT THE MOMENT'; if (!lotteryBot.enabled) { sendBoldNotice(username, 'LOTTERY BOT IS NOT ENABLED', lotteryBot.foregroundColor, lotteryBot.background); return; } if (objectSize(availablePrizes) > 0) { resultString = 'These are the available numbers: ' + lineBreak + availableNumbers(); } sendBoldNotice(username, bracket(resultString, lotteryBot.unicode, 3, 0), lotteryBot.foregroundColor, lotteryBot.background); } function sendLotteryPrizesNotice(username) { var lotteryBot = wetBotData.bots.lottery, availablePrizes = getAvailablePrizes(), resultString = 'THERE ARE NO LOTTERY PRIZES AVAILABLE AT THE MOMENT'; if (!lotteryBot.enabled) { sendBoldNotice(username, 'LOTTERY BOT IS NOT ENABLED', lotteryBot.foregroundColor, lotteryBot.background); return; } if (objectSize(availablePrizes) > 0) { resultString = 'Available prizes: ' + lineBreak ; for (var prize in availablePrizes) { var numbers = (availablePrizes[prize].sum > 1 ? availablePrizes[prize].numbers.slice(0,-1).join(', ') + ' and ' + availablePrizes[prize].numbers.slice(-1) : availablePrizes[prize].number); resultString += (' - ' + prize + ' (' + availablePrizes[prize].sum + ' left) in ' + numbers + lineBreak); } } sendBoldNotice(username, bracket(resultString, lotteryBot.unicode, 0, 0), lotteryBot.foregroundColor, lotteryBot.background); } function broadcastLotteryInfo() { wetBotData.bots.lottery.enabled && sendLotteryInfoNotice(everyone); } function getAvailablePrizes() { var lotteryBot = wetBotData.bots.lottery, result = {}; for (var number in lotteryBot.prizes) { if (result[lotteryBot.prizes[number]] == undefined ) { result[lotteryBot.prizes[number]] = {sum:1, numbers:[number]}; } else { result[lotteryBot.prizes[number]].sum += 1; result[lotteryBot.prizes[number]].numbers.push(number); } } return result; } function broadcastLotteryInfoTimeout() { const lotteryBot = wetBotData.bots.lottery; broadcastLotteryInfo(); (lotteryBot.noticeTimeout > 0) && (lotteryBot.timeoutId = cb.setTimeout(broadcastLotteryInfoTimeout, lotteryBot.noticeTimeout * 60 * 1000)); } //////////////// // validators // //////////////// function isValidColor( color ) { var hexRegEx = /^#(([0-9a-fA-F]{3})|([0-9a-fA-F]{6}))$/, rgbaRegEx = /^rgba?\(((25[0-5]|2[0-4]\d|1\d{1,2}|\d\d?)\s*,\s*){2}(25[0-5]|2[0-4]\d|1\d{1,2}|\d\d?)\s*,?\s*([01]\.?\d*?)?\)$/; color = color.trim(); return !!(color.match(hexRegEx) || color.match(rgbaRegEx)); } function isValidEmote( emote ) { var emoteRegEx = /^:[a-zA-Z0-9\-_]+$/; emote = emote.trim(); return !!(emote.match(emoteRegEx)); } ////////////// // settings // ////////////// function sendWelcomeMessage(user) { sendBoldNotice(user.user, getWelcomeMessage(user), wetBotData.foregroundColor, wetBotData.background); } ////////// // Init // ////////// function init() { wetBotData.foregroundColor = (cb.settings.foregroundColor && isValidColor(cb.settings.foreground)) ? cb.settings.foregroundColor : defaultSettings.foregroundColor; wetBotData.backgroundColor = (cb.settings.backgroundColor && isValidColor(cb.settings.background)) ? cb.settings.backgroundColor : defaultSettings.backgroundColor; wetBotData.start = new Date().getTime(); initBots(); } function initBots() { initRoomSubject(); initTippersBot(); initFansBot(); initClubsBot(); initTipMenuBot(); initLotteryBot(); initMultiGoalBot(); } function initTippersBot() { var tippersBot = wetBotData.bots.tippers, defaults = defaultSettings.tippers; tippersBot.status = Status.RUNNING; tippersBot.foregroundColor = defaults.foregroundColor ; tippersBot.backgroundColor = defaults.backgroundColor ; tippersBot.unicode = defaults.unicode; tippersBot.emotes.kingTipper = cb.settings.kingTipperEmote && isValidEmote(cb.settings.kingTipperEmote) ? cb.settings.kingTipperEmote : defaults.emotes.kingTipper; tippersBot.emotes.bombTipper = cb.settings.bombTipperEmote && isValidEmote(cb.settings.bombTipperEmote) ? cb.settings.bombTipperEmote : defaults.emotes.bombTipper; tippersBot.minBombTip = (cb.settings.bombTipperMinValue && !isNaN(parseInt(cb.settings.bombTipperMinValue))) ? parseInt(cb.settings.bombTipperMinValue) : defaults.bombTipperMinValue; tippersBot.prependTipCount = cb.settings.prependTipCount == 'yes'? true : false; } function initFansBot() { var fansBot = wetBotData.bots.fanClub, defaults = defaultSettings.fanClub; fansBot.status = Status.RUNNING; fansBot.foregroundColor = cb.settings.fansInGreen == "yes" ? defaults.foregroundColor :''; fansBot.backgroundColor = defaults.backgroundColor; fansBot.unicode = defaults.unicode; } function initClubsBot() { var clubsBot = wetBotData.bots.clubs, defaults = defaultSettings.clubs; clubsBot.foregroundColor = defaults.foregroundColor; clubsBot.backgroundColor = defaults.BackgroundColor; clubsBot.unicode = defaults.unicode; for (var i = 0; i < MAX_GROUPS; i++) { var clubName = cb.settings["clubName" + i] ? cb.settings["clubName" + i].trim() : '', clubEmote = cb.settings["clubEmote" + i] ? cb.settings["clubEmote" + i].trim() : '', clubFee = parseInt(cb.settings["clubFee" + i]); if (clubName.length > 0 && !isNaN(clubFee) && (clubEmote == '' || isValidEmote(clubEmote))) { clubsBot.clubs[clubName] = {}; clubsBot.clubs[clubName]['members'] = cb.settings["clubMemebers" + i].trim().split(/\s*,\s*/);; clubsBot.clubs[clubName]['fee'] = clubFee; clubsBot.clubs[clubName]['emote'] = clubEmote; } } // set timeout and launch clubsBot.timeout = defaults.timeout; if (cb.settings.clubsBotEnabled == 'yes') { clubsBot.enabled = true, clubsBot.status = Status.RUNNING; clubsBot.timeout > 0 && broadcastClubsBotNoticeTimeout(); } } function initTipMenuBot() { var tipMenuBot = wetBotData.bots.tipMenu, defaults = defaultSettings.tipMenu; tipMenuBot.foregroundColor = defaults.foregroundColor; tipMenuBot.backgroundColor = defaults.backgroundColor; tipMenuBot.tipForegroundColor = defaults.tipForegroundColor; tipMenuBot.tipBackgroundColor = defaults.tipBackgroundColor; tipMenuBot.unicode = defaults.unicode; tipMenuBot.noticeTimeout = defaults.noticeTimeout; tipMenuBot.happyTimeEnabled = cb.settings.tipMenuBotHappyTimeEnabled == 'yes'? true : false; tipMenuBot.happyTimeTriggerTip = parseInt(cb.settings.happyTimeTriggerTip); tipMenuBot.happyTimeLength = parseInt(cb.settings.happyTimeLength); tipMenuBot.happyTimeDiscount = parseInt(cb.settings.happyTimeDiscount); tipMenuBot.happyTimeTriggered = false; tipMenuBot.fanClubDiscount = (cb.settings.fanClubDiscount && !isNaN(parseInt(cb.settings.fanClubDiscount))) ? parseInt(cb.settings.fanClubDiscount) : defaults.fanClubDiscount; if (cb.settings.tipMenuEnabled == 'yes') { tipMenuBot.enabled = true; tipMenuBot.status = Status.RUNNING; } for ( var i = 0; i < MAX_TIP_MENU_ITEMS; i++ ) { var tipDescription = cb.settings["tipMenuItemDescription" + i] ? cb.settings["tipMenuItemDescription" + i].trim() : '', tipAmount = cb.settings["tipMenuItemAmount" + i] ? parseInt(cb.settings["tipMenuItemAmount" + i]) : ''; if ( tipDescription.length > 0 && !isNaN(tipAmount) && tipAmount > 0 ) { tipMenuBot.items.push({amount: tipAmount , description: tipDescription, times: 0}); } } tipMenuBot.items = tipMenuBot.items.sort(function(a,b) { return (parseInt(a.amount) - parseInt(b.amount)); }); // set timeout and launch broadcastTipMenuTimeout(); } function initMultiGoalBot() { var multiGoalBot = wetBotData.bots.multiGoal, defaults = defaultSettings.multiGoal; multiGoalBot.tokensPerGoal = cb.settings.tokensPerGoal; multiGoalBot.foregroundColor = defaults.foregroundColor; multiGoalBot.backgroundColor = defaults.backgroundColor; multiGoalBot.unicode = defaults.unicode; if (cb.settings.multiGoalEnabled == 'yes') { cb.log('multi goal enabled'); multiGoalBot.enabled = true; multiGoalBot.status = Status.RUNNING; multiGoalBot.goals.push(null); cb.drawPanel(); } } function initRoomSubject() { const roomSubject = cb.settings.roomSubject; wetBotData.bots.roomSubject = roomSubject; cb.changeRoomSubject(roomSubject); } function initLotteryBot() { var lotteryBot = wetBotData.bots.lottery, defaults = defaultSettings.lottery; lotteryBot.enabled = cb.settings.lotteryEnabled == 'yes'? true : false; lotteryBot.status = cb.settings.lotteryEnabled == 'yes'? Status.RUNNING: Status.STOPPED; lotteryBot.foregroundColor = defaults.foregroundColor; lotteryBot.backgroundColor = defaults.backgroundColor; lotteryBot.min = parseInt(cb.settings.lotteryMin) || defaults.min; lotteryBot.max = parseInt(cb.settings.lotteryMax) || defaults.max; lotteryBot.prizes = {}; lotteryBot.guessed = []; lotteryBot.unicode = defaults.unicode; lotteryBot.noticeTimeout = defaults.noticeTimeout; var min = lotteryBot.min, max = lotteryBot.max, value; for(var i = 0; i < MAX_LOTTERY_PRIZES; i++){ var description = cb.settings['lotteryPrizeDescription' + i] || '', amount = cb.settings['lotteryPrizeAmount' + i] && parseInt(cb.settings['lotteryPrizeAmount' + i]) ? parseInt(cb.settings['lotteryPrizeAmount' + i]) : 0 ; while(description.trim().length && amount > 0) { value = Math.floor(Math.random() * (max - min) + min); if ( !(value in lotteryBot.prizes) ) { lotteryBot.prizes[value] = cb.settings['lotteryPrizeDescription' + i]; amount--; } } } if (lotteryBot.enabled && lotteryBot.noticeTimeout > 0) { broadcastLotteryInfoTimeout(); } } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.