Bots Home
|
Create an App
CelestialPurpleSluts Tip Menu
Author:
celestialpurpleslut
Description
Source Code
Launch Bot
Current Users
Created by:
Celestialpurpleslut
/* Title: "Tip Menu" bot based on the original idea of badbadbubba. Additional changes by 4science Version 1.8: Reach for the stars and more. You can now use your own divider! Simply pick 'Custom' in the drop-down menu and write whatever you want! Even gif! Does this need more exclamation point? I believe so! You can now run a sale, reducing all the price on the menu by X%. Added the option to add or delete options on the menu. You can now toggle on and off a notice when someone request the menu (it currently hides that.) ----Contact---- Send complains, suggestions, bug reports and praises to the4science@gmail.com or on twitter @the4science. If you want a faster answer, use twitter. */ cb.settings_choices = [{ name: 'sepchar', type: 'choice', choice1: 'Vertical Bar', choice2: 'Hearts', choice3: 'Glitter', choice4: 'Flowers', choice5: 'Bow', choice6: 'Hearts2', choice7: 'Smiley', choice8: 'Text Heart', choice9: 'Text Diamond', choice10: 'Text Star', choice11: 'Custom', defaultValue: 'Vertical Bar', label: "Separator character" }, { name: 'sepcharcustom', type: 'str', defaultValue: ':heart2', required: false, label: 'Custom Separator. It can be an gif (Don\'t forget the ":") or a string of characters (&!&).' }, { name: 'menutxtcolor1', type: 'str', label: 'Text color (default red...ish #F10060)', required: false, defaultValue: '#F10060' }, { name: 'menubgcolor1', type: 'str', label: 'Background color (default white #FFFFFF)', required: false, defaultValue: '#FFFFFF' }, { name: 'chatAd', type: 'str', defaultValue: 3, label: 'How often the menu (or each part) will appear in chat. Can do fractions, e.g. 2.5 = two minutes 30 seconds.' }, { name: 'chatNotice', type: 'choice', choice1: 'Display the full menu', choice2: 'Only display the short notice', defaultValue: 'Display the full menu', label: "Do you want the notice to display the full menu or only the short notice ( ei: Type '/tipmenu' to see the menu)" }, { name: 'listSort', type: 'choice', choice1: 'Do not sort the list', choice2: 'Ascending', choice3: 'Descending', defaultValue: 'Ascending', label: "Do you want the list to be sorted by price?" }, { name: 'listSplit', type: 'choice', choice1: 'Do not split the list', choice2: 'Split the list in 2', defaultValue: 'Do not split the list', label: "If you have a very long list, Do you want the list to be split in 2?" }, { name: 'menutxtcolor2', type: 'str', required: false, label: 'You can pick the color for the split menu', defaultValue: '#F10060' }, { name: 'menubgcolor2', type: 'str', required: false, label: 'Split menu background color', defaultValue: '#FFFFFF' }, { name: 'item1', type: 'str', label: "Item 1 " }, { name: 'itemprice1', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, label: 'Item 1 price' }, { name: 'item2', type: 'str', required: false, label: 'Item 2' }, { name: 'itemprice2', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 2 price' }, { name: 'item3', type: 'str', required: false, label: 'Item 3' }, { name: 'itemprice3', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 3 price' }, { name: 'item4', type: 'str', required: false, label: 'Item 4' }, { name: 'itemprice4', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 4 price' }, { name: 'item5', type: 'str', required: false, label: 'Item 5' }, { name: 'itemprice5', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 5 price' }, { name: 'item6', type: 'str', required: false, label: 'Item 6' }, { name: 'itemprice6', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 6 price' }, { name: 'item7', type: 'str', required: false, label: 'Item 7' }, { name: 'itemprice7', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 7 price' }, { name: 'item8', type: 'str', required: false, label: 'Item 8' }, { name: 'itemprice8', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 8 price' }, { name: 'item9', type: 'str', required: false, label: 'Item 9' }, { name: 'itemprice9', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 9 price' }, { name: 'item10', type: 'str', required: false, label: 'Item 10' }, { name: 'itemprice10', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 10 price' }, { name: 'item11', type: 'str', required: false, label: 'Item 11' }, { name: 'itemprice11', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 11 price' }, { name: 'item12', type: 'str', required: false, label: 'Item 12' }, { name: 'itemprice12', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 12 price' }, { name: 'item13', type: 'str', required: false, label: 'Item 13' }, { name: 'itemprice13', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 13 price' }, { name: 'item14', type: 'str', required: false, label: 'Item 14' }, { name: 'itemprice14', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 14 price' }, { name: 'item15', type: 'str', required: false, label: 'Item 15' }, { name: 'itemprice15', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 15 price' }, { name: 'item16', type: 'str', required: false, label: 'Item 16' }, { name: 'itemprice16', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 16 price' }, { name: 'item17', type: 'str', required: false, label: 'Item 17' }, { name: 'itemprice17', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 17 price' }, { name: 'item18', type: 'str', required: false, label: 'Item 18' }, { name: 'itemprice18', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 18 price' }, { name: 'item19', type: 'str', required: false, label: 'Item 19' }, { name: 'itemprice19', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 19 price' }, { name: 'item20', type: 'str', required: false, label: 'Item 20' }, { name: 'itemprice20', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 20 price' }, { name: 'item21', type: 'str', required: false, label: 'Item 21' }, { name: 'itemprice21', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 21 price' }, { name: 'item22', type: 'str', required: false, label: 'Item 22' }, { name: 'itemprice22', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 22 price' }, { name: 'item23', type: 'str', required: false, label: 'Item 23' }, { name: 'itemprice23', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 23 price' }, { name: 'item24', type: 'str', required: false, label: 'Item 24' }, { name: 'itemprice24', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 24 price' }, { name: 'item25', type: 'str', required: false, label: 'Item 25' }, { name: 'itemprice25', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 25 price' }, { name: 'item26', type: 'str', required: false, label: 'Item 26' }, { name: 'itemprice26', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 26 price' }, { name: 'item27', type: 'str', required: false, label: 'Item 27' }, { name: 'itemprice27', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 27 price' }, { name: 'item28', type: 'str', required: false, label: 'Item 28' }, { name: 'itemprice28', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 28 price' }, { name: 'item29', type: 'str', required: false, label: 'Item 29' }, { name: 'itemprice29', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 29 price' }, { name: 'item30', type: 'str', required: false, label: 'Item 30' }, { name: 'itemprice30', type: 'int', minValue: 0, maxValue: 99999, defaultValue: 0, required: false, label: 'Item 30 price' } ]; var chatAdTime; var sepChar = "| "; var tipMenu; var menuPart1; var menuPart2; var menuToken = 1; var tipMenuPrice = []; var backupPrice = []; var tipMenuItem = []; var initToken = true; var menuTColor1; var menuBGColor1; var menuTColor2; var menuBGColor2; var menuLength; var requesters = []; var request = []; //var confirmToken = 0; var sale = false; var discount = 0; //For statistical analysis var noticeView = ["4science", "mr_likes_it_"]; var noticeViewLength = noticeView.length; var help = "Here are the commands available for Tip Menu.\n" + "- /tipmenu: Show the menu in chat.\n" + "- /tipmenurequest: Show the last 10 requests.\n" + "- /tipmenurequest X: Show the last X requests.\n" + "- /tipmenurequest all: Show all the requests (up to 100).\n" + '- /tipmenuadd X Y: Add an item name Y for X token to the menu.\n' + "- /tipmenudel X: Removes every item with a value of X tokens.\n" + "- /tipmenudel X Y: Will only remove an item named Y and the value X\n" + "- /tipmenudel Y: Will removed any item labeled Y independant of the cost.\n" + "- /tipmenusale X: Will reduce the price of each item by X% rounded up.\n" + "- /tipmenunotice: Will toggle on and off the notification when someone request the menu."; var separators = [{ label: 'Hearts', shortcut: ':heart2' }, { label: 'Glitter', shortcut: ':pixelglitter' }, { label: 'Flowers', shortcut: ':tinyflower2' }, { label: 'Bow', shortcut: ':bluebow' }, { label: 'Hearts2', shortcut: ':pixelheart' }, { label: 'Smiley', shortcut: ':smile' }, { label: 'Text Heart', shortcut: '\u2665' }, { label: 'Text Diamond', shortcut: '\u2666' }, { label: 'Text Star', shortcut: '\u2605' } ]; function chatAd() { if (cb.settings.chatNotice === 'Only display the short notice' && !initToken) { cb.sendNotice('Tip menu is active. To see the full tip menu type: /tipmenu', '', menuBGColor1, menuTColor1, 'bold'); } else if (menuPart1 !== 'Tip Menu Part 1: \n' && !initToken) { if (menuToken === 1) { cb.sendNotice(menuPart1, '', menuBGColor1, menuTColor1, 'bold'); menuToken = 2; } else if (menuToken === 2) { cb.sendNotice(menuPart2, '', menuBGColor2, menuTColor2, 'bold'); menuToken = 1; } } else if (tipMenu !== 'Tip Menu: ') { cb.sendNotice(tipMenu, '', menuBGColor1, menuTColor1, 'bold'); if (initToken) { initToken = false; } } else { cb.sendNotice("Something when wrong with the menu.", '', "#FFFFFF", "#FF0000", 'bold'); } cb.setTimeout(chatAd, chatAdTime); } function chatAdTimer() { let timer = parseFloat(cb.settings.chatAd); if (timer < 1) { cb.sendNotice("Tip Menu - Time lapse is to short. Using default value.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); timer = 3; } timer *= 60000; timer = parseInt(timer); chatAdTime = timer; } function checkColor(C, D) { if (/^#[0-9A-F]{6}$/i.test(C)) { return C; } else if (/^[0-9A-F]{6}$/i.test(C)) { return ('#' + C); } else { cb.sendNotice("Tip Menu - Error while setting color. It has to be in a HEX format. Using default value.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); return (D); } } function menuSanitize() { tipMenu = 'Tip Menu: '; menuPart1 = 'Tip Menu Part 1: \n'; menuPart2 = 'Tip Menu Part 2: \n'; let menuArray = []; let menuArray1 = []; let menuArray2 = []; let sorted = []; let menuL = tipMenuPrice.length; for (let i = 0; i < menuL; i++) { sorted.push({ "prices": tipMenuPrice[i], "id": i }); } if (cb.settings.listSort !== 'Do not sort the list') { sorted.sort(function(a, b) { return a.prices - b.prices; }); if (cb.settings.listSort === 'Descending') { sorted.reverse(); } } for (let j = 0; j < sorted.length; j++) { if (tipMenuPrice[sorted[j].id] !== 0) { menuArray.push(tipMenuItem[sorted[j].id] + '(' + tipMenuPrice[sorted[j].id] + ') '); } } tipMenu += menuArray.join(sepChar); if (cb.settings.listSplit === 'Split the list in 2') { if (menuArray.length < 8) { cb.sendNotice("Tip Menu - Error - The menu has less than 8 items, it will not be split.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); } else { let msglength1 = 0; let msgHalf = (tipMenu.length - 9) / 2; for (let k = 0; k < sorted.length; k++) { if (tipMenuPrice[sorted[k].id] !== 0) { if (msglength1 < msgHalf) { menuArray1.push(tipMenuItem[sorted[k].id] + '(' + tipMenuPrice[sorted[k].id] + ') /n'); msglength1 = menuArray1.join(sepChar).length; } else { menuArray2.push(tipMenuItem[sorted[k].id] + '(' + tipMenuPrice[sorted[k].id] + ') /n'); } } } menuPart1 += menuArray1.join(sepChar) + '\n To see the full menu type /tipmenu.'; menuPart2 += menuArray2.join(sepChar) + '\n To see the full menu type /tipmenu.'; } } menuLength = tipMenuPrice.length; if (tipMenu === 'Tip Menu: ') { cb.sendNotice('Error - No menu items found', '', '', menuTColor1, 'bold'); } } function init() { let maxItems = 30; menuTColor1 = checkColor(cb.settings.menutxtcolor1, '#F10060'); menuTColor2 = checkColor(cb.settings.menutxtcolor2, '#F10060'); menuBGColor1 = checkColor(cb.settings.menubgcolor1, '#FFFFFF'); menuBGColor2 = checkColor(cb.settings.menubgcolor2, '#FFFFFF'); chatAdTimer(); if (cb.settings.sepchar === "Custom") { sepChar = cb.settings.sepcharcustom + ' '; } else { let maxSep = 9; for (let i = 0; i <= maxSep - 1; i++) { if (cb.settings.sepchar === separators[i].label) { sepChar = separators[i].shortcut + ' '; } } } for (let j = 0; j <= maxItems; j++) { if (cb.settings['item' + j] !== '' && cb.settings['itemprice' + j] > 0) { if (cbjs.arrayContains(tipMenuPrice, cb.settings['itemprice' + j])) { cb.sendNotice("Tip Menu - " + cb.settings['itemprice' + j] + " is already on the menu. It is recommended to have different price for each item.", cb.room_slug, "#FFFFFF", "#FF0000"); } tipMenuPrice.push(cb.settings['itemprice' + j]); tipMenuItem.push(cb.settings['item' + j]); } } cb.sendNotice("Tip Menu by 4science.", ""); cb.sendNotice('Type /menuhelp to see all the commands.', "", "", "", 'bold'); menuSanitize(); chatAd(); } cb.onTip(function(tip) { let tipAmt = parseInt(tip.amount); for (let i = 0; i < menuLength; i++) { if (tipAmt === tipMenuPrice[i]) { requesters.push(tip.from_user); request.push(tipMenuItem[i]); cb.sendNotice(tip.from_user + ' tipped for ' + tipMenuItem[i], '', menuBGColor1, menuTColor1, 'bold'); } } }); cb.onMessage(function(m) { if (m.m.charAt(0) === "/") { let u = m.user; let message = m.m.split(" "); let isMod = (cb.room_slug === u || m.is_mod); switch (message[0]) { case "/tipmenu": case "/menu": case "/smenu": case "/stipmenu": { m['X-Spam'] = true; m.background = '#d9d9d9'; for (let i = 0; i < noticeViewLength; i++) { if (u !== noticeView[i]) { cb.sendNotice(u + " requested the tip menu.", noticeView[i]); } } if (isMod && message[0] === "/tipmenu" || isMod && message[0] === "/menu") { u = ''; } cb.sendNotice(tipMenu, u, menuBGColor1, menuTColor1, 'bold'); return m; } case "/menuhelp": case "/tipmenuhelp": { m['X-Spam'] = true; m.background = '#d9d9d9'; cb.sendNotice(help, u); return m; } case "/menurequest": case "/tipmenurequest": case "/smenurequest": case "/stipmenurequest": case "/tmr": { m['X-Spam'] = true; m.background = '#d9d9d9'; if (isMod && message[0] === "/menurequest" || isMod && message[0] === '/tipmenurequest') { u = ''; } let rL = request.length; if (rL === 0) { cb.sendNotice("There is no request at the moment.", u, menuBGColor1, menuTColor1); } else { let cmdInt1 = parseInt(message['1']); if (cmdInt1 <= 0) { cb.sendNotice('**** Here are the last 0 requests! :p', u, menuBGColor1, menuTColor1); } else { let noticeMsg; let rS = 0; if (message['1'] === "all" || message['1'] === "All") { cmdInt1 = rL; } else if (cmdInt1 === undefined || isNaN(cmdInt1)) { cmdInt1 = 10; rS = rL - 10; } if (rL <= cmdInt1) { noticeMsg = '**** Here is the list of all the requests! ****\n'; cmdInt1 = rL; rS = 0; } else if (rL > 100) { noticeMsg = '**** Here is are the last 100 requests! ****\n'; rS = rL - 100; } else { noticeMsg = '**** Here ' + (cmdInt1 === 1 ? "is the last" : "are the last " + cmdInt1) + ' request' + (cmdInt1 === 1 ? "" : "s") + '! **** \n'; rS = rL - cmdInt1; } for (let i = rS; i < rL; i++) { noticeMsg += 'Request #' + (i + 1) + ': ' + requesters[i] + ' requested ' + request[i] + '\n'; } noticeMsg += '**************************************'; cb.sendNotice(noticeMsg, u, menuBGColor1, menuTColor1); } } return m; } case "/whorequested": case "/swhorequested": case "/mwr": { m['X-Spam'] = true; m.background = '#d9d9d9'; if (isMod && message['0'] !== '/swhorequested') { u = ''; } let rL = request.length; if (rL === 0) { cb.sendNotice("There is no request at the moment.", u, menuBGColor1, menuTColor1); } else { let itemPrice = parseInt(message['1']); let label; let noticeMsg; let s = 2; if (isNaN(itemPrice)) { s = 1; } for (let i = s; i < message.length; i++) { if (i === s) { label = message[i]; } else { label += " " + message[i]; } } if (itemPrice > 0) { //test for label that contains numbers. It elegant but I'll fix it later let labeltest; for (let i = 1; i < message.length; i++) { if (i === 1) { labeltest = message[i]; } else { labeltest += " " + message[i]; } } cb.log("labeltest is :" + labeltest); if (cbjs.arrayContains(tipMenuItem, labeltest)) { cb.log("labeltest triggered"); for (let i = 0; i < menuLength; i++) { if (labeltest === tipMenuItem[i]) { let reqList = []; for (let j = 0; j < rL; j++) { if (request[j] === tipMenuItem[i]) { reqList.push(requesters[j]); } } if (reqList.length === 0) { noticeMsg = '**** No one has requested ' + tipMenuItem[i] + ' so far. ****'; } else { noticeMsg = '**** Here is the list of everyone that requested ' + tipMenuItem[i] + '! ****\n'; noticeMsg += reqList.join(', '); noticeMsg += '\n**************************************'; } cb.sendNotice(noticeMsg, u, menuBGColor1, menuTColor1); } } } else if (cbjs.arrayContains(tipMenuPrice, itemPrice)) { if (!message[2]) { //cb.sendNotice('Tip menu - No label was found! Every options that match ' + itemPrice + ' tokens will be showed." .', u, "#FFFFFF", "#FF0000", "bold"); for (let i = 0; i < menuLength; i++) { if (itemPrice === tipMenuPrice[i]) { let reqList = []; for (let j = 0; j < rL; j++) { if (request[j] === tipMenuItem[i]) { reqList.push(requesters[j]); } } if (reqList.length === 0) { noticeMsg = '**** No one has requested ' + tipMenuItem[i] + ' so far. ****'; } else { noticeMsg = '**** Here is the list of everyone that requested ' + tipMenuItem[i] + '! ****\n'; noticeMsg += reqList.join(', '); noticeMsg += '\n**************************************'; } cb.sendNotice(noticeMsg, u, menuBGColor1, menuTColor1); } } } else { let labelFound = false; for (let i = 0; i < menuLength; i++) { if (itemPrice === tipMenuPrice[i] && label === tipMenuItem[i]) { labelFound = true; let reqList = []; for (let j = 0; j < rL; j++) { if (request[j] === tipMenuItem[i]) { reqList.push(requesters[j]); } } if (reqList.length === 0) { noticeMsg = '**** No one has requested ' + tipMenuItem[i] + ' so far. ****'; } else { noticeMsg = '**** Here is the list of everyone that requested ' + tipMenuItem[i] + '! ****\n'; noticeMsg += reqList.join(', '); noticeMsg += '\n**************************************'; } cb.sendNotice(noticeMsg, u, menuBGColor1, menuTColor1); } } if (!labelFound) { cb.sendNotice("Tip menu - Unable find item " + label + "(" + itemPrice + ") on the menu. Skipping.", u, "#FFFFFF", "#FF0000", "bold"); } } } else { cb.sendNotice("Tip menu - Unable find any item at " + itemPrice + " tokens on the menu.", u, "#FFFFFF", "#FF0000", "bold"); } } else { if (!label) { cb.sendNotice('Tip menu - Unable to process. Use "/tipmenudel X Label". Where X is the amount of tokens and label is the name of the item.', u, "#FFFFFF", "#FF0000", "bold"); } else if (cbjs.arrayContains(tipMenuItem, label)) { for (let i = 0; i < menuLength; i++) { if (label === tipMenuItem[i]) { let reqList = []; for (let j = 0; j < rL; j++) { if (request[j] === tipMenuItem[i]) { reqList.push(requesters[j]); } } if (reqList.length === 0) { noticeMsg = '**** No one has requested ' + tipMenuItem[i] + ' so far. ****'; } else { noticeMsg = '**** Here is the list of everyone that requested ' + tipMenuItem[i] + '! ****\n'; noticeMsg += reqList.join(', '); noticeMsg += '\n**************************************'; } cb.sendNotice(noticeMsg, u, menuBGColor1, menuTColor1); } } } else { cb.sendNotice("Tip menu - Unable find item " + label + " on the menu. Skipping.", u, "#FFFFFF", "#FF0000", "bold"); } } } return m; } case "/menusale": case "/tipmenusale": { m['X-Spam'] = true; m.background = '#d9d9d9'; if (!isMod) { cb.sendNotice("Only mods and broadcasters can use this command.", u, "#FFFFFF", "#FF0000"); } else { discount = parseInt(message['1']); if (message['1'] === "off" || discount === 0) { if (!sale) { cb.sendNotice("Items on the menu are at regular price.", "", "#FFFFFF", "#FF0000"); } else { tipMenuPrice.splice(0, tipMenuPrice.length, ...backupPrice); cb.sendNotice("The sale is now off.", "", menuBGColor1, menuTColor1); menuSanitize(); cb.sendNotice(tipMenu, "", menuBGColor1, menuTColor1, 'bold'); sale = false; } } else { if (discount < 0 || isNaN(discount) || discount >= 100) { cb.sendNotice("X has be be a number between 0 and 99. It will be the percentage taken off the price.", u, "#FFFFFF", "#FF0000"); } else { if (sale) { tipMenuPrice.splice(0, tipMenuPrice.length, ...backupPrice); } else { backupPrice.splice(0, backupPrice.length, ...tipMenuPrice); } for (let i = 0; i < menuLength; i++) { tipMenuPrice[i] = Math.ceil(tipMenuPrice[i] * (1 - discount / 100)); } menuSanitize(); cb.sendNotice("All item on the tip menu are now " + discount + "% off!", "", menuBGColor1, menuTColor1, 'bold'); cb.sendNotice(tipMenu, "", menuBGColor1, menuTColor1, 'bold'); sale = true; } } } return m; } case "/tipmenunotice": { m['X-Spam'] = true; m.background = '#d9d9d9'; if (!isMod) { cb.sendNotice("Only mods and broadcasters can use this command.", u, "#FFFFFF", "#FF0000"); return m; } if (cbjs.arrayContains(noticeView, u)) { cbjs.arrayRemove(noticeView, u); noticeViewLength--; cb.sendNotice("Tip menu - You will no longer see who request the tip menu.", u); } else { noticeView.push(u); noticeViewLength++; cb.sendNotice("Tip menu - You will now see who request the tip menu.", u); } return m; } case "/menuadd": case "/tipmenuadd": { m['X-Spam'] = true; m.background = '#d9d9d9'; if (!isMod) { cb.sendNotice("Only mods and broadcasters can use this command.", u, "#FFFFFF", "#FF0000"); } else { let label; let newItemPrice = parseInt(message['1']); if (newItemPrice <= 0 || isNaN(newItemPrice)) { cb.sendNotice('The correct format is "/menuadd X item" where X has to be a number over 0. This is the amount the viewers will tip for it.', u, "#FFFFFF", "#FF0000"); return m; } if (!message[2]) { cb.sendNotice("You need to include a label for that option.", u, "#FFFFFF", "#FF0000"); return m; } for (let j = 2; j < message.length; j++) { if (j === 2) { label = message[j]; } else { label += " " + message[j]; } } cb.sendNotice("Tip menu to Broadcaster - " + (u === cb.room_slug ? "You" : u) + ' added the option "' + label + '" for ' + newItemPrice + ' tokens to the menu.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); cb.sendNotice("Tip menu to mods - " + u + ' added the option "' + label + '" for ' + newItemPrice + ' tokens the menu.', "", "#FFFFFF", "#FF0000", "bold", "red"); if (sale) { cb.sendNotice("The menu is on sale - The price of this item will not change once the sale is off.", u, "#FFFFFF", "#FF0000", "bold"); } if (cbjs.arrayContains(tipMenuPrice, newItemPrice)) { cb.sendNotice("Tip Menu - " + newItemPrice + " is already on the menu. It is recommended to have different price for each item.", u, "#FFFFFF", "#FF0000"); } tipMenuPrice.push(newItemPrice); tipMenuItem.push(label); backupPrice.push(newItemPrice); menuSanitize(); } return m; } case "/menudel": case "/tipmenudel": { m['X-Spam'] = true; m.background = '#d9d9d9'; if (!isMod) { cb.sendNotice("Only mods and broadcasters can use this command.", u, "#FFFFFF", "#FF0000"); } else { let itemPrice = parseInt(message['1']); let label; let s = 2; if (isNaN(itemPrice)) { s = 1; } for (let i = s; i < message.length; i++) { if (i === s) { label = message[i]; } else { label += " " + message[i]; } } if (itemPrice <= 0) { cb.sendNotice("Tip menu - Error! X need to be over 0 tokens.", "", "#FFFFFF", "#FF0000", "bold"); return m; } if (itemPrice > 0) { if (cbjs.arrayContains(tipMenuPrice, itemPrice)) { if (!message[2]) { cb.sendNotice('Tip menu - No label was found! Every options that match "' + itemPrice + '" will be removed from the menu.', u, "#FFFFFF", "#FF0000", "bold"); for (let i = 0; i < menuLength; i++) { if (itemPrice === tipMenuPrice[i]) { tipMenuPrice[i] = 0; if (sale) { backupPrice[i] = 0; } cb.sendNotice("Tip menu to Broadcaster - " + (u === cb.room_slug ? "You" : u) + ' removed the option "' + tipMenuItem[i] + '" from the menu.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); cb.sendNotice("Tip menu to mods - " + u + ' removed the option "' + tipMenuItem[i] + '" from the menu.', "", "#FFFFFF", "#FF0000", "bold", "red"); } } menuSanitize(); } else { let labelFound = false; for (let i = 0; i < menuLength; i++) { if (itemPrice === tipMenuPrice[i] && label === tipMenuItem[i]) { labelFound = true; tipMenuPrice[i] = 0; if (sale) { backupPrice[i] = 0; } cb.sendNotice("Tip menu to Broadcaster - " + (u === cb.room_slug ? "You" : u) + ' removed the option "' + tipMenuItem[i] + '" from the menu.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); cb.sendNotice("Tip menu to mods - " + u + ' removed the option "' + tipMenuItem[i] + '" from the menu.', "", "#FFFFFF", "#FF0000", "bold", "red"); menuSanitize(); } } if (!labelFound) { cb.sendNotice("Tip menu - Unable find item " + label + "(" + itemPrice + ") on the menu. Skipping.", u, "#FFFFFF", "#FF0000", "bold"); } } } else { cb.sendNotice("Tip menu - Unable find any item at " + itemPrice + " tokens on the menu.", u, "#FFFFFF", "#FF0000", "bold"); } } else { if (!label) { cb.sendNotice('Tip menu - Unable to process. Use "/tipmenudel X Label". Where X is the amount of tokens and label is the name of the item.', u, "#FFFFFF", "#FF0000", "bold"); } else if (cbjs.arrayContains(tipMenuItem, label)) { for (let i = 0; i < menuLength; i++) { if (label === tipMenuItem[i]) { tipMenuPrice[i] = 0; if (sale) { backupPrice[i] = 0; } cb.sendNotice("Tip menu to Broadcaster - " + (u === cb.room_slug ? "You" : u) + ' removed the option "' + tipMenuItem[i] + '" from the menu.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); cb.sendNotice("Tip menu to mods - " + u + ' removed the option "' + tipMenuItem[i] + '" from the menu.', "", "#FFFFFF", "#FF0000", "bold", "red"); } } menuSanitize(); } else { cb.sendNotice("Tip menu - Unable find item " + label + " on the menu. Skipping.", u, "#FFFFFF", "#FF0000", "bold"); } } } return m; } // case "/menuconfirm": // m['X-Spam'] = true; // m['background'] = '#d9d9d9'; // if (!isMod) { // cb.sendNotice("Only mods and broadcasters can use this command.", u, "#FFFFFF", "#FF0000"); // return m; // } else { // if (confirmToken === 0) { // cb.sendNotice("Tip menu - There is currently no change to approve.", u, "#FFFFFF", "#FF0000"); // return m; // } // if (confirmToken === 1) { // cb.sendNotice("Tip menu - There is currently no change to approve.", u, "#FFFFFF", "#FF0000"); // } // } default: { return m; } } } return m; }); cb.onEnter(function(user) { let isMod = (cb.room_slug === user.user || user.is_mod); cb.sendNotice('Tip Menu Active! See the full menu at anytime by typing /tipmenu.', user.user, menuBGColor1, menuTColor1, 'bold'); if (isMod) { cb.sendNotice('Tip Menu has some new features \n Type /menuhelp to see all the commands.', user.user); } }); init();
© Copyright Freesexcam 2011- 2024. All Rights Reserved.