Bots Home
|
Create an App
MasturBOT
Author:
slave_4_lady
Description
Source Code
Launch Bot
Current Users
Created by:
Slave_4_Lady
/** * Bot: MasturBOT * Version: 1.0 * Author: slave_4_lady * Date: 04.02.16 */ cb.settings_choices = [ {name:'action', type:'str', minLength:1, maxLength:255, defaultValue:"MASTURBATING", label:'Action to perform (ending with "ing")'}, {name:'minimum', type:'int', minValue:3, defaultValue:30, label: "Minimum Time (in minutes)"}, {name:'finish', type:'int', minValue:3, defaultValue:15, label: "Finish Time (in minutes)"}, {name:'reminder1', type:'int', minValue:0, defaultValue:5, label: "1st Reminder Time (in minutes)"}, {name:'reminder2', type:'int', minValue:0, defaultValue:10, label: "2nd Reminder Time (in minutes)"}, {name:'bathroom', type:'int', minValue:0, defaultValue:120, label: "Bathroom Break Time (in minutes, optional)"}, {name:'forTips', type:'choice', choice1:'no', choice2:'yes', defaultValue: 'no', label: "For Tips instead of messages?"}, {name:'minimumTip', type:'int', minValue:0, defaultValue:1, label: "Minimum Tip"}, {name:'increaseTipBy', type:'int', minValue:0, defaultValue:1, label: "Increase Tip By"}, {name:'increaseTipTime', type:'int', minValue:1, defaultValue:1, label: "Increase Tip Interval (in minutes)"}, {name:'highlightColor', type:'str', minLength:7, maxLength:7, defaultValue:"#FFFF00", label:'Highlight Color (hex value)'} ]; var minimum = cb.settings.minimum; //minutes var reminder1 = cb.settings.reminder1; //minutes var reminder2 = cb.settings.reminder2; //minutes var finish = cb.settings.finish; //minutes var bathroom = cb.settings.bathroom; //minutes var action = cb.settings.action; // str var highlightColor = cb.settings.highlightColor; // str var delay = minimum > finish ? minimum - finish : 0; var msPerMin = 60000; var startTime; //time in ms var sessionStarted = false; var lastMessageTime; //time in ms var stopTime = false; //time in ms var waitAfterStop = 5; // minutes var forTips = cb.settings.forTips == "yes" ? true : false; // flag var minimumTip = cb.settings.minimumTip; // tokens var orginalMimimumTip = cb.settings.minimumTip; // tokens var currentMinimumTip = cb.settings.minimumTip; // tokens var increaseTipBy = cb.settings.increaseTipBy; // tokens var increaseTipTime = cb.settings.increaseTipTime; // minutes var updateTip = false; // flag function getS(qty) { if(qty > 1) { return "s"; } return ""; } function getExc(qty) { var totalMinutes = (new Date().getTime() - startTime) / msPerMin; if(totalMinutes > 20) { return "!"; } return "."; } var extendAction = forTips ? "sends another tip of at least " + minimumTip + " token" + getS(minimumTip) : "posts another message here"; cb.sendNotice("Thanks for using MasturBOT! Author: slave_4_lady.", "", highlightColor); cb.sendNotice("Enter ccstart to start your session.", cb.room_slug, highlightColor); cb.sendNotice("Enter ccstop to stop your session, though you will be punished if you do!.", cb.room_slug, highlightColor); function timeSinceStart() { var totalMinutes = (new Date().getTime() - startTime) / msPerMin; var timeSinceStart = parseMinutes(totalMinutes) if(timeSinceStart == "") { return false; } return timeSinceStart; } function parseMinutes(totalMinutes) { var timeString = ""; var hours = Math.floor(totalMinutes / 60); if(hours > 0) { timeString += hours + " hour" + getS(hours); } var minutes = Math.round(totalMinutes % 60); if(minutes > 0) { var minuteString = minutes + " minute" + getS(minutes); if(timeString != "") { timeString += " "; // add space after 'hour' } timeString += minuteString; } return timeString; } function setExtendAction() { extendAction = forTips ? "sends another tip of at least " + currentMinimumTip + " token" + getS(minimumTip) : "posts another message here"; } function showNotice(minutes) { setExtendAction() if(timeSinceStart() !== false) { cb.sendNotice(cb.room_slug + " has been " + action + " for " + timeSinceStart() + getExc(), "", highlightColor); } cb.sendNotice(cb.room_slug + " will be allowed to stop " + action + " in " + parseMinutes(minutes) + " if nobody " + extendAction + ".", "", highlightColor); } function checkNotices() { if(sessionStarted === true) { var time = new Date().getTime(); if(time > lastMessageTime + (finish * msPerMin)) { sessionStarted = false; minimumTip = currentMinimumTip; // in case we start again after timing out var notice = "############## SESSION OVER ##############\n"; notice += cb.room_slug + " is allowed to stop " + action + " now. " + cb.room_slug + " should have only been " + action + " or performing other acts specified in the session rules since the session started " + timeSinceStart() + " ago.\n"; notice += "############## THANKS FOR WATCHING! ########"; cb.sendNotice(notice, "", highlightColor); } else { incrementMinTip(); if(time > lastMessageTime && time < lastMessageTime + msPerMin - 1) { showNotice(finish); showTipIncrease(); } else if(reminder1 > 0 && time > lastMessageTime + (reminder1 * msPerMin) && time < lastMessageTime + ((reminder1 + 1) * msPerMin) - 1) { showNotice(finish - reminder1); showTipIncrease(); } else if(reminder2 > 0 && time > lastMessageTime + (reminder2 * msPerMin) && time < lastMessageTime + ((reminder2 + 1) * msPerMin) - 1) { showNotice(finish - reminder2); showTipIncrease(); } else if (updateTip) { showNotice(finish - (Math.round(new Date().getTime() - lastMessageTime) / msPerMin)); showTipIncrease(); } setTimeout(checkNotices, msPerMin); } } } function showTipIncrease() { if (forTips === true && increaseTipBy > 0) { cb.sendNotice("( The required tip amount increases by " + increaseTipBy + " tokens every " + parseMinutes(increaseTipTime) + ". )", "", highlightColor); } } function incrementMinTip() { updateTip = false; if(forTips && minimumTip > 0) { var totalMinutes = (new Date().getTime() - startTime) / msPerMin; var newMinimumTip = (Math.floor(totalMinutes / increaseTipTime) * increaseTipBy) + minimumTip; if(newMinimumTip != currentMinimumTip) { currentMinimumTip = newMinimumTip; updateTip = true; } } } cb.onMessage(function(msg) { if(msg['user'] == cb.room_slug) { msg['X-Spam'] = true; if (msg['m'].match(/ccstop/i) && sessionStarted === true) { sessionStarted = false; stopTime = new Date().getTime(); minimumTip = orginalMimimumTip; currentMinimumTip = orginalMimimumTip; var notice = "############## SESSION STOPPED BY BROADCASTER ##############\n"; notice += cb.room_slug + " has stopped " + action + "... WITHOUT PERMISSION! " + cb.room_slug + " now must be PUNISHED SEVERELY on camera for disobeying the bot!"; cb.sendNotice(notice, "", highlightColor); } else if (msg['m'].match(/ccstop/i) && sessionStarted === false) { cb.sendNotice("No session started. Enter ccstart to start a new session.", cb.room_slug, highlightColor); } else if (msg['m'].match(/ccstart/i) && sessionStarted === false) { var newTime = new Date().getTime(); if(stopTime !== false) { var minSinceStop = Math.floor((newTime - stopTime) / msPerMin); if(minSinceStop < waitAfterStop) { cb.sendNotice("You must wait " + parseMinutes(waitAfterStop - minSinceStop) + " before you can start again.", cb.room_slug, highlightColor); return msg; } } sessionStarted = true; startTime = newTime; lastMessageTime = startTime + delay * msPerMin; setExtendAction(); var notice = "############## START SESSION NOW ##############\n"; notice += cb.room_slug + " must start " + action + " RIGHT NOW! " + cb.room_slug + " is NOT allowed to stop " + action + " until this bot says that the session is over. This will only happen if nobody " + extendAction + " for " + parseMinutes(finish) + ". The minimum session duration is set to " + parseMinutes(minimum) + "."; cb.sendNotice(notice, "", highlightColor); showTipIncrease(); setTimeout(checkNotices, msPerMin); if(bathroom > 0) { var breakTime = bathroom * msPerMin; function bathroomBreak() { if(sessionStarted === true) { cb.sendNotice("############## BATHROOM BREAK ##############", "", highlightColor); cb.sendNotice(cb.room_slug + " is allowed a very short bathroom break after " + parseMinutes(bathroom) + ". Make it quick " + cb.room_slug + "!", "", highlightColor); setTimeout(bathroomBreak, breakTime); } } setTimeout(bathroomBreak, breakTime); } } } if (forTips === false && new Date().getTime() > lastMessageTime && sessionStarted === true) { lastMessageTime = new Date().getTime(); } return msg; }); if(forTips) { cb.onTip(function (tip) { if(tip['amount'] >= currentMinimumTip && new Date().getTime() > lastMessageTime) { cb.sendNotice("Thanks " + tip['from_user'] + "! Your generous tip has just extended the session. " + cb.room_slug + " must now continue " + action + " for at least another " + parseMinutes(finish) + "!", "", highlightColor, "#000000", "bold"); lastMessageTime = new Date().getTime(); sessionStarted = true; } }); }
© Copyright Chaturbate 2011- 2026. All Rights Reserved.