Bots Home
|
Create an App
Tip Menu Plus 20 PLus
Author:
thenewapache
Description
Source Code
Launch Bot
Current Users
Created by:
Thenewapache
/* Title: "Tip Menu Single Line Plus" bot Author: badbadbubba Version: 1.0.0 (03/07/2016) 1.0.1 (09/08/2016) Improved error checking and reporting 1.0.2 (09/09/2016) Added text character separators */ var HEART = '\u2665'; // ♥ BDIAMOND = '\u2666'; // ♦ BSTAR = '\u2605'; // ★ var tip_amt = 0; var separator_char = "| "; var msg; var MAXITEMS=20; var tipmenuprice = []; var tipmenuitem= []; var MAXSEP = 9; 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}, ] var smallTip_cuml = 0; var smallTipItems= []; var currentSmallTipNumber = 1; var currentSmallTipIndex = -1; var smallTipActive = false; var smallTipRandom = false; 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:'item1', type:'str', label:'Item 1 (eg 10--flash tits)',}, {name:'item2', type:'str', required: false, label:'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:'smallTipRewards', type:'str', required: false, label:'Small Tips rewards - from available menu items (eg 1,2,3)'}, {name:'smallTipMaxTip', type:'int', required: false, label:'Tips under which it count for small tips reward'}, {name:'smallTipOrder', type: 'choice', choice1: 'Sequential', choice2: 'Random', defaultValue: 'Sequential', label: "Small tip rewards order"}, {name:'noticecolor', type:'str', label:'Notice color (html code default red #FF0000)', defaultValue: '#FF0000'}, {name: 'chat_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 1, label: 'Delay in minutes between notice being displayed (minimum 1)'} ]; function GetNewSmallItem() { if(smallTipItems.length == 1) { currentSmallTipNumber = smallTipItems[0]; return; } if(smallTipRandom) { var rand = currentSmallTipIndex; while( rand == currentSmallTipIndex) rand = Math.floor(Math.random() * smallTipItems.length); currentSmallTipNumber = smallTipItems[rand]; currentSmallTipIndex = rand; } else { currentSmallTipIndex++; if(currentSmallTipIndex >= smallTipItems.length) currentSmallTipIndex = 0; currentSmallTipNumber = smallTipItems[currentSmallTipIndex]; } } cb.onTip(function (tip) { tip_amt=parseInt(tip['amount']); for (var i = 1; i <= MAXITEMS; i++) { if (tip_amt == tipmenuprice[i]) { cb.sendNotice(tip['from_user'] + ' tipped for ' + tipmenuitem[i],'','',cb.settings['noticecolor'],'bold'); } } if(smallTipActive) { if(tip_amt < parseInt(cb.settings.smallTipMaxTip)) { if(tip_amt + smallTip_cuml < tipmenuprice[currentSmallTipNumber]) { smallTip_cuml += tip_amt; var tokenleft = tipmenuprice[currentSmallTipNumber] - smallTip_cuml; cb.sendNotice(tokenleft + ' tokens left for small tips reward ['+ tipmenuitem[currentSmallTipNumber] + ']','','',cb.settings['noticecolor'],'bold'); } else { smallTip_cuml = smallTip_cuml + tip_amt - tipmenuprice[currentSmallTipNumber]; cb.sendNotice(tipmenuitem[currentSmallTipNumber] + ' reached by ' + tip['from_user'],'','',cb.settings['noticecolor'],'bold'); GetNewSmallItem(); } } } }); function chatAd() { if (msg!='Tip Menu: ') { cb.sendNotice(msg,'','',cb.settings['noticecolor'],'bold'); } cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); } /* SMALL TIPS REWARD NOTICE */ function chatAdSmallTipReward() { if(smallTipActive) { var msg = 'All tips < ' + parseInt(cb.settings.smallTipMaxTip) + ' tokens will be accumulated until ' + tipmenuprice[currentSmallTipNumber] + ' tokens for the small tips reward [' + tipmenuitem[currentSmallTipNumber] + ']'; cb.sendNotice(msg,'','',cb.settings['noticecolor'],'bold'); cb.setTimeout(chatAdSmallTipReward, (cb.settings.chat_ad * 60000)); } } cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); cb.setTimeout(chatAdSmallTipReward, ((cb.settings.chat_ad * 60000) / 2)); function init() { for (i=0;i<=MAXSEP-1;i++) { if (cb.settings['sepchar'] == separators[i].label) { separator_char = separators[i].shortcut + ' '; } } msg = 'Tip Menu: '; for (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.settings['noticecolor'],'bold'); } else { var amt=parseInt(arr[0]); if (amt>0) { tipmenuprice[i]=amt; tipmenuitem[i]=arr[1]; if (i>=2) { msg += separator_char; } msg += arr[1] + '(' + amt + ') '; } } } } if (msg!= 'Tip Menu: ') { cb.sendNotice(msg,'','',cb.settings['noticecolor'],'bold'); } else { cb.sendNotice('Error-No menu items found','','',cb.settings['noticecolor'],'bold'); } /* small tip rewards initialization */ var tmp = cb.settings['smallTipRewards']; if (tmp) { var smallArr= tmp.split(','); if(smallArr[0] == '' && smallArr.length == 1) return; for(i=0 ; i < smallArr.length; ++i) { var item=parseInt(smallArr[i]); if(item > 0) { smallTipActive = true; smallTipItems[i]=item; } } if(smallTipActive) { if(cb.settings.smallTipOrder == "Random") smallTipRandom = true; GetNewSmallItem(); } } } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.