Apps Home
|
Create an App
Tip Tree
Author:
toyahtiptree
Description
Source Code
Launch App
Current Users
Created by:
Toyahtiptree
/** * App: Tip Tree * Version: 1.00 * Author: toyahtiptree * Date: 14.06.24 */ var lastTipper = '--'; var lastTipAmount = 0; var tipCounter = 0; var lastItem = '--'; cb.settings_choices = [ {name:'item_1', type:'str', label:'Item #1', defaultValue:'show ass'}, {name:'item_1_price', type:'int', label:'Price for item #1', defaultValue:25}, {name:'item_2', type:'str', label:'Item #2 (optional)', defaultValue:'', required:false}, {name:'item_2_price', type:'int', label:'Price for item #2', defaultValue:35}, {name:'item_3', type:'str', label:'Item #3 (optional)', defaultValue:'', required:false}, {name:'item_3_price', type:'int', label:'Price for item #3', defaultValue:45}, {name:'item_4', type:'str', label:'Item #4 (optional)', defaultValue:'', required:false}, {name:'item_4_price', type:'int', label:'Price for item #4', defaultValue:55}, {name:'item_5', type:'str', label:'Item #5 (optional)', defaultValue:'', required:false}, {name:'item_5_price', type:'int', label:'Price for item #5', defaultValue:65}, {name:'notification_wait_time', type:'choice', label:'Time to notify viewers (in minutes)', choice1:1, choice2:2, choice3:3, choice4:4, choice5:5, choice6:10, choice7:15, choice8:20, choice9:25, choice10:30, defaultValue:15} ]; cb.onDrawPanel(function (user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Last Item:', 'row1_value': lastItem, 'row2_label': 'Last Tipper:', 'row2_value': lastTipper + ' (' + lastTipAmount + ')', 'row3_label': 'Tip Jar:', 'row3_value': tipCounter + ' token(s)' }; }); cb.onTip(function (tip) { tipCounter += parseInt(tip['amount']); lastTipAmount = parseInt(tip['amount']); lastTipper = tip['from_user']; lastItem = getItem(tip['amount']); if (lastItem) { cb.sendNotice(tip['from_user'] + ' wants to see: ' + getItem(tip['amount']), '', '#ABFFFB', '#000000', 'bold'); } cb.drawPanel(); }); cb.onEnter(function (user) { var notices = 'Welcome ' + user['user'] + '. ' + cb.room_slug + ' is showing something for a tip.\n'; notices += 'Type /list to see a list of things ' + cb.room_slug + ' will be showing.'; cb.sendNotice(notices, user['user'], '', '', 'bold'); }); cb.onMessage(function(msg) { if(msg['m'].match(/\/list/i)) { msg['X-Spam'] = true; showList(msg['user']); } return msg; }); function getItem(tokens) { for(var i=1;i<=10;i++) { if(parseInt(cb.settings['item_' + i + '_price']) == parseInt(tokens)) { return cb.settings['item_' + i]; } } } function showList(user) { var notices = '***** Tip to See The Following: *****'; for(var i=1;i<=10;i++) { if(cb.settings.get('item_' + i) && (parseInt(cb.settings['item_' + i + '_price']) > 0)) { notices += '\nTip ' + cb.settings['item_' + i + '_price'] + ' for: ' + cb.settings['item_' + i]; } cb.sendNotice(notices, user, '#FCFCD7', '', 'bold'); } } function advertise() { var notices = 'Tip to See by zingknaat\n'; notices += 'Type /list to see a list of things ' + cb.room_slug + ' will be showing.'; cb.sendNotice(notices, '', '', '#AB001C'); cb.setTimeout(advertise, cb.settings.notification_wait_time * 60000); } function init() { advertise(); } init();
© Copyright Sisiva.Com 2011- 2024. All Rights Reserved.