Bots Home
|
Create an App
twolefterTestBot
Author:
bladblah
Description
Source Code
Launch Bot
Current Users
Created by:
Bladblah
//#region User Type Breakdown // Broadcaster: Orange names are Broadcasters // Moderator: Red names are Moderators // TokenOwner: Light Blue names own or have purchased tokens // Tip50User: Dark Blue names have tipped at least 50 tokens in the past 2 weeks // Tip250User: Light Purple names have tipped at least 250 tokens in the past 2 weeks // Tip1KUser: Dark Purple names have tipped at least 1000 tokens in the past 2 weeks // Fan: Green names are fan club members // Freeloader: Grey names have no tokens var userTypes = [ { id: 7, tag: 'broadcaster', display: 'Broadcaster', color: '#DC5500', systemCode: '' }, { id: 6, tag: 'moderator', display: 'Mod', color: '#FF0000', systemCode: 'red' }, { id: 5, tag: 'fan', display: 'User', color: '#009900', systemCode: 'green' }, { id: 4, tag: 'tip1KUser', display: 'User', color: '#5F497A', systemCode: 'darkpurple' }, { id: 3, tag: 'tip250User', display: 'User', color: '#BE6AFF', systemCode: 'lightpurple' }, { id: 2, tag: 'tip50User', display: 'User', color: '#1F497D', systemCode: 'darkblue' }, { id: 1, tag: 'tokenOwner', display: 'User', color: '#6699AA', systemCode: 'lightblue' }, { id: 0, tag: 'freeloader', display: 'User', color: '#494949', systemCode: '' }, { id: -1, tag: 'rando', display: 'Anonymous', color: '#494949', systemCode: '' }]; function getUserType(tag) { return userTypes.find(function (item) { return item.tag === tag; }); } //#endregion //#region Broadcaster Functions //#endregion //#region Moderator Functions //#endregion //#region Token User Functions //#endregion //#region Non-Token User Functions //#endregion //#region Determine User function determineUserType(userData) { if (userData.is_mod) { return getUserType('moderator'); } if (userData.in_fanclub) { return getUserType('fan'); } if (userData.tipped_tons_recently) { return getUserType('tip1KUser'); } if (userData.tipped_alot_recently) { return getUserType('tip250User'); } if (userData.tipped_recently) { return getUserType('tip50User'); } if (userData.has_tokens) { return getUserType('tokenOwner'); } if (userData.user) { return getUserType('freeloader'); } else { return getUserType('rando'); } } //#endregion function createUserObject(userData) { return { types: userTypes, myType: determineUserType(userData), myReference: userData, }; } function createUser(userData) { var newUser = createUserObject(userData); if (newUser.myType.id >= -1) {//rando } if (newUser.myType.id >= 0) {//freeloader } if (newUser.myType.id >= 1) {//tokenOwner } if (newUser.myType.id >= 2) {//tip50User } if (newUser.myType.id >= 3) {//tip250User } if (newUser.myType.id >= 4) {//tip1KUser } if (newUser.myType.id >= 5) {//fan } if (newUser.myType.id >= 6) {//moderator } if (newUser.myType.id >= 7) {//broadcaster } return newUser; } //#region Room // Room Object Contains Methods And Members To Apply Functionality To The Current Room //#endregion //#region Constants var fontWeights = { normal:'normal', bold:'bold', bolder:'bolder' }; var definedColors = { black:'#000', white:'#FFF' }; //#endregion //#region Room Functions //#region Timeout Methods // TODO: Countdown Method function startTimeout(timeoutPeriod, callbackFunction){ var timeoutId = this.cbObject.setTimeout(callbackFunction,timeoutPeriod); this.timeouts.push(timeoutId); return timeoutId; } function endTimeout(timeoutId){ this.cbObject.cancelTimeout(timeoutId); } function clearAllTimeouts(){ this.timeouts.forEach(element => { this.endTimeout(element); }); } //#endregion //#region Tip Options Functions function createTipOption(optionText){ if(!optionText){return null;} return {label:optionText}; } function determineTipOptionLabel(tipParams, roomObject){ return ''; } function determineTipOptions(tipParams, roomObject){ return []; } function applyTipOptionList(tipParams){ if(this.tipOptionsDisabled){return;} // Used To Dynamically Generate Menus For Tips return {options:determineTipOptions(tipParams, this), label:determineTipOptionLabel(tipParams, this)}; } //#endregion //#region Room Subject Methods (Supposedly Apps Only) function setRoomTitle(newSubjectText){ this.cbObject.changeRoomSubject(newSubjectText); } //#endregion //#region Room Notice function sendSingleNotice(messageText, userObject, userGroup, backgroundColor, foregroundColor, fontWeight){ // Defaults backgroundColor = backgroundColor || definedColors.white; foregroundColor = foregroundColor || definedColors.black; fontWeight = fontWeight || fontWeights.normal; // Make The Call To The API return this.cbObject.sendNotice(messageText, userObject && userObject !== '' ? userObject.myReference['user'] : '', backgroundColor, foregroundColor, fontWeight, userGroup); } function sendManyUserNotice(messageText, userArray, backgroundColor, foregroundColor, fontWeight){ if(!userArray){return false;} userArray.forEach(function(item){ this.sendNotice(messageText, item, '', backgroundColor, foregroundColor, fontWeight); }); return true; } function sendGroupNotice(messageText, userGroup, backgroundColor, foregroundColor,fontWeigth){ return this.sendNotice(messageText,'', userGroup, backgroundColor, foregroundColor, fontWeight); } //#endregion //#region Room Events function handleUserEnter(userParams, roomObject){ roomObject.cbObject.log(JSON.stringify(Object.keys(users))); roomObject.sendNotice('Welcome '+userParams['user'], createUser(userParams)); } function handleUserLeave(userParams, roomObject){ } function handleUserMessage(messageParams, roomObject){ } function handleUserTip(tipParams, roomObject){ } //#endregion //#region Initialization function createSettingInt(name, required, minVal, maxVal, uiLabel){ if(!name || name === ''){ return nulll;} return { name:name, type:'int', minValue: minVal || 0, maxValue: maxVal || 100, defaultValue: null, required: required || false, label: uiLabel || name }; } function createSettingString(name, required, minLen, maxLen, uiLabel){ if(!name || name === ''){ return nulll;} return { name:name, type:'str', minLength: minLen || 0, maxLength: maxLen || 255, required: required || false, defaultValue: null, label: uiLabel || name }; } function addChoice(label){ this['choice'+(this.choiceCount+=1)] = label; } function createSettingChoice(name, required, uiLabel){ if(!name || name === ''){ return nulll;} return { name:name, type:'choice', required: required || false, label: uiLabel || name, choiceCount: 0, addChoice:addChoice, defaultValue: null }; } function initializeRoom(chaturbateObject){ this.cbObject = chaturbateObject; this.timeouts = []; this.users = []; this.settings = []; this.tipOptionsDisabled = true; var roomObject = this; // Event Registration this.cbObject.onEnter(function(userParams){ handleUserEnter(userParams, roomObject); }); this.cbObject.onLeave(function(userParams){ handleUserLeave(userParams, roomObject); }); this.cbObject.onMessage(function(messageParams){ handleUserMessage(messageParams, roomObject); }); this.cbObject.onTip(function(tipParams){ handleUserTip(tipParams, roomObject); }); this.cbObject.tipOptions(function(tipParams){ roomObject.applyTipOptionList(tipParams, roomObject); }); } function createRoom(){ return { cbObject: null, timeouts: [], users: [], settings: [], tipOptionsDisabled: true, // Initialization initialize: initializeRoom, // "App Only" Functions setRoomTitle: setRoomTitle, // Timeout Methods startTimeout: startTimeout, endTimeout: endTimeout, clearAllTimeouts: clearAllTimeouts, // Room Notice Methods sendNotice: sendSingleNotice, sendManyUserNotice: sendManyUserNotice, sendGroupNotice: sendGroupNotice, // Tip Options applyTipOptionList: applyTipOptionList }; } //#endregion //#endregion var room = createRoom(); room.initialize(cb);
© Copyright Chaturbate 2011- 2024. All Rights Reserved.