Bots Home
|
Create an App
Smart Entry/Exit Notifications
Author:
adambomb01
Description
Source Code
Launch Bot
Current Users
Created by:
Adambomb01
/****************************************************** ******************************************************* * Name: Smart Entry/Exit Notifications * Author: adambomb01 * Version: 1.0 (2/14/16) ******************************************************* ********** * 1.0 ********** - Does one thing and does it well ****************************************************** *****************************************************/ /************************************************************************************************************************************ ***** App Launch Settings *********************************************************************************************************** ************************************************************************************************************************************/ cb.settings_choices = [ /**** 1. PERSONALIZATION ****/ {name: 'userList', label: 'Users to send notifications for', type: 'str', minLength: 1, maxLength: 1000, defaultValue: '[Exact usernames, separated by commas]', required: false}, {name: 'entryToggle', label: 'Notify on entry?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', required: false}, {name: 'exitToggle', label: 'Notify on exit?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', required: false}, {name: 'showTo', label: 'Notify everyone or just you?', type: 'choice', choice1: 'Everyone', choice2: 'Only me', defaultValue: 'Only me', required: false}, ] /************************************************************************************************************************************ ***** Global Variables ************************************************************************************************************** ************************************************************************************************************************************/ var roomHost = cb.room_slug; var userArray = new Array; var entry = false; var exit = false; var sendTo; var initialize = 0; //colors and styles var green_dark = "#007700"; var green_light = "#CCEEAA"; var red_dark = "#BB2222"; var red_light = "#FFCCCC"; /************************************************************************************************************************************ ***** Functions ********************************************************************************************************************* ************************************************************************************************************************************/ function isBlank(cbsetting) { var s; if(cbsetting) { s = cbsetting.trim(); } if(s == null || s == '' || s.substr(0,1) == '[') { return true; } else { return false; } } function userArrayPopulate(user) { userArray.push(user); } /************************************************************************************************************************************ ***** onEnter *********************************************************************************************************************** ************************************************************************************************************************************/ cb.onEnter(function(user) { var u = user['user']; if (cbjs.arrayContains(userArray,u) && entry) { cb.sendNotice(u + ' has joined the room.',sendTo,green_light,green_dark,'bold'); } }); /************************************************************************************************************************************ ***** onLeave *********************************************************************************************************************** ************************************************************************************************************************************/ cb.onLeave(function(user) { var u = user['user']; if (cbjs.arrayContains(userArray,u) && exit) { cb.sendNotice(u + ' has left the room.',sendTo,red_light,red_dark,'bold'); } }); /************************************************************************************************************************************ ***** Initialize ******************************************************************************************************************** ************************************************************************************************************************************/ if(initialize == 0) { if(!isBlank(cb.settings.userList)) { var n = cb.settings.userList.replace(/\s+/g, ''); userArray = n.replace(/^,+|,+$/g,'').split(','); } if(cb.settings.entryToggle == 'Yes') { entry = true; } if(cb.settings.exitToggle == 'Yes') { exit = true; } if(cb.settings.showTo == 'Everyone') { sendTo = ''; } else if(cb.settings.showTo == 'Only me') { sendTo = roomHost; } //Initialize initialize = 1; }
© Copyright Chaturbate 2011- 2026. All Rights Reserved.