Bots Home
|
Create an App
DicksNotifier
Author:
dickavatar
Description
Source Code
Launch Bot
Current Users
Created by:
Dickavatar
/* * Copyright 2019 Dick Avatar * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Change Log * * 1.0.0 * - Initial release. */ const VERSION = '1.0.0-RC1' const broadcaster = cb.room_slug const LVL_EVERYONE = 1 const LVL_LT_BLUE = 2 const LVL_DK_BLUE = 3 const LVL_PURPLE = 4 const LVL_DK_PURPLE = 5 const EVERYONE = 'Everyone' const LT_BLUE = 'Light Blue' const DK_BLUE = 'Dark Blue' const PURPLE = 'Purple' const DK_PURPLE = 'Dark Purple' // See https://html-color-codes.info const color_map = { Black:'#000000', White:'#FFFFFF', Red:'#FF0000', Yellow:'#FFFF00', Green:'#00FF00', Cyan:'#00FFFF', Blue:'#0000FF', Magenta:'#FF00FF' } let color = '#ffffff' let background = '#000000' let weight = 'bold' // Configuration options when the bot is started cb.settings_choices = [ {name:'weight', label: 'Font weight', type:'choice', choice1:'normal', choice2: 'bold', choice3: 'bolder', defaultValue:'bold'}, {name:'color', type:'choice', choice1:'Black', choice2:'White', choice3:'Red', choice4:'Yellow', choice5:'Green', choice6:'Cyan', choice7:'Blue', choice8:'Magenta', defaultValue:'White', label:'Font color.'}, {name:'background', type:'choice', choice1:'Black', choice2:'White', choice3:'Red', choice4:'Yellow', choice5:'Green', choice6:'Cyan', choice7:'Blue', choice8:'Magenta', defaultValue:'Red', label:'Background color.'}, {name:'member_level', label:'Member color', type:'choice', choice1:EVERYONE, choice2:LT_BLUE, choice3:DK_BLUE, choice4:PURPLE, choice5:DK_PURPLE, defaultValue:DK_PURPLE}, {name:'welcome_message', label:'Welcome message. [user] will be replaced with the member\'s name.',type:'str', defaultValue:'Welcome to my room [user]. I am so glad you are here'}, {name:'notify_on_enter', label:'Notify you whe n member enters', type:'choice', choice1:'Yes', choice2:'No', defaultValue:'Yes'}, {name:'notify_on_leave', label:'Notify you when member leaves', type:'choice', choice1:'Yes', choice2:'No', defaultValue:'No'} ] function log(message) { //cb.sendNotice(message, broadcaster, color_map.Black, color_map.White, 'bold') cb.log(message) } function getLevel() { let level = cb.settings['member_level'] if (level === EVERYONE) return LVL_EVERYONE if (level === LT_BLUE) return LVL_LT_BLUE if (level === DK_BLUE) return LVL_DK_BLUE if (level === PURPLE) return LVL_PURPLE return LVL_DK_PURPLE } function getUserLevel(user) { if (user['tipped_tons_recently']) return LVL_DK_PURPLE if (user['tipped_alot_recently']) return LVL_PURPLE if (user['tipped_recently']) return LVL_DK_BLUE if (user['has_tokens']) return LVL_LT_BLUE return LVL_EVERYONE } function onEnter(user) { let required_member_level = getLevel() let current_member_level = getUserLevel(user) log("Required " + required_member_level) log("Current " + current_member_level) if (current_member_level < required_member_level) { log("Member is not worthy of a greeting") return } let name = user['user'] let message = cb.settings['welcome_message'] if (message !== undefined) { message = message.replace(/\[user\]/, name) } else { log('Welcome message is undefined.') message = 'Welcome to my room ' + name + '.' } notify(name, message) if (cb.settings['notify_on_enter'] === 'Yes') { notify(broadcaster, name + ' has entered the room.') } } cb.onEnter(onEnter) function onLeave(user) { log(user['user'] + ' left') if (cb.settings['notify_on_leave'] === 'No') { log("Leave notification disabled.") return } let required_member_level = getLevel() let current_member_level = getUserLevel(user) if (current_member_level < required_member_level) return let name = user['user'] let message = name + ' has left the chat room.' notify(broadcaster, name + ' has left the room.') } cb.onLeave(onLeave) // Send a notification to a specific user. function notify(user, message) { log('Sending notice to ' + user) let color = cb.settings['color'] let background = cb.settings['background'] let weight = cb.settings['weight'] cb.sendNotice(message, user, background, color, weight) }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.