Bots Home
|
Create an App
MultiLine Tip Menu
Author:
jmmprogrammer
Description
Source Code
Launch Bot
Current Users
Created by:
Jmmprogrammer
var HEART = '\u2665'; // BDIAMOND = '\u2666'; // BSTAR = ' \u2605 '; // WSTAR = ' \u2606 '; // var _timerIntervalMultiplier = 1; var _totalTips = 0; var tip_amt = 0; var separator_char = "\n "; 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 _blockGreyUsers = true; cb.settings_choices = [ {name: 'blockgrey', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Block messages from users without tokens. Once the bot is running you can unblock users without tokens by entering !unblockgrey during the session. To re-block, type !blockgrey'}, {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:'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)'}, {name: 'repeatingGoalValue', type:'int', minValue: 1, maxValue: 10000, defaultValue: 100, label:'Goal Amount'}, {name: 'repeatingGoalText', type:'str', label:'Goal Description -- Leave blank if you do not want one.'} ]; cb.onMessage(function (msg) { // // only the broadcaster or a mod can kickoff the countdown // if(( msg['user'] == cb.room_slug )||(msg['is_mod'] == true)){ if ( msg['m'] == '!unblockgrey' ){ _blockGreyUsers = false; msg['X-Spam'] = true; } if ( msg['m'] == '!blockgrey' ){ _blockGreyUsers = true; msg['X-Spam'] = true; } } if ( _blockGreyUsers ){ // // if grey user (someone with no tokens) // if( msg['has_tokens'] == false ){ msg['X-Spam'] = true; cb.sendNotice( 'I\'m so sorry ' + msg['user'] +', but after a lot of abuse from users who are unwilling to purchase tokens, I have been forced to block your message. If you are one of my regulars, and you would still like to stop in and say HI, do us both a favor and purchase a few tokens. For reals... will it really break the bank? :)', msg['user'], '', '', '', ''); } } return msg; }); cb.onTip(function (tip) { tip_amt = parseInt(tip['amount']); _totalTips += tip_amt; // // Update the goal progess // if ( _configuredGoalText ) { _goalAmountSoFar += tip_amt; if ( _goalAmountSoFar >= _configuredGoalAmount ) { _goalAchieved = true; } drawGoalProgress(); } // // Loop through all 20 items and look to see if the tip amount // matches a configured menu item. // 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'); cb.sendNotice("\n=== TIME TO DELIVER ===", cb.room_slug, "#FFFF00", "", "bold", ""); cb.sendNotice("\"" + tip['from_user'] + "\" paid for an item from your menu.", cb.room_slug, "#FFFF00", "", "bold", ""); cb.sendNotice("Item: \"" + tipmenuitem[i] + "\"\n", cb.room_slug, "#FFFF00", "", "bold", ""); } } }); // // Timer for printing the menu to the chat // function chatAd() { if( cb.settings['item1']) { cb.sendNotice( msg,'','',cb.settings['noticecolor'],'bold'); } else{ _timerIntervalMultiplier = 1; } cb.setTimeout(chatAd, (_timerIntervalMultiplier * 60000)); } cb.setTimeout(chatAd, (_timerIntervalMultiplier * 60000)); // // Timer for adding the goal to the chat // function AddGoalToChat() { if ( _configuredGoalText) { drawGoalProgress(); cb.setTimeout(AddGoalToChat, (60000)); } else{ cb.setTimeout(AddGoalToChat, (0)); } } cb.setTimeout(AddGoalToChat, (60000)); var _configuredGoalAmount = 0; var _configuredGoalText = ''; var _goalAmountSoFar = 0; var _goalTimesAchieved = 0; var _goalAchieved = false; function drawGoalProgress(){ if ( _goalAchieved == true ) { // // Message for the users // var str = '\n' + _goalAmountSoFar + ' TOKENS COLLECTED!!! GOAL ACHIEVED!!!\n'; str += 'GOAL REWARD: \"' + _configuredGoalText + '\" \n'; cb.sendNotice( str,'','#CCCCFF','#000000','bold'); // // Message for the broadcaster // cb.sendNotice('\n=== GOAL ACHIEVED=== \n=== TIME TO DELIVER === ', cb.room_slug, '#FFFF00', '', 'bold', ''); cb.sendNotice('\"' + _configuredGoalText + '\" \n', cb.room_slug, '#FFFF00', '', 'bold', ''); _goalAchieved = false; _goalTimesAchieved = ~~( _totalTips / _configuredGoalAmount ); _goalAmountSoFar = _totalTips % _configuredGoalAmount; } else{ // // Message for the users // var str = 'GOAL: \"' + _configuredGoalText + '\" \nPROGRESS: ' + _goalAmountSoFar + '/' + _configuredGoalAmount + ' achieved \n ' + graphicalPercent(_configuredGoalAmount, _goalAmountSoFar); if( _goalTimesAchieved >= 1 ) { str += '\nGOALS ACHIEVED: ' + _goalTimesAchieved; } cb.sendNotice( str,'','#CCCCFF','#000000',''); } } // // Returns a string that is a graph showing the percent completed the goal is. // The string uses black and white stars as a graphical representation. // function graphicalPercent(cfgNum, soFarNum){ var numberOfStars = 15; var returnString = ''; var normalized = cfgNum / numberOfStars; // normalize to numberOfStars since our graph has numberOfStars in it var blackStars = ~~( soFarNum / normalized ); // round it off to the interval var whiteStars = numberOfStars - blackStars; for( var x = 0; x < blackStars; x++ ) { returnString += BSTAR; } for( var y = 0; y < whiteStars; y++ ) { returnString += WSTAR; } return returnString; } function init() { // // If there is at least one menu item configured // if( cb.settings['item1']) { _timerIntervalMultiplier = parseInt( cb.settings.chat_ad ); cb.sendNotice('INTERVAL: ' + _timerIntervalMultiplier,'','',cb.settings['noticecolor'],'bold'); } // // What is the configured goal amount? // What is the configured goal description? // _configuredGoalAmount = parseInt(cb.settings['repeatingGoalValue']); _configuredGoalText = cb.settings['repeatingGoalText']; if ( _configuredGoalText ) { cb.sendNotice( 'LOADING the new goal.','','','#0000AA','bold'); drawGoalProgress(); } // // Handle whether or not to block users with no tokens // if( cb.settings['blockgrey'] == "No"){ _blockGreyUsers = false; } // // Start constructing the text for the menu. // msg = 'Tip Menu: \n Being nice (0)\n'; // // Look at all 20 slots and see if anything is in any of them. // If so, parse the text and add the item to the 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 += "\n"; } msg += "" + arr[1] + ' (' + amt + ') '; } } } } msg += "\n If you are unwilling to tip, please be equally unwilling to make demands."; // // Print the start up message to verify that everything loaded correctly // This message will display regardless of whether or not there are any menu items. // cb.sendNotice( "LOADING: " + msg,'','',cb.settings['noticecolor'],'bold'); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.