Bots Home
|
Create an App
Test OP
Author:
adinner
Description
Source Code
Launch Bot
Current Users
Created by:
Adinner
var guestList = []; var lastAllowedUser = '--'; var tipReceived = 0; var lastTipper = '--'; var showStarted = false; var showEnded = false; var showPrice = 0; var tokensToStart = 0; cb.settings_choices = [ {name:'tokens_per_minute', type:'int', minValue:1, label:'Tokens Per Minute', defaultValue:12}, {name:'tokens_to_start', type:'int', minValue:10, label:'Tokens To Start', defaultValue:30}, {name:'notification_time', type:'choice', label:'Notification Time (in minutes)', choice1:1, choice2:2, choice3:3, choice4:4, choice5:5, choice6:10, choice7:15, choice8:20, choice9:25, choice10:30, defaultValue:5} ]; cb.onTip(function (tip) { lastTipper = tip['from_user']; tipReceived += parseInt(tip['amount']); if(parseInt(tip['amount']) >= tokensToStart) { if(!showStarted) { addUser(tip['from_user']); lastAllowedUser = tip['from_user']; } else { addUser(tip['from_user']); cb.limitCam_addUsers([tip['from_user']]); } } cb.drawPanel(); }); /*cb.onDrawPanel(function(user) { if(showStarted) { return { 'template': '3_rows_12_21_31', 'row1_label': 'Tip Received', 'row1_value': tipReceived + ' token(s)', 'row2_value': 'The show is in progress.', 'row3_value': 'Tip ' + showPrice + ' to join the show' } } else { if(showEnded) { return { 'template': '3_rows_12_21_31', 'row1_label': 'Tip Received', 'row1_value': tipReceived + ' token(s)', 'row2_value': 'The show has ended.', 'row3_value': 'Thank you for your support!' } } else { return { 'template': '3_rows_12_22_31', 'row1_label': 'Countdown', //'row1_value': getTimeLeft(), 'row2_label': 'Tip Received', 'row2_value': tipReceived + ' token(s)', 'row3_value': 'Tip ' + showPrice + ' to join the show' } } } });*/ cb.onEnter(function(user) { if(showStarted) { var msg = 'Welcome, ' + user['user'] + '. \n'; msg += 'There is a private show going on.'; cb.sendNotice(msg, user['user'], '', '#FF0000', 'bold'); } }); cb.onMessage(function(msg) { if(msg['m'].match(/\/guestlist/i)) { msg['X-Spam'] = true; if(msg['user'] == cb.room_slug) { showGuestList(msg['user']); } } if(msg['m'].match(/\/startshow/i)) { msg['X-Spam'] = true; if(msg['user'] == cb.room_slug) { startShow(); } } if(msg['m'].match(/\/stopshow/i)) { msg['X-Spam'] = true; if(msg['user'] == cb.room_slug) { stopShow(); } } if(msg['m'].match(/\/add/i)) { msg['X-Spam'] = true; if(msg['user'] == cb.room_slug) { var userMsg = msg['m'].trim().split(' '); var username = userMsg[1]; if(username) { addUser(username); cb.limitCam_addUsers(guestList); } } } if(msg['m'].match(/\/remove/i)) { msg['X-Spam'] = true; if(msg['user'] == cb.room_slug) { var userMsg = msg['m'].trim().split(' '); var username = userMsg[1]; if(username) { var userIndex = guestList.indexOf(username); guestList.splice(userIndex,1); cb.limitCam_removeUsers([username]); cb.sendNotice(username + ' has been removed from the guest list.', '', '', '#006600'); } } } return msg; }); function addUser(username) { if(guestList.indexOf(username) < 0) { guestList.push(username); // cb.sendNotice(username + ' has been added to the private show guest list.', '', '#CCFFCC', '', 'bold'); } } function resetApp() { showStarted = false; guestList = []; lastAllowedUser = '--'; tipReceived = 0; lastTipper = '--'; } function secondsToHms(d) { d = Number(d); var h = Math.floor(d / 3600); var m = Math.floor(d % 3600 / 60); var s = Math.floor(d % 3600 % 60); return ((h > 0 ? h + ' hrs ' : '') + (m > 0 ? (h > 0 && m < 10 ? '0' : '') + m + ' mins ' : ' ') + (s < 10 ? '0' : '') + s + ' secs'); } function startShow() { advertise(); showStarted = true; cb.sendNotice('The private show has started.', cb.room_slug, '#FF0000', '#FFFFFF', 'bold'); for(var i=0;i<guestList.length;i++) { cb.sendNotice('The private show has started.', guestList[i], '#FF0000', '#FFFFFF', 'bold'); } cb.limitCam_addUsers(guestList); cb.limitCam_start('Private show is in progress. Tip ' + showPrice + ' to join the show. Otherwise, thanks for visiting!'); } function stopShow() { showStarted = false; showEnded = true; guestList = []; cb.limitCam_removeAllUsers(); cb.limitCam_stop(); cb.sendNotice('The private show has ended.', '', '#FF0000', '#FFFFFF', 'bold'); } function showGuestList(username) { cb.sendNotice('#### PRIVATE SHOW GUEST LIST ####', username); var rowNum = 1; for(var i=0;i<guestList.length;i++) { cb.sendNotice(rowNum + ') ' + guestList[i], username); rowNum++; } } function advertise() { var msg = ''; msg += 'Type /startshow to restart the app.'; if(showStarted) { msg += 'Type /stopshow to end the private show.'; } msg += 'Type /add username to add a user to the guest list.'; msg += 'Type /remove username to remove a user from the guest list.'; msg += 'Type /changeprice number to change the private show price.'; cb.sendNotice(msg, cb.room_slug, '', '#0066CC', 'bold'); var msg = 'Private Show In Progress!'; if(!showStarted) { msg += 'Tip ' + showPrice + ' per minute to join the show.'; } cb.sendNotice(msg, '', '', '#0066CC', 'bold'); if(!showStarted) { cb.setTimeout(advertise, cb.settings.notification_time * 60000); } } function init() { showPrice = cb.settings.tokens_per_minute; tokensToStart = cb.settings.tokens_to_start; } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.