Bots Home
|
Create an App
privateapp123qweASD
Author:
bobita60
Description
Source Code
Launch Bot
Current Users
Created by:
Bobita60
{ var tipperArray = new Array; var numTippers = 0; var modArray = new Array; modArray[0] = cb.room_slug; var eModArray = new Array; var dickArray = ['']; var niceArray = new Array; var numNice = 0; var silenceArray = new Array; var numSilenced = 0; var ignoreArray = new Array; var numIgnorers = 0; var whisperArray = new Array; var numWhispers = 0; var silenceLevel = 0; var graphicLevel = 1; var numMods = 1; var numEMods = 0; var startTime = 0; var timerDuration = 0; var timeAdded = 0; var currentKing = ''; var kingTip = 0; var kingTimer = parseInt(cb.settings.kingTimer); var leaderArray = [['', 0], ['', 0], ['', 0]]; var leaderTimer = parseInt(cb.settings.leaderTimer); var initialize = 0; var kingTipperSpam = 0; var notifierSpamTGL = 0; var leaderboardSpam = 0; var notifierMessage = cb.settings.spamMessage; tipper = ""; tipmsg = ""; //color codes { var purple = "#C287C2";//original color: #B369B3 } } function setMessage(message){ if(message != '') { cb.settings.tipMessage = message } } function setMessageMin(min){ if(min != '') { cb.settings.tipMessageMin = min } } function startTimer(t, mod) { //there is no timer already running if(startTime == 0 && timeAdded == 0) { //verify a valid option was sent with /starttimer if(t >= 0 && t.toString().indexOf('.') == -1) { timerDuration = t; //notice of timer start if(mod != null) { cb.sendNotice(mod + ' has set a timer for ' + timerDuration + ' minutes!','',purple); } //local variable to convert noticeTime (minutes) to milliseconds var millis = timerDuration * 60000; var fiveMinutes = millis - 300000; var oneMinute = millis - 60000; //actual timer cb.setTimeout(timer,millis); //five minutes remaining announcement if(fiveMinutes > 0) { cb.setTimeout(fiveMinuteWarning,fiveMinutes); } //one minute remaining announcement cb.setTimeout(oneMinuteWarning,oneMinute); //set the start time startTime = new Date(); } else if(t != null) { cb.sendNotice(t + ' is not a valid option for /starttimer.\nType /ubhelp starttimer to see how to use /starttimer.',mod,purple); } else if(t == null) { cb.sendNotice('You did not enter a valid option for /starttimer.\nType /ubhelp starttimer to see how to use /starttimer.',mod,purple); } } //there is a timer running and time has been added else if(startTime != 0 && timeAdded != 0 && mod == null) { timeAdded = 0; timerDuration = t; //local variable to convert noticeTime (minutes) to milliseconds var millis = timerDuration * 60000; var fiveMinutes = millis - 300000; var oneMinute = millis - 60000; //actual timer cb.setTimeout(timer,millis); //five minutes remaining announcement if(fiveMinutes > 0) { cb.setTimeout(fiveMinuteWarning,fiveMinutes); } //one minute remaining announcement cb.setTimeout(oneMinuteWarning,oneMinute); } //there is a timer running and someone tried to start a new timer else if(startTime != 0 && timeAdded == 0 || startTime != 0 && timeAdded != 0 && mod != null) { cb.sendNotice('There is a timer running already.',mod,purple); } } function timer() { //check to see if /addTime has been used if(timeAdded == 0) { cb.sendNotice('Time is up!','',purple); startTime = 0; timerDuration = 0; } else { if(timeAdded == 5) { cb.sendNotice('There are 5 minutes remaining!','',purple); } startTimer(timeAdded); } } function fiveMinuteWarning() { if(timeAdded == 0) { cb.sendNotice('There are 5 minutes remaining!','',purple); } } function oneMinuteWarning() { if(timeAdded == 0) { cb.sendNotice('There is 1 minute remaining!','',purple); } } function timeLeft(user) { if(startTime != 0) { //local variable for the current time var currentTime = new Date(); //local variable to hold the time left var timeLeft = startTime.getHours()*3600 + startTime.getMinutes()*60 + startTime.getSeconds() + timerDuration*60 - currentTime.getHours()*3600 - currentTime.getMinutes()*60 - currentTime.getSeconds(); //local variables for hours, minutes, and seconds remaining var hours = timeLeft/3600; hours = Math.floor(hours); var minutes = (timeLeft-hours*3600)/60; minutes = Math.floor(minutes); var seconds = timeLeft-hours*3600-minutes*60; //account for timeAdded minutes += timeAdded; //fix numbers after timeAdded if(hours < 0) { hours = 0; minutes = 0; } if(hours > 0) { if(hours > 9) { if(minutes > 9 && seconds > 9) { cb.sendNotice('Time Remaining: ' + hours + ':' + minutes + ':' + seconds,user,purple); } else if(minutes > 9 && seconds <= 9) { cb.sendNotice('Time Remaining: ' + hours + ':' + minutes + ':0' + seconds,user,purple); } else if(minutes <= 9 && seconds > 9) { cb.sendNotice('Time Remaining: ' + hours + ':' + minutes + ':' + seconds,user,purple); } else if(minutes <= 9 && seconds <= 9) { cb.sendNotice('Time Remaining: ' + hours + ':' + minutes + ':0' + seconds,user,purple); } } else { if(minutes > 9 && seconds > 9) { cb.sendNotice('Time Remaining: 0' + hours + ':' + minutes + ':' + seconds,user,purple); } else if(minutes > 9 && seconds <= 9) { cb.sendNotice('Time Remaining: 0' + hours + ':' + minutes + ':0' + seconds,user,purple); } else if(minutes <= 9 && seconds > 9) { cb.sendNotice('Time Remaining: 0' + hours + ':' + minutes + ':' + seconds,user,purple); } else if(minutes <= 9 && seconds <= 9) { cb.sendNotice('Time Remaining: 0' + hours + ':' + minutes + ':0' + seconds,user,purple); } } } else if(hours == 0 && minutes > 0) { if(minutes > 9 && seconds > 9) { cb.sendNotice('Time Remaining: 00:' + minutes + ':' + seconds,user,purple); } else if(minutes > 9 && seconds <= 9) { cb.sendNotice('Time Remaining: 00:' + minutes + ':0' + seconds,user,purple); } else if(minutes <= 9 && seconds > 9) { cb.sendNotice('Time Remaining: 00:0' + minutes + ':' + seconds,user,purple); } else if(minutes <= 9 && seconds <= 9) { cb.sendNotice('Time Remaining: 00:0' + minutes + ':0' + seconds,user,purple); } } else if(hours == 0 && minutes == 0 && seconds > 0) { if(seconds > 9) { cb.sendNotice('Time Remaining: 00:00' + ':' + seconds,user,purple); } else { cb.sendNotice('Time Remaining: 00:00' + ':0' + seconds,user,purple); } } else { cb.sendNotice('hours: ' + hours + '\nminutes: ' + minutes + '\nseconds: ' + seconds); } } else { cb.sendNotice('There is no timer running.',user,purple); } } function addTime(t, mod) { if(t > 0 && t.toString().indexOf('.') == -1) { if(startTime != 0) { timeAdded = parseInt(t); //notice of timer start if(timeAdded == 1) { cb.sendNotice(mod + ' has has added 1 minute to the timer!','',purple); } else { cb.sendNotice(mod + ' has has added ' + timeAdded + ' minutes to the timer!','',purple); } } else { cb.sendNotice('There is no timer running.',mod,purple); } } else if(t != null) { cb.sendNotice(t + ' is not a valid option for /addtime.\nType /ubhelp addtime to see how to use /addtime.',mod,purple); } else if(t == null) { cb.sendNotice('You did not enter a valid option for /addtime.\nType /ubhelp addtime to see how to use /addtime.',mod,purple); } } function colorChecker() { var colorString = '0123456789abcdefABCDEF'; var valid = true; var color = "C287C2"; if(cb.settings.color != null) { color = cb.settings.color; } for(var i = 0; i < 6; i++) { if(colorString.indexOf(color.charAt(i)) == -1) { valid = false; } if(valid == false) { purple = '#C287C2'; cb.sendNotice(color + ' is not a valid option for the highlight color. Hex color codes use numbers and letters only.\nUse www.color-hex.com to find the code for the color you want.\nDo not include the #.\nReverting to default color.',cb.room_slug,purple); break; } } if(valid) { purple = '#' + cb.settings.color; } } { cb.settings_choices = [ { name: 'tipamount', type: 'int', minValue: 1, defaultValue: 10, label: 'Minimum tokens required for a thank you message' } , { name: 'tipmsg', type: 'str', minLength: 8, maxLength: 128, defaultValue: '**** Thank you [tipper] for your tip!!! (: **** ', label: "Tip thank you message, [tipper] = tipper's name" } ]; } { cb.onTip(function (tip) { if (parseInt(tip['amount']) >= cb.settings.tipMessageMin) { tipper = tip['from_user']; tipmsg = cb.settings.tipMessage; tipmsg = tipmsg.replace("[tipper]", tipper); //cb.chatNotice(tipmsg, tipper); cb.sendNotice(tipmsg, '', purple); } }); } { cb.onEnter(function (user) { if (cb.settings.notifierEnter == "Yes") { cb.sendNotice(cb.settings.enterMessage, user['user'], purple); } if (user['is_mod'] && !cbjs.arrayContains(modArray, user)) { modArrayPopulate(user['user']); } }); } { cb.onMessage(function (msg) { //turn the message into an array var message = msg['m'].split(' '); //0 = invalid command, 1 = valid command var cmd = 0; //1 = user is already silenced var silenced = 0; var symbolString = '~`!@#$%^&*()_-+={[}]|\\:;"\'<,>.?/'; //check to see if the user is attempting to use a command if(message[0].charAt(0) == '/') { //don't print this message to chat msg['X-Spam'] = true; switch(message[0]) { case '/starttimer': { //user entered a proper command cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug || cbjs.arrayContains(eModArray,msg['user'])) { startTimer(message[1], msg['user']); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.\nType "/ubhelp commands" to see a full list of the available commands.',msg['user'],purple); } break; } case '/addtime': { //user entered a proper command cmd = 1; //permission check if(msg['is_mod'] || msg['user'] == cb.room_slug || cbjs.arrayContains(eModArray,msg['user'])) { addTime(message[1], msg['user']); } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.\nType "/ubhelp commands" to see a full list of the available commands.',msg['user'],purple); } break; } case '/timeleft': { //user entered a proper command cmd = 1; timeLeft(msg['user']); break; } case '/setmessage': { //user entered a proper command cmd = 1; setMessage(msg[1]); break; } case '/setmessagemin': { //user entered a proper command cmd = 1; setMessageMin(msg[1]); break; } } //Ultra App command support if(message[0] == '/startshow' || message[0] == '/showtimeleft' || message[0] == '/addshowtime' || message[0] == '/selltickets' || message[0] == '/setmessage' || message[0] == '/setmessagemin' ) { cmd = 1; } //the user entered an invalid command if(cmd == 0 && cb.settings.invalidToggle == 'Yes') { cb.sendNotice(message[0] + ' is not a command.\nType /ubhelp commands to see a full list of the available commands.',msg['user'],purple); } } //stop people from sending messages in all caps if(msg['m'] == msg['m'].toUpperCase() && msg['m'].toUpperCase() != msg['m'].toLowerCase() && !msg['is_mod'] && msg['user'] != cb.room_slug && !cbjs.arrayContains(eModArray,msg['user']) && cb.settings.capsToggle == 'Yes') { for(var i = 0; i < msg['m'].length; i++) { if(symbolString.indexOf(msg['m'].charAt(i)) == -1) { msg['m'] = msg['m'].toLowerCase(); cb.sendNotice('I\'m sure you didn\'t actually mean to send that message in all capital letters, so I fixed it for you :smile',msg['user'],purple); break; } } } return msg; }); } if(initialize == 0) { if(cb.settings.color != 'C287C2') { colorChecker(); } // cb.sendNotice('Grey users are now unable to use graphics by default. If you would like grey users to be able to use graphics, type /graphiclevel 0.', cb.room_slug, purple); initialize = 1; }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.