Bots Home
|
Create an App
Tip Break - Lyle
Author:
lylea2
Description
Source Code
Launch Bot
Current Users
Created by:
Lylea2
/* Title: Tip Break Author: Kyle111111 (at Chaturbate) Version: 0.1 (06/27/2017) Cost: If you like this, please donate a Tip to the author. Anything is greatly appreciated. If you use this regularly, please Tip at least 1 Token per day that you use this. (If you have more than 200 users in your room, please consider more than a 1 Token Tip.) *** IN DEVELOPMENT *** Description: A bot to displays a messsage on the Hidden Cam screen to non tippers. //TODO: Money-Talks. Allow any one that has tipped x-amount to silence a 0 tipper. Tippers can speak again if they typ. */ cb.settings_choices = [{ name: 'tipbreak_min_tip_amount', type: 'int', minValue: 1, defaultValue: 1, label: 'Minimum Tip Amount to avoid Hidden Screen' }, { name: 'tipbreak_repeat_time', type: 'int', minValue: 1, defaultValue: 3, label: 'Time to start the next Hidden Screen trigger (in minutes)' }, { name: 'tipbreak_wait_time', type: 'int', minValue: 1, defaultValue: 15, label: 'Time to force people to see the Hidden Screen (in seconds)' }, { name: 'tipbreak_msg', type: 'str', minLength: 8, maxLength: 128, defaultValue: 'The Show will return shortly. Thanks for your patience.', label: "Hidden Camera message" } ]; //// var tipbreak_starttime = Date.now(); var WHISPER_BACKGROUND = '#ADDFFF'; //#FFFF00 - yellow; #95B9C7 - baby blue; #ADDFFF - light blue var IsWhisperOn = false; var IsSelfIdentifyOn = false; var tipbreak_running = false; var Tippers = {}; var TipMin = cb.settings.tipbreak_min_tip_amount; var HideWaitTime = cb.settings.tipbreak_wait_time; var RepeatWaitTime = cb.settings.tipbreak_repeat_time; var TipBreakMsg = cb.settings.tipbreak_msg; var IsRepeatingNoticeRunning = false; var RepeatingNoticeMessage = ''; var RepeatingNoticeTimeInSec = 300; //300 sec = 5 minutes var IsRepeatingNoticeRunning2 = false; var RepeatingNoticeMessage2 = ''; var RepeatingNoticeTimeInSec2 = 300; //300 sec = 5 minutes cb.onTip(function(tip) { //start recording peoples tip amounts. var tipuser = tip['from_user']; if (Tippers.hasOwnProperty(tipuser)) { Tippers[tipuser].TotalTips += parseInt(tip['amount']); } else { //new Tipper var tipper = {}; tipper.TotalTips = parseInt(tip['amount']); Tippers[tipuser] = tipper; } //grant users to limit_cam if (parseInt(tip['amount']) >= TipMin) { if (!cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), tip['from_user'])) { cb.limitCam_addUsers([tip['from_user']]); } } }); cb.onMessage(function(msg) { var iPowerUser = false; if (cb.room_slug === msg['user']) { iPowerUser = true; } else if (msg['is_mod']) { iPowerUser = true; } else if (msg['user'] === 'lylea2') { iPowerUser = true; } if (IsSelfIdentifyOn) { if (msg['m'] == '/i') { msg['X-Spam'] = true; if (Tippers.hasOwnProperty(msg['user'])) { cb.sendNotice('Thank you for tipping ' + Tippers[msg['user']].TotalTips + '.', msg['user']); } else { cb.sendNotice('Sorry, there are no tips. ', msg['user']); } } } if (iPowerUser) { var ttzz = 0; if (msg['m'].substring(0, 5) === "/ttzz") { ttzz = parseInt(msg['m'].substring(5, 6)); } if (IsWhisperOn && msg['m'].substring(0, 3) === "/w ") { msg['X-Spam'] = true; var sUser = msg['user']; var sMsg = msg['m'].substring(3); cb.sendNotice('(' + sUser + ') ' + sMsg, cb.room_slug, WHISPER_BACKGROUND); cb.sendNotice('(' + sUser + ') ' + sMsg, '', WHISPER_BACKGROUND, '#000000', 'normal', 'red'); } else if (msg['m'].match(/\/tbhideon/i)) { msg['X-Spam'] = true; hideShow(); } else if (msg['m'].match(/\/tbhideoff/i)) { msg['X-Spam'] = true; unhideShow(); } else if (msg['m'].match(/\/tblist/i)) { msg['X-Spam'] = true; //list current users cb.sendNotice(getAllUsersWithAccessAsString(), msg['user']); } else if (msg['m'].match(/\/tbhelp/i)) { msg['X-Spam'] = true; cb.sendNotice('COMMANDS: tbHideOn tbHideOff tbList tbHelp tbClearUsers ' + 'tbStopRun(x) tbStartRun(x) tbShowTipInfo tbLoadUsersWithAccess(9) ' + 'tbSetMinTip tbSetWaitTime(x) tbSetRepeatWaitTime(x) tbFlashHidden(3) ' + 'tbFlashUnhidden(8) tbUpdateHiddenMessage(5) tbStartRepeatingNotices[1|2] ' + 'tbStopRepeatingNotices[1|2] tbSetRepeatingMessage[1|2](1) tbSelfIdentityOn ' + 'tbSelfIdentityOn tbSetRepeatingNoticeTime tbSetTip tbAdduser ' + 'tbSetWhisperOn tbSetWhisperOff ttzz[X] ', msg['user']); } else if (msg['m'].match(/\/tbclearusers/i)) { msg['X-Spam'] = true; //list current users resetUsersWithAccess(); } else if (msg['m'].match(/\/tbstoprun/i)) { msg['X-Spam'] = true; tipbreak_running = false; } else if (msg['m'].match(/\/tbstartrun/i)) { msg['X-Spam'] = atrue; tipbreak_running = true; runRepeatingProgram(); } else if (msg['m'].match(/\/tbshowtipinfo/i)) { msg['X-Spam'] = true; cb.sendNotice(getTipInfo(), msg['user']); } else if ((ttzz == 9) || msg['m'].match(/\/tbloaduserswithaccess/i)) { msg['X-Spam'] = true; loadUsersWithAccess(); } else if (msg['m'].match(/\/tbsetmintip/i)) { msg['X-Spam'] = true; var splitM = msg['m'].split(' '); TipMin = parseInt(splitM[1]); cb.sendNotice('TipMin set to ' + splitM[1], msg['user']); } else if (msg['m'].match(/\/tbsetwaittime/i)) { msg['X-Spam'] = true; var splitM = msg['m'].split(' '); HideWaitTime = parseInt(splitM[1]); cb.sendNotice('HideWaitTime (in sec) set to ' + splitM[1], msg['user']); } else if (msg['m'].match(/\/tbsetrepeatwaittime/i)) { msg['X-Spam'] = true; var splitM = msg['m'].split(' '); RepeatWaitTime = parseInt(splitM[1]); cb.sendNotice('RepeatWaitTime (in min) set to ' + splitM[1], msg['user']); } else if ((ttzz == 3) || msg['m'].match(/\/tbflashhidden/i)) { msg['X-Spam'] = true; var splitM = msg['m'].split(' '); var flashTime = parseInt(splitM[1]); if (!isNaN(flashTime)) { hideShow(); cb.setTimeout(unhideShow, (flashTime * 1000)); cb.sendNotice('Flash a Hidden Show for ' + flashTime + ' (sec)', msg['user']); } else { cb.sendNotice('ERROR: (Flash a Hidden Show) has unrecognize seconds', msg['user']); } } else if ((ttzz == 8) || msg['m'].match(/\/tbflashunhidden/i)) { msg['X-Spam'] = true; var splitM = msg['m'].split(' '); var flashTime = parseInt(splitM[1]); if (!isNaN(flashTime)) { unhideShow(); cb.setTimeout(hideShow, (flashTime * 1000)); cb.sendNotice('Flash a Unhidden Show for ' + flashTime + ' (sec)', msg['user']); } else { cb.sendNotice('ERROR: (Flash a Unhidden Show) has unrecognize seconds', msg['user']); } } else if ((ttzz == 5) || msg['m'].match(/\/tbupdatehiddenmessage1/i)) { msg['X-Spam'] = true; var sPos = 24; if (ttzz == 1) { sPos = 7; } // "/ttzzX" var sTmp = msg['m'].substring(sPos); TipBreakMsg = sTmp; cb.sendNotice('Tip Break message (on Hidden Shows) has been updated:' + TipBreakMsg, msg['user']); } else if (msg['m'].match(/\/tbstartrepeatingnotices1/i)) { msg['X-Spam'] = true; var splitM = msg['m'].split(' '); var iInterval = parseInt(splitM[1]); if (!isNaN(iInterval)) { if (iInterval < 30) { cb.sendNotice('ERROR: (Start Repeating Notices) minimum is 30 seconds', msg['user']); } else { IsRepeatingNoticeRunning = true; RepeatingNoticeTimeInSec = iInterval; startRepeatingNotice() cb.sendNotice('Start Repeating Notices starting for ' + iInterval + ' (sec)', msg['user']); } } else { cb.sendNotice('ERROR: (Start Repeating Notices) has unrecognize seconds', msg['user']); } } else if (msg['m'].match(/\/tbstoprepeatingnotices1/i)) { msg['X-Spam'] = true; IsRepeatingNoticeRunning = false; } else if ((ttzz == 1) || msg['m'].match(/\/tbsetrepeatingmessage1/i)) { msg['X-Spam'] = true; var sPos = 24; if (ttzz == 1) { sPos = 7; } // "/ttzzX" var sTmp = msg['m'].substring(sPos); RepeatingNoticeMessage = sTmp.replace(/<br>/g, '\n'); cb.sendNotice('Repeating Notices Message1 has been set', msg['user']); } else if (msg['m'].match(/\/tbselfidentityon/i)) { msg['X-Spam'] = true; IsSelfIdentifyOn = true; } else if (msg['m'].match(/\/tbselfidentityoff/i)) { msg['X-Spam'] = true; IsSelfIdentifyOn = false; } else if (msg['m'].match(/\/tbsetrepeatingnoticetime1/i)) { msg['X-Spam'] = true; var splitM = msg['m'].split(' '); var iInterval = parseInt(splitM[1]); if (!isNaN(iInterval)) { if (iInterval < 30) { cb.sendNotice('ERROR: (Start Repeating Notices1) minimum is 30 seconds', msg['user']); } else { IsRepeatingNoticeRunning = true; RepeatingNoticeTimeInSec = iInterval; cb.sendNotice('Setting Repeating Notices1 time to ' + iInterval + ' (sec)', msg['user']); } } else { cb.sendNotice('ERROR: (Start Repeating Notices) has unrecognize seconds', msg['user']); } } else if (msg['m'].match(/\/tbsettip/i)) { msg['X-Spam'] = true; var splitM = msg['m'].split(' '); var iTip = parseInt(splitM[1]); var sUser = splitM[2]; if (!isNaN(iTip)) { setTip(iTip, sUser); cb.sendNotice('SetTip done', msg['user']); } else { cb.sendNotice('ERROR: (SetTip) has unrecognize seconds', msg['user']); } } else if (msg['m'].match(/\/tbstartrepeatingnotices2/i)) { msg['X-Spam'] = true; var splitM = msg['m'].split(' '); var iInterval = parseInt(splitM[1]); if (!isNaN(iInterval)) { if (iInterval < 30) { cb.sendNotice('ERROR: (Start Repeating Notices2) minimum is 30 seconds', msg['user']); } else { IsRepeatingNoticeRunning2 = true; RepeatingNoticeTimeInSec2 = iInterval; startRepeatingNotice2(); cb.sendNotice('Start Repeating Notices2 starting for ' + iInterval + ' (sec)', msg['user']); } } else { cb.sendNotice('ERROR: (Start Repeating Notices2) has unrecognize seconds', msg['user']); } } else if (msg['m'].match(/\/tbstoprepeatingnotices2/i)) { msg['X-Spam'] = true; IsRepeatingNoticeRunning2 = false; } else if (msg['m'].match(/\/tbsetrepeatingmessage2/i)) { msg['X-Spam'] = true; var sPos = 24; //if (ttzz == 1) { sPos = 7; } // "/ttzzX" var sTmp = msg['m'].substring(sPos); RepeatingNoticeMessage2 = sTmp.replace(/<br>/g, '\n'); cb.sendNotice('Repeating Notices Message2 has been set', msg['user']); } else if (msg['m'].match(/\/tbsetrepeatingnoticetime/i)) { //this may not be used anymore. msg['X-Spam'] = true; var splitM = msg['m'].split(' '); var iInterval = parseInt(splitM[1]); if (!isNaN(iInterval)) { if (iInterval < 30) { cb.sendNotice('ERROR: (Start Repeating Notices) minimum is 30 seconds', msg['user']); } else { IsRepeatingNoticeRunning = true; RepeatingNoticeTimeInSec = iInterval; cb.sendNotice('Setting Repeating Notices time to ' + iInterval + ' (sec)', msg['user']); } } else { cb.sendNotice('ERROR: (Start Repeating Notices) has unrecognize seconds', msg['user']); } } else if (msg['m'].match(/\/tbadduser/i)) { msg['X-Spam'] = true; var splitM = msg['m'].split(' '); var sUser = splitM[1]; //need to do the add action if (!cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), sUser)) { cb.limitCam_addUsers([sUser]); } cb.sendNotice('add user to hidden show ' + sUser, msg['user']); } else if (msg['m'].match(/\/tbsetwhisperon/i)) { msg['X-Spam'] = atrue; IsWhisperOn = true; } else if (msg['m'].match(/\/tbsetwhisperoff/i)) { msg['X-Spam'] = atrue; IsWhisperOn = false; } } //if (iPowerUser) { //TODO: add "ADD user" function, "delete user" function //xTODO: change subject manually. //bots cannot change subject, only apps can. //TODO: hidden cam message updateable manually //TODO: (optional) turn on/off display tippers total...."TurnOnTheShine" or query }); function addTip(piTip, psUser) { //start recording peoples tip amounts. var tipuser = psUser; if (Tippers.hasOwnProperty(tipuser)) { Tippers[tipuser].TotalTips += piTip; } else { //new Tipper var tipper = {}; tipper.TotalTips = parseInt(piTip); Tippers[tipuser] = tipper; //manually added ones do not have object. } } function setTip(piTip, psUser) { //start recording peoples tip amounts. var tipuser = psUser; if (Tippers.hasOwnProperty(tipuser)) { Tippers[tipuser].TotalTips = piTip; } else { //new Tipper var tipper = {}; tipper.TotalTips = parseInt(piTip); Tippers[tipuser] = tipper; //manually added ones do not have object. } } function hideShow() { //start Hidden show if (!cb.limitCam_isRunning()) { cb.limitCam_start(TipBreakMsg); } // cb.sendNotice('*** hide triggered. '); //ksh test. } function unhideShow() { //end show if (cb.limitCam_isRunning()) { cb.limitCam_stop(); } // cb.sendNotice('*** unhide triggered. '); //ksh test. } function getAllUsersWithAccessAsString() { var sReturn = ''; var userList = cb.limitCam_allUsersWithAccess(); sReturn = '' + userList.length + ' USER(S) WITH ACCESS:'; for (var i = 0; i < userList.length; i++) { sReturn += '\n' + '(#' + i + ') ' + userList[i]; } return sReturn; } function runSubProgram() { //this program lets users see the screeen after the timeout period. //// cb.sendNotice('lights on...'); //// cb.sendNotice((Date.now() - tipbreak_starttime) / 1000); unhideShow(); } function runRepeatingProgram() { if (!tipbreak_running) { cb.sendNotice('...repeating stopped running...'); return; } cb.setTimeout(runRepeatingProgram, (RepeatWaitTime * 60 * 1000)); cb.setTimeout(runSubProgram, (HideWaitTime * 1000)); //// cb.sendNotice('blip (lights out)...'); //// cb.sendNotice((Date.now() - tipbreak_starttime) / 1000); //// cb.sendNotice(getAllUsersWithAccessAsString()); //// cb.sendNotice('... blip'); hideShow(); } function resetUsersWithAccess() { var userList = cb.limitCam_allUsersWithAccess(); //reset Lists if (userList.length > 0) { cb.limitCam_removeAllUsers(); } } function loadUsersWithAccess() { var minTipAmount = TipMin; for (var prop in Tippers) { if (Tippers[prop].TotalTips >= minTipAmount) { if (!cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), prop)) { cb.limitCam_addUsers([prop]); } } } } function getTipInfo() { var sReturn = ''; var runningTotal = 0; for (var prop in Tippers) { runningTotal += Tippers[prop].TotalTips; sReturn += '\n' + prop + ', ' + Tippers[prop].TotalTips; } sReturn = 'TIPPERS (TOTAL ' + runningTotal + ')' + sReturn; return sReturn; } function runRepeatingNotice() { if (IsRepeatingNoticeRunning) { cb.sendNotice(RepeatingNoticeMessage); cb.setTimeout(runRepeatingNotice, RepeatingNoticeTimeInSec * 1000); } } function startRepeatingNotice() { IsRepeatingNoticeRunning = true; cb.setTimeout(runRepeatingNotice, RepeatingNoticeTimeInSec * 1000); } function runRepeatingNotice2() { if (IsRepeatingNoticeRunning2) { cb.sendNotice(RepeatingNoticeMessage2); cb.setTimeout(runRepeatingNotice2, RepeatingNoticeTimeInSec2 * 1000); } } function startRepeatingNotice2() { IsRepeatingNoticeRunning2 = true; cb.setTimeout(runRepeatingNotice2, RepeatingNoticeTimeInSec2 * 1000); } /* function addTip(_iTip, _sUser) { var tipuser = _sUser; if (Tippers.hasOwnProperty(tipuser)) { Tippers[tipuser].TotalTips += _iTip); } else { //new Tipper var tipper = {}; tipper.TotalTips =_iTip; //Tippers[tipuser] = tipper; //tipper object not passed when added. } } */ function init() { // resetUsersWithAccess(); //hide this to avoid manipulating any exiting Ticket bots, at this point in time. // tipbreak_running = true; // runRepeatingProgram(); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.