Bots Home
|
Create an App
Dakota's Announce Bot
Author:
smoker919
Description
Source Code
Launch Bot
Current Users
Created by:
Smoker919
/////////////////////////////////////////////////////////////////////////////// // D A K O T A ' S A N N O U N C E B O T // by Smoker919 // for Dakota_Ossa // // Simple bot that announces when tracked users enter and leave the room /////////////////////////////////////////////////////////////////////////////// /*** Settings ***/ cb.settings_choices = [ {name: 'trackedUsers', type: 'str', label: 'Users to track (comma-separated list)', default: ''}, {name: 'announceTo', type: 'choice', label: 'Announce to', choice1: 'Broadcaster only', choice2: 'Broadcaster and Moderators', default: 'Broadcaster only'}, {name: 'additionalUsersToAnnounceTo', type: 'str', label: 'Additional users to announce to (comma-separated list)', default: '', required: false}, {name: 'messageOnEnter', type: 'str', label: 'Message on entering (use %username% for the username)', default: 'Tracked user %username% has joined the room.'}, {name: 'messageOnLeave', type: 'str', label: 'Message on leaving (use %username% for the username)', default: 'Tracked user %username% has left the room.'}, {name: 'noticeBackground', type: 'str', label: 'Notice background (HTML colour code, e.g., #800080)', default: '', required: false}, {name: 'noticeForeground', type: 'str', label: 'Notice foreground (HTML colour code, e.g., #FFFFFF)', default: '', required: false}, {name: 'noticeWeight', type: 'choice', label: 'Notice weight', choice1: 'normal', choice2: 'bold', choice3: 'bolder', default: 'bolder'} ]; /*** Variables ***/ var trackedUsers = []; var announceTo = ''; var additionalUsersToAnnounceTo = []; var messageOnEnter = ''; var messageOnLeave = ''; var noticeBackground = ''; var noticeForeground = ''; var noticeWeight = ''; /*** Initialize the bot ***/ function init() { trackedUsers = String(cb.settings['trackedUsers']).split(','); announceTo = String(cb.settings['announceTo']); if (cb.settings['additionalUsersToAnnounceTo']) { additionalUsersToAnnounceTo = String(cb.settings['additionalUsersToAnnounceTo']).split(','); } messageOnEnter = String(cb.settings['messageOnEnter']); messageOnLeave = String(cb.settings['messageOnLeave']); noticeBackground = String(cb.settings['noticeBackground']); noticeForeground = String(cb.settings['noticeForeground']); noticeWeight = String(cb.settings['noticeWeight']); } /*** On enter callback ***/ cb.onEnter(function(user) { announce(user, messageOnEnter); }); /*** On leave callback ***/ cb.onLeave(function(user) { announce(user, messageOnLeave); }); /*** All the work happens here ***/ function announce(user, message) { var username = user['user']; if (trackedUsers.includes(username)) { var msg = message.replace('%username%', username); cb.sendNotice(msg, cb.room_slug, noticeBackground, noticeForeground, noticeWeight); if (announceTo == 'Broadcaster and Moderators') { cb.sendNotice(msg, '', noticeBackground, noticeForeground, noticeWeight, 'red'); } if (additionalUsersToAnnounceTo.length > 0) { additionalUsersToAnnounceTo.forEach(function(value, index, array) { cb.sendNotice(msg, value, noticeBackground, noticeForeground, noticeWeight); }); } } } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.