Bots Home
|
Create an App
test123456789
Author:
faketemptest123
Description
Source Code
Launch Bot
Current Users
Created by:
Faketemptest123
/* Title: "Tip Menu" bot based on the original idea of badbadbubba. Additional changes by 4science Version 1.35: More is more ----Contact---- Send complains, suggestions, bug reports and praises to the4science@gmail.com or on twitter @le4science. If you want a faster answer, use twitter. */ var HEART = '\u2665'; // ? BDIAMOND = '\u2666'; // ? BSTAR = '\u2605'; // ? var chatAdTime; var sepChar = "| "; var msg = 'Tip Menu: '; var msgArray = []; var msgPart1 = 'Tip Menu Part 1: \n'; var msgPart2 = 'Tip Menu Part 2: \n'; var msgToken = 1; var maxSep = 9; var maxItems = 24; var tipMenuPrice = []; var tipMenuItem = []; var msgArray1 = []; var msgArray2 = []; var initToken = true; var noticeColor; var splitColor; var menuLength; 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: HEART }, { label: 'Text Diamond', shortcut: BDIAMOND }, { label: 'Text Star', shortcut: BSTAR }, ] 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', defaultValue: 'Vertical Bar', label: "Separator character" }, { name: 'noticecolor', type: 'str', label: 'Notice color (default red...ish #F10060)', defaultValue: '#F10060' }, { 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: 'Do not sort the list', 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: 'splitcolor', type: 'str', required: false, label: 'if you want a different color with the split menu', defaultValue: '#F10060' }, { 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' }, ]; 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', '', '', noticeColor, 'bold'); } else if (msgPart1 != 'Tip Menu Part 1: \n' && !initToken) { if (msgToken == 1) { cb.sendNotice(msgPart1, '', '', noticeColor, 'bold'); msgToken = 2; } else if (msgToken == 2) { cb.sendNotice(msgPart2, '', '', splitColor, 'bold'); msgToken = 1; } } else if (msg != 'Tip Menu: ') { cb.sendNotice(msg, '', '', noticeColor, 'bold'); if (initToken) { initToken = false; } } cb.setTimeout(chatAd, chatAdTime); } function chatAdTimer(){ var 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; } // this should be a only one function but it did not work on the testbed function checkColor() { if (/^#[0-9A-F]{6}$/i.test(cb.settings['noticecolor'])) { return( cb.settings['noticecolor']); } else if (/^[0-9A-F]{6}$/i.test(cb.settings['noticecolor'])) { return ('#' + cb.settings['noticecolor']); } else { cb.sendNotice("Tip Menu - Error while setting the color. Using default value.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); return('#F10060'); } } function checkColorSplit() { if (/^#[0-9A-F]{6}$/i.test(cb.settings['splitcolor'])) { return( cb.settings['splitcolor']); } else if (/^[0-9A-F]{6}$/i.test(cb.settings['splitcolor'])) { return ('#' + cb.settings['splitcolor']); } else { cb.sendNotice("Tip Menu - Error while setting the split menu color. Using default value.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); return('#F10060'); } } function init() { noticeColor = checkColor(); splitColor = checkColorSplit(); chatAdTimer(); for (i = 0; i <= maxSep - 1; i++) { if (cb.settings['sepchar'] == separators[i].label) { sepChar = separators[i].shortcut + ' '; } } for (i = 0; i <= maxItems; i++) { if (cb.settings['item' + i] !== '') { if (cb.settings['itemprice' + i] > 0) { if(cbjs.arrayContains(tipMenuPrice, cb.settings['itemprice' + i])){ cb.sendNotice("Tip Menu - "+cb.settings['itemprice' + i]+" is already on the menu. It is recommanded to have different price for each item.", cb.room_slug, "#FFFFFF", "#FF0000"); } tipMenuPrice.push(cb.settings['itemprice' + i]); tipMenuItem.push(cb.settings['item' + i]); } } } var sorted = []; for (j = 0; j < tipMenuPrice.length; j++) { sorted.push({ "prices": tipMenuPrice[j], "id": j }); } if (cb.settings.listSort !== 'Do not sort the list') { sorted.sort(function(a, b) { if (cb.settings.listSort == 'Ascending') { return a.prices - b.prices; } if (cb.settings.listSort == 'Descending') { return b.prices - a.prices; } }); } for (i = 0; i < sorted.length; i++) { msgArray.push(tipMenuItem[sorted[i]["id"]] + '(' + tipMenuPrice[sorted[i]["id"]] + ') '); } msg += msgArray.join(sepChar); if (cb.settings.listSplit == 'Split the list in 2'){ if ( msgArray.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{ var msglength1 = 0; var msgHalf = (msg.length - 9) / 2; for (i = 0; i < sorted.length; i++) { if (msglength1 < msgHalf) { msgArray1.push(tipMenuItem[sorted[i]["id"]] + '(' + tipMenuPrice[sorted[i]["id"]] + ') '); msglength1 = msgArray1.join(sepChar).length } else { msgArray2.push(tipMenuItem[sorted[i]["id"]] + '(' + tipMenuPrice[sorted[i]["id"]] + ') '); } } msgPart1 += msgArray1.join(sepChar) + '\n To see the full menu type /tipmenu.'; msgPart2 += msgArray2.join(sepChar) + '\n To see the full menu type /tipmenu.'; } } menuLength = tipMenuPrice.length; if (msg != 'Tip Menu: ') { chatAd(); } else { cb.sendNotice('Error - No menu items found', '', '', noticeColor, 'bold'); } } cb.onTip(function(tip) { var tipAmt = parseInt(tip['amount']); for (var i = 0; i < menuLength; i++) { if (tipAmt == tipMenuPrice[i]) { cb.sendNotice(tip['from_user'] + ' tipped for ' + tipMenuItem[i], '', '', noticeColor, 'bold'); } } }); cb.onMessage(function(m) { var u = m['user']; var message = m['m'].split(" "); var isMod = (cb.room_slug == u || m['is_mod']); if (message['0'] == '/tipmenu' || message['0'] == '/menu' ) { m['X-Spam'] = true; m['background'] = '#d9d9d9'; if (isMod) { u = ''; } cb.sendNotice(msg, u, '', noticeColor, 'bold'); return m; } }); cb.onEnter(function(user) { cb.sendNotice('Tip Menu Active! See the full menu at anytime by typing /tipmenu.', user['user'], '', noticeColor, 'bold'); }); init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.