Bots Home
|
Create an App
kiratipmenu
Author:
apptester1
Description
Source Code
Launch Bot
Current Users
Created by:
Apptester1
// Title: "Kira's Tip Menu" // Author: d_styles // May 9th 2018 // Used the original from badbadbubba // *** Changes made to the original *** // Added 10 extra items // Changed to one array instead of two // Array is sorted ascending on prices // Changed to one item per line, more readable for the users // Removed the check for menu items as the first item is required // Check for double prices // Removed the separators, not needed // Added a tipmenu command var tip_amnt = 0; var separator = ":heart7 "; var TxtMsg; var MaxItems=30; var tipmenu = []; cb.settings_choices = [ {name:'item1', type:'str', required: true, label:'(E.g. 10--flash boobies) Item 1',}, {name:'item2', type:'str', required: false, label:'(A 0 as price will disable an item) Item 2',}, {name:'item3', type:'str', required: false, label:'Item 3',}, {name:'item4', type:'str', required: false, label:'Item 4',}, {name:'item5', type:'str', required: false, label:'Item 5',}, {name:'item6', type:'str', required: false, label:'Item 6',}, {name:'item7', type:'str', required: false, label:'Item 7',}, {name:'item8', type:'str', required: false, label:'Item 8',}, {name:'item9', type:'str', required: false, label:'Item 9',}, {name:'item10', type:'str', required: false, label:'Item 10',}, {name:'item11', type:'str', required: false, label:'Item 11',}, {name:'item12', type:'str', required: false, label:'Item 12',}, {name:'item13', type:'str', required: false, label:'Item 13',}, {name:'item14', type:'str', required: false, label:'Item 14',}, {name:'item15', type:'str', required: false, label:'Item 15',}, {name:'item16', type:'str', required: false, label:'Item 16',}, {name:'item17', type:'str', required: false, label:'Item 17',}, {name:'item18', type:'str', required: false, label:'Item 18',}, {name:'item19', type:'str', required: false, label:'Item 19',}, {name:'item20', type:'str', required: false, label:'Item 20',}, {name:'item21', type:'str', required: false, label:'Item 21',}, {name:'item22', type:'str', required: false, label:'Item 22',}, {name:'item23', type:'str', required: false, label:'Item 23',}, {name:'item24', type:'str', required: false, label:'Item 24',}, {name:'item25', type:'str', required: false, label:'Item 25',}, {name:'item26', type:'str', required: false, label:'Item 26',}, {name:'item27', type:'str', required: false, label:'Item 27',}, {name:'item28', type:'str', required: false, label:'Item 28',}, {name:'item29', type:'str', required: false, label:'Item 29',}, {name:'item30', type:'str', required: false, label:'Item 30',}, {name: 'chat_ad', type:'int', minValue: 1, maxValue: 60, defaultValue: 4, label: 'Delay in minutes between notice being displayed.'} ]; cb.onMessage(function(msg) { if (msg['m'].indexOf('/tipmenu') == 0) { if (msg['user'] == cb.room_slug) { cb.sendNotice(TxtMsg,'','','#FF0000','bold'); msg['X-Spam'] = true; } else if (msg['has_tokens']) { cb.sendNotice(TxtMsg,msg['user'],'','#FF0000','bold'); msg['X-Spam'] = true; } } }); cb.onTip(function(tip) { tip_amnt=parseInt(tip['amount']); for (var i = 0; i < tipmenu.length; i++) { if (tip_amnt == tipmenu[i][0]) { cb.sendNotice(tip['from_user'] + ' tipped for ' + tipmenu[i][1],'','','#FF0000','bold'); } } }); function makenotice() { TxtMsg = cb.room_slug + '\'s Tip Menu: \n'; tipmenu.sort(function(a, b){ return a[0] - b[0]; }); for (var i = 0; i < tipmenu.length; i++) { TxtMsg += separator + tipmenu[i][1] + '(' + tipmenu[i][0] + ')\n'; } TxtMsg += '**** Type \/tipmenu to show the Tip Menu ****'; } function chatnotice() { cb.sendNotice(TxtMsg,'','','#FF0000','bold'); cb.setTimeout(chatnotice, (cb.settings.chat_ad * 60000)); } function CheckForDoubles() { for (var i = 0; i < tipmenu.length - 1; i++) { for (var c = i + 1; c < tipmenu.length; c++) { if (tipmenu[i][0] == tipmenu[c][0]) { cb.sendNotice('Error.' + tipmenu[i][1] + ' and ' + tipmenu[c][1] + ' have the same price.',cb.room_slug,'#FF0000','','bold'); return 1; } } } } function init() { var pos = 0; for (var i=1; i <= MaxItems; i++) { var tmp; tmp = cb.settings['item' + i]; if (tmp) { var arr = tmp.split('--'); if (arr[1] === undefined) { cb.sendNotice('Error. You need two dashes to separate the tip amount and menu item for item no ' + i,cb.room_slug,'#FF0000','','bold'); } else { var amnt = parseInt(arr[0]); if (amnt > 0) { tipmenu[pos] = []; tipmenu[pos][0] = amnt; tipmenu[pos][1] = arr[1]; pos++; } } } } makenotice(); if (!CheckForDoubles() == 1) { chatnotice(); } } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.