Bots Home
|
Create an App
anntest
Author:
quid14
Description
Source Code
Launch Bot
Current Users
Created by:
Quid14
/* Automatically welcome users and periodically post notifications to the room. */ /* ========= GLOBAL VARS ==================================== */ // Defaults var greetingEnabled = true; var greeting = ':hii I am Annie! Welcome to my room, $user!. If you like me, Please :followclick :thxyou7 '; var MAX_MESSAGES = 5; var notifyEnabled = true; var notifyInterval = 3 * 60000; // ms var enterLeaveEnabled = false; var fgWelcome = '#800080'; var bgWelcome = ''; var fsWelcome = 'bold'; var fgNotify = '#800080'; var bgNotify = ''; var fsNotify = 'bold'; var fgEnterLeave = '#999999'; var bgEnterLeave = ''; var fsEnterLeave = ''; var msgList = []; var msgIndex = 0; /* ========= CHATURBATE SETTINGS ============================ */ cb.settings_choices = []; // 1. Greeting cb.settings_choices.push({ name: 'greetingEnabled', label: 'Welcome message enabled', type: 'choice', choice1: 'yes', choice2: 'no', required: true, defaultValue: greetingEnabled }); cb.settings_choices.push({ name: 'greeting', label: 'Welcome message ($user will be replace by the user\'s name)', type: 'str', required: false, defaultValue: greeting }); // 2. Room messages cb.settings_choices.push({ name: 'notifyEnabled', label: 'Room notifications enabled', type: 'choice', choice1: 'yes', choice2: 'no', required: true, defaultValue: (notifyEnabled ? 'yes' : 'no') }); for (var i = 1; i <= MAX_MESSAGES; i++) { cb.settings_choices.push({ name: 'msg' + i, label: 'Room message ' + i, type: 'str', required: false }); } cb.settings_choices.push({ name: 'notifyInterval', label: 'Delay in minutes between room notifications', type: 'int', minValue: 1, maxValue: 999, required: true, defaultValue: (notifyInterval / 60000) }); // 3. Enter/leave notifications cb.settings_choices.push({ name: 'enterLeaveEnabled', label: 'Display enter/leave notifications for users without tokens', type: 'choice', choice1: 'yes', choice2: 'no', required: true, defaultValue: (enterLeaveEnabled ? 'yes' : 'no') }); // Style "Welcome" cb.settings_choices.push({ name: 'fgWelcome', label: '[Advanced] Foreground color for welcome messages', type: 'str', required: false, defaultValue: fgWelcome }); cb.settings_choices.push({ name: 'bgWelcome', label: '[Advanced] Background color for welcome messages', type: 'str', required: false, defaultValue: bgWelcome }); cb.settings_choices.push({ name: 'fsWelcome', label: '[Advanced] Font style for welcome messages ("normal" or "bold")', type: 'str', required: false, defaultValue: fsWelcome }); // Style "Notifications" cb.settings_choices.push({ name: 'fgNotify', label: '[Advanced] Foreground color for notification messages', type: 'str', required: false, defaultValue: fgNotify }); cb.settings_choices.push({ name: 'bgNotify', label: '[Advanced] Background color for notification messages', type: 'str', required: false, defaultValue: bgNotify }); cb.settings_choices.push({ name: 'fsNotify', label: '[Advanced] Font style for notification messages ("normal" or "bold")', type: 'str', required: false, defaultValue: fsNotify }); /* ========= FUNCTIONS ====================================== */ cb.onEnter(function(user) { if (greetingEnabled && greeting) { var msg = greeting.replace('$user', user['user']); cb.sendNotice(msg, user['user'], bgWelcome, fgWelcome, fsWelcome); } if (!user.has_tokens && enterLeaveEnabled) { cb.sendNotice('Grey user ' + user['user'] + ' has joined the room.', cb.room_slug, bgEnterLeave, fgEnterLeave, fsEnterLeave); } }); cb.onLeave(function(user) { if (!user.has_tokens && enterLeaveEnabled) { cb.sendNotice('Grey user ' + user['user'] + ' has left the room.', cb.room_slug, bgEnterLeave, fgEnterLeave, fsEnterLeave); } }); function notify() { var msg = msgList[msgIndex]; msgIndex++; if (msgIndex >= msgList.length) { msgIndex = 0; } cb.sendNotice(msg, '', bgNotify, fgNotify, fsNotify); cb.setTimeout(notify, notifyInterval); } /* ========= INITIALIZATION ================================= */ function init() { // Prepare settings greetingEnabled = (cb.settings['greetingEnabled'] === 'yes'); greeting = cb.settings['greeting']; notifyEnabled = (cb.settings['notifyEnabled'] === 'yes'); notifyInterval = cb.settings['notifyInterval'] * 60000; for (var i = 1; i <= MAX_MESSAGES; i++) { if (cb.settings['msg' + i]) { msgList.push(cb.settings['msg' + i]); } } enterLeaveEnabled = (cb.settings['enterLeaveEnabled'] === 'yes'); fgWelcome = cb.settings['fgWelcome']; bgWelcome = cb.settings['bgWelcome']; fsWelcome = cb.settings['fsWelcome']; fgNotify = cb.settings['fgNotify']; bgNotify = cb.settings['bgNotify']; fsNotify = cb.settings['fsNotify']; // Start notification loop if (notifyEnabled && msgList.length > 0 && notifyInterval > 0) { cb.setTimeout(notify, notifyInterval); } } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.