Apps Home
|
Create an App
Entry Announce Bot
Author:
sbj_t1
Description
Source Code
Launch App
Current Users
Created by:
Sbj_T1
/* Entry Announce Bot Announces users that enter or exit the chat to the broadcaster. Features: - Option to announce users (including greys). You should turn of the normal CB notifications in your chat settings. - Option to decorate all messages with the user's gender icon. (Similar to the "Gender Bot" app by tablesalt90.) */ /* ========= GLOBAL VARS ==================================== */ // Defaults var announceEnterLeave = true; var decorateMessages = true; var decorateOwnMessages = false; var styleEnterLeave = { fg: '#ffffff', bg: '<gender>', fs: 'bold' }; // Other global data var genderIcons = { m: ':avatar_gen_male', f: ':avatar_gen_female', s: ':avatar_gen_trans', c: ':avatar_gen_couple' }; var genderNames = { m: 'Male', f: 'Female', s: 'Trans', c: 'Couple' }; var genderColors = { m: '#7CA6DA', f: '#D08192', s: '#41B36E', c: '#946AA6' }; /* ========= CHATURBATE SETTINGS ============================ */ cb.settings_choices = []; // Announce enter/leave cb.settings_choices.push({ name: 'announceEnterLeave', label: 'Announce enter/leave of all users (including greys)', type: 'choice', choice1: 'yes', choice2: 'no', required: true, defaultValue: (announceEnterLeave ? 'yes' : 'no') }); cb.settings_choices.push({ name: 'styleEnterLeave', label: 'Style of enter/leave notifications. Format: "<ForegroundColor> <BackgroundColor> <FontStyle>". Colors are HTML colors or the special "<gender>" placeholder. Font style can be "normal" or "bold".', type: 'str', required: false, defaultValue: [styleEnterLeave.fg, styleEnterLeave.bg, styleEnterLeave.fs].join(' ').trim() }); // Decorate messages cb.settings_choices.push({ name: 'decorateMessages', label: 'Decorate each message with the user\'s gender icon.', type: 'choice', choice1: 'yes', choice2: 'no', required: true, defaultValue: (decorateMessages ? 'yes' : 'no') }); cb.settings_choices.push({ name: 'decorateOwnMessages', label: 'Decorate own messages with your gender icon. (This setting only has an effect if the previous option is set to "yes".)', type: 'choice', choice1: 'yes', choice2: 'no', required: true, defaultValue: (decorateOwnMessages ? 'yes' : 'no') }); /* ========= FUNCTIONS ====================================== */ function announce(user, enter) { if (!announceEnterLeave || user['user'] === cb.room_slug) { return; } var gender = genderNames[user['gender']]; var genderInfo = (gender ? ' (' + gender + ')' : ''); var msg = user['user'] + genderInfo + ' has ' + (enter ? 'joined' : 'left') + ' the room.'; cb.sendNotice(msg, cb.room_slug, genderColor(styleEnterLeave.bg, user), genderColor(styleEnterLeave.fg, user), styleEnterLeave.fs); } cb.onEnter(function(user) { announce(user, true); }); cb.onLeave(function(user) { announce(user, false); }); cb.onMessage(function(message) { var prefix = ''; if (decorateMessages && (decorateOwnMessages || message['user'] !== cb.room_slug)) { var icon = genderIcons[message['gender']]; if (icon) { prefix = icon + ' '; } } message['m'] = prefix + message['m']; }); function parseStyle(styleStr, defaultStyle) { var style = (styleStr || '').replace(/\s+/, ' ').trim().split(' '); return { fg: style[0] || defaultStyle.fg, bg: style[1] || defaultStyle.bg, fs: style[2] || defaultStyle.fs, }; } function genderColor(color, user) { if (color === '<gender>') { var gender = (user ? user['gender'] : ''); return genderColors[gender]; } return color; } /* ========= INITIALIZATION ================================= */ // Prepare settings announceEnterLeave = (cb.settings['announceEnterLeave'] === 'yes'); announceEnterLeaveGender = (cb.settings['announceEnterLeaveGender'] === 'yes'); decorateMessages = (cb.settings['decorateMessages'] === 'yes'); decorateOwnMessages = (cb.settings['decorateOwnMessages'] === 'yes'); styleEnterLeave = parseStyle(cb.settings['styleEnterLeave'], styleEnterLeave);
© Copyright Chaturbate 2011- 2025. All Rights Reserved.