Bots Home
|
Create an App
SchmidtBot
Author:
jjjschmidt
Description
Source Code
Launch Bot
Current Users
Created by:
Jjjschmidt
const isBroadcaster = (user) => user === cb.room_slug; const backgroundColor = '#CCCCFF'; const foregroundColor = '#000033'; let menu = null; cb.settings_choices = [ { name:'menu', type:'str', label: 'Menu (comma-separated list of item:amount pairs)', minLength: 1, defaultValue:'top off: 50, naked: 200' } ]; const getMenuItem = (tipAmount) => { if (!menu) { menu = []; cb.settings.menu.split(',').forEach(menuItem => { const match = menuItem.match(/\s*(.+)\s*:\s*(\d+)\s*/); if (match) { const item = match[1]; const amount = match[2]; menu[amount] = item; } }); } return menu[tipAmount]; } cb.onEnter(user => { const enterMessage = 'Welcome ' + user.user + ', type "/menu" for tip menu.'; cb.sendNotice(enterMessage, user.user, backgroundColor, foregroundColor, 'bold'); }); cb.onMessage(message => { if (message.m === '/menu') { message['X-Spam'] = true; const menuMessage = 'Menu:\n' + cb.settings.menu; const user = isBroadcaster(message.user) ? '' : message.user; cb.sendNotice(menuMessage, user, backgroundColor, foregroundColor, 'bold'); } return message; }); cb.onTip(tip => { const menuItem = getMenuItem(tip.amount); if (menuItem) { const tipMessage = tip.from_user + ' tipped for ' + menuItem; cb.sendNotice(tipMessage, '', backgroundColor, foregroundColor, 'bold'); } });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.