Bots Home
|
Create an App
Private Show Bot
Author:
xxxvenomous
Description
Source Code
Launch Bot
Current Users
Created by:
Xxxvenomous
/** * App: Private Show with Timer * Version: 1.13 * Author: zingknaat * Date: 01.10.14 */ var guestList = []; var lastAllowedUser = '--'; var tipReceived = 0; var lastTipper = '--'; var timeLeft = 0; var showStarted = false; var showPrice = 0; var showLength = 0; var minsShowStarts = 0; cb.settings_choices = [ {name:'minimum_tip_amount', type:'int', minValue:1, label:'Minimum Tip Amount', defaultValue:200}, {name:'show_length', type:'int', label:'Length of Show (in minutes; 0 = infinite)', defaultValue:0}, {name:'minutes_left', type:'int', minValue:1, label:'Minutes Before Show Starts', defaultValue:60}, {name:'allow_late_tippers', type:'choice', label:'Allow Late Tippers', defaultValue:'No', choice1:'Yes', choice2:'No'}, {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']) >= showPrice) { if(!showStarted) { addUser(tip['from_user']); lastAllowedUser = tip['from_user']; } else { if(cb.settings.allow_late_tippers == 'No') { cb.sendNotice('Sorry, but you are too late. The show has already started.', tip['from_user']); } else { addUser(tip['from_user']); cb.limitCam_addUsers([tip['from_user']]); } } } }); cb.onDrawPanel(function(user) { 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) { cb.sendNotice('Welcome to my room, ' + user['user'] + '.', user['user'], '', '#FF0000', 'bold'); cb.sendNotice('The private show will be starting in ' + getTimeLeft() + '.', user['user'], '', '#FF0000', 'bold'); cb.sendNotice('If you would like to join, please tip ' + showPrice + ' tokens.', user['user'], '', '#FF0000', 'bold'); cb.sendNotice('Type /guestlist to see the guest list.', user['user'], '', '#FF0000', 'bold'); }); cb.onMessage(function(msg) { if(msg['m'].match(/\/guestlist/i)) { msg['X-Spam'] = true; showGuestList(msg['user']); } if(msg['m'].match(/\/restartapp/i)) { msg['X-Spam'] = true; if(msg['user'] == cb.room_slug) { resetApp(); } } if(msg['m'].match(/\/stopshow/i)) { msg['X-Spam'] = true; if(msg['user'] == cb.room_slug) { stopShow(); } } if(msg['m'].match(/\/changeprice/i)) { msg['X-Spam'] = true; if(msg['user'] == cb.room_slug) { var userMsg = msg['m'].trim().split(' '); var newPrice = parseInt(userMsg[1]); if(newPrice) { showPrice = newPrice; cb.sendNotice('The private show price has been changed to ' + newPrice + ' tokens.', '', '', '', 'bold'); } } } if(msg['m'].match(/\/changelength/i)) { msg['X-Spam'] = true; if(msg['user'] == cb.room_slug) { var userMsg = msg['m'].trim().split(' '); var newLength = parseInt(userMsg[1]); if(newLength) { var previousTimeLeft = timeLeft; showLength = newLength; if((showLength > 0) && (showStarted)) { timeLeft = showLength * 60; if((previousTimeLeft <= 0) && (timeLeft > 0)) { updateTimeLeft(); } } cb.sendNotice('The private show length has been changed to ' + newLength + ' mins.', '', '', '', 'bold'); } } } if(msg['m'].match(/\/changecountdown/i)) { msg['X-Spam'] = true; if(msg['user'] == cb.room_slug) { var userMsg = msg['m'].trim().split(' '); var newLength = parseInt(userMsg[1]); if(newLength) { var previousTimeLeft = timeLeft; minsShowStarts = newLength; timeLeft = minsShowStarts * 60; if((previousTimeLeft <= 0) && (timeLeft > 0)) { updateTimeLeft(); } cb.sendNotice('The private show countdown has been changed to ' + newLength + ' mins.', '', '', '', 'bold'); } } } 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() { timeLeft = minsShowStarts * 60; if(timeLeft > 0) { updateTimeLeft(); } showStarted = false; guestList = []; lastAllowedUser = '--'; tipReceived = 0; lastTipper = '--'; cb.sendNotice('A new private show will start in ' + getTimeLeft(), '', '', '#0000FF', 'bold'); cb.changeRoomSubject('Tip for Private Show'); } 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 getTimeLeft() { if(timeLeft > 0) { return secondsToHms(timeLeft); } return 0; } function updateTimeLeft() { if(timeLeft) { if(showStarted && (timeLeft == 60)) { cb.sendNotice('WARNING: The private show will end in 1 minute. Please prepare yourself to go public.', cb.room_slug, '#FF0000', '#FFFFFF', 'bold'); for(var i=0;i<guestList.length;i++) { cb.sendNotice('WARNING: The private show will end in 1 minute.', guestList[i], '#FF0000', '#FFFFFF', 'bold'); } } if(!showStarted && (timeLeft == 60)) { cb.sendNotice('FINAL CALL: The private show will begin in 1 minute.', '', '#FF0000', '#FFFFFF', 'bold'); } cb.drawPanel(); timeLeft -= 5; cb.setTimeout(updateTimeLeft, 5000); } else { if(showStarted && showLength > 0) { stopShow(); } else { if(guestList.length > 0) { startShow(); } else { resetApp(); } } } } function startShow() { showStarted = true; cb.changeRoomSubject('Private show in progress'); 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); if(cb.settings.allow_late_tippers == 'No') { cb.limitCam_start('Private show is in progress. Thanks for visiting!'); } else { cb.limitCam_start('Private show is in progress. Tip ' + showPrice + ' to join the show. Otherwise, thanks for visiting!'); } if(showLength > 0) { var previousTimeLeft = timeLeft; timeLeft = showLength * 60; if(previousTimeLeft <= 0) { updateTimeLeft(); } for(var i=0;i<guestList.length;i++) { cb.sendNotice('The show will end in ' + getTimeLeft() + '.', guestList[i], '', '#FF0000', 'bolder'); cb.sendNotice('Please pay attention to the countdown clock.', guestList[i], '', '#FF0000', 'bolder'); cb.sendNotice('The show will end as soon as the clock turns 0.', guestList[i], '', '#FF0000', 'bolder'); } } } function stopShow() { showStarted = false; guestList = []; cb.limitCam_removeAllUsers(); cb.limitCam_stop(); cb.changeRoomSubject('Tip for Private Show'); 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() { cb.sendNotice('Private Show with Timer by zingknaat', '', '', '#0066CC', 'bold'); cb.sendNotice('Type /restartapp to restart the app.', cb.room_slug, '', '#0066CC', 'bold'); if(showStarted) { cb.sendNotice('Type /stopshow to end the private show.', cb.room_slug, '', '#0066CC', 'bold'); } cb.sendNotice('Type /add username to add a user to the guest list.', cb.room_slug, '', '#0066CC', 'bold'); cb.sendNotice('Type /remove username to remove a user from the guest list.', cb.room_slug, '', '#0066CC', 'bold'); cb.sendNotice('Type /changeprice number to change the private show price.', cb.room_slug, '', '#0066CC', 'bold'); cb.sendNotice('Type /changelength number to change the length of the show (0 = infinite).', cb.room_slug, '', '#0066CC', 'bold'); cb.sendNotice('Type /changecountdown number to change the countdown clock.', cb.room_slug, '', '#0066CC', 'bold'); if(!showStarted || (cb.settings.allow_late_tippers == 'Yes')) { cb.sendNotice('Tip ' + showPrice + ' to join the show.', '', '', '#0066CC', 'bold'); } if(!showStarted && timeLeft) { cb.sendNotice('Show starting in ' + getTimeLeft(), '', '', '#0066CC', 'bold'); } cb.sendNotice('Type /guestlist to see the guest list.', '', '', '#0066CC', 'bold'); if(!showStarted) { cb.setTimeout(advertise, cb.settings.notification_time * 60000); } } function init() { cb.changeRoomSubject('Tip for Private Show'); showPrice = cb.settings.minimum_tip_amount; showLength = cb.settings.show_length; minsShowStarts = cb.settings.minutes_left; timeLeft = minsShowStarts * 60; cb.setTimeout(updateTimeLeft(), 1000); advertise(); } init();
© Copyright Freesexcam 2011- 2024. All Rights Reserved.