Bots Home
|
Create an App
BlazeyBot
Author:
testing1010
Description
Source Code
Launch Bot
Current Users
Created by:
Testing1010
cb.settings_choices = [ // { name: 'fanclubWheelSpinPrice', type: 'int', required: true, label: 'Fanclub Wheel Spin Price', defaultValue: 199 }, { name: 'minorWheelSpinPrice', type: 'int', required: true, label: 'Minor Wheel Spin Price', defaultValue: 200 }, { name: 'majorWheelSpinPrice', type: 'int', required: true, label: 'Major Wheel Spin Price', defaultValue: 4000 }, // { name: 'fanclubWheelPrizes', type: 'str', required: true, label: 'Fanclub Wheel Prizes', defaultValue: '' }, { name: 'minorWheelPrizes', type: 'str', required: true, label: 'Minor Wheel Prizes', defaultValue: '' }, { name: 'majorWheelPrizes', type: 'str', required: true, label: 'Major Wheel Prizes', defaultValue: '' }, { name: 'tipMenu', type: 'str', required: true, label: 'Tip Menu', defaultValue: '' }, { name: 'fanClubTipMenu', type: 'str', required: true, label: 'Fanclub Tip Menu', defaultValue: '' }, { name: 'bannedWordsList', type: 'str', label: 'Banned Words', defaultValue: '' }, { name: 'noticeColor', type: 'str', required: true, label: 'Notice Color', defaultValue: '#cc0000' }, { name: 'notifyDelay', type: 'int', defaultValue: 5, label: 'Channel notice delay (minutes)' }, { name: 'message1', type: 'str', required: false }, { name: 'message2', type: 'str', required: false }, { name: 'message3', type: 'str', required: false }, { name: 'message4', type: 'str', required: false }, { name: 'message5', type: 'str', required: false }, { name: 'message6', type: 'str', required: false }, { name: 'message7', type: 'str', required: false }, { name: 'message8', type: 'str', required: false }, { name: 'message9', type: 'str', required: false }, { name: 'message10', type: 'str', required: false }, ]; const bannedWordsList = cb.settings.bannedWordsList || ''; const noticeColor = cb.settings.noticeColor || '#cc0000'; const minorSpinPrice = cb.settings.minorWheelSpinPrice; const majorSpinPrice = cb.settings.majorWheelSpinPrice; // const fanclubSpinPrice = cb.settings.fanclubWheelSpinPrice; // const fanclubWheelPrizes = (cb.settings.fanclubWheelPrizes || '').split(',').map(i => i.trim()); const minorWheelPrizes = (cb.settings.minorWheelPrizes || '').split(',').map(i => i.trim()); const majorWheelPrizes = (cb.settings.majorWheelPrizes || '').split(',').map(i => i.trim()); let TIPPERS = []; let BANNED_WORDS = bannedWordsList.split(',').map(i => i.trim()); let BANNED_REGEX_TEXT = `(${BANNED_WORDS.join('|')})`; let BANNED_REGEX = new RegExp(BANNED_REGEX_TEXT, 'i'); const SPIN_HISTORY = []; const NOTIFY_MESSAGES = []; const SILENCED_USERS = []; const TIP_LEADERBOARD = {}; const TIPMENU = {}; const FANCLUBTIPMENU = {}; const NICKNAMES = {}; // TIPMENU[fanclubSpinPrice] = 'Fanclub Wheel Spin (Fanclub Members Only!)'; TIPMENU[minorSpinPrice] = 'Minor Wheel Spin'; TIPMENU[majorSpinPrice] = 'Major Wheel Spin'; for (let i = 1; i <= 10; i++) { let message = cb.settings['message' + i]; if (message !== '') { NOTIFY_MESSAGES.push(message); } } (cb.settings.tipMenu || '').split(',').forEach(t => { const item = t.trim(); const split = item.split(' '); const price = parseInt(split.shift()); if (TIPMENU[price] || FANCLUBTIPMENU[price]) { cb.sendNotice(`!!! Multiple tip menu prices collide. Make sure all tip options + wheel spin prices are different !!!`, cb.room_slug, '#cc0000', '#ffffff', 'bold'); } else { TIPMENU[price] = split.join(' '); } }); (cb.settings.fanClubTipMenu || '').split(',').forEach(t => { const item = t.trim(); const split = item.split(' '); const price = parseInt(split.shift()); if (TIPMENU[price] || FANCLUBTIPMENU[price]) { cb.sendNotice(`!!! Multiple tip menu prices collide. Make sure all tip options + wheel spin prices are different !!!`, cb.room_slug, '#cc0000', '#ffffff', 'bold'); } else { FANCLUBTIPMENU[price] = split.join(' '); } }); cb.onTip(tip => { const tipItem = TIPMENU[tip.amount]; const fanTipItem = FANCLUBTIPMENU[tip.amount]; if (tipItem) { let msg = `${tip.from_user} tipped ${tip.amount} for: ${tipItem}` cb.sendNotice(msg, null, null, noticeColor, 'bold'); SPIN_HISTORY.push(msg); } if(fanTipItem && (tip.from_user_in_fanclub || tip.from_user === 'mrblackhorn')){ let msg = `Fanclub Member ${tip.from_user} tipped ${tip.amount} for ${fanTipItem} from the Fanclub Only Menu`; cb.sendNotice(msg, null, null, noticeColor, 'bold'); SPIN_HISTORY.push(msg); } switch(tip.amount){ case majorSpinPrice: spin(tip.from_user, 'major'); break; case minorSpinPrice: spin(tip.from_user, 'minor'); break; /*case fanclubSpinPrice: if (tip.from_user_in_fanclub) { spin(tip.from_user, 'fanclub'); } else { cb.sendNotice(`Uh oh! You must be in Blazey's fanclub to spin the Fanclub wheel. Join now and ask Blazey to spin for your prize!`, tip.from_user, null, noticeColor, 'bold'); } break;*/ } if (!TIP_LEADERBOARD[tip.from_user]) { TIP_LEADERBOARD[tip.from_user] = 0; } TIP_LEADERBOARD[tip.from_user] += tip.amount; TIPPERS = Object.keys(TIP_LEADERBOARD).map((name) => { return { name, tips: TIP_LEADERBOARD[name] }; }); TIPPERS.sort((a, b) => b.tips - a.tips); }); cb.onMessage(msg => { const txt = msg.m; const command = txt.split(' '); if (msg.user === cb.room_slug || msg.is_mod || msg.user === 'mrblackhorn') { switch (command[0]) { case '/notice': notice(msg, command); msg['X-Spam'] = true; break; case '/tell': tell(msg, command); msg['X-Spam'] = true; break; case '/mods': tell(msg, command, true); msg['X-Spam'] = true; break; case '/ss': secretSilence(msg, command); msg['X-Spam'] = true; break; case '/bw': updateBannedWords(msg, command); msg['X-Spam'] = true; break; case '/nickname': nickname(msg, command); msg['X-Spam'] = true; break; case '/spin': if (msg.user === cb.room_slug) { spin(msg.user, command[1], command[2]); } msg['X-Spam'] = true; break; case '/spinhistory': if (msg.user === cb.room_slug) { spinHistory(); } msg['X-Spam'] = true; break; default: break; } } switch (command[0]) { case '/cmds': showCmds(msg); msg['X-Spam'] = true; break; case '/tipmenu': tipMenu(msg); msg['X-Spam'] = true; break; case '/fanclubmenu': fanclubTipMenu(msg); msg['X-Spam'] = true; break; /* case '/fcprizes': wheelPrizes(msg, 'fanclub'); msg['X-Spam'] = true; break;*/ case '/minorprizes': wheelPrizes(msg, 'minor'); msg['X-Spam'] = true; break; case '/majorprizes': wheelPrizes(msg, 'major'); msg['X-Spam'] = true; break; default: break; } const bannedTxt = txt.match(BANNED_REGEX); if (SILENCED_USERS.indexOf(msg.user) !== -1) { msg['X-Spam'] = true; } else if(bannedTxt){ msg['X-Spam'] = true; } let message = ''; const top3 = TIPPERS.slice(0, 3).map(i => i.name); if (top3[0] === msg.user || msg.user === 'mrblackhorn') { message += ':cindycrowngold '; } if(NICKNAMES[msg.user]){ message += `[${NICKNAMES[msg.user]}] `; } else if(msg.in_fanclub){ message += `[TeamBlaze] `; } message += msg.m; return msg; }); const updateBannedWords = (msg, command) => { const method = command[1]; const word = command[2]; if(!method){ cb.sendNotice(`Must enter one of 'add' or 'remove' to modify the banned words list`, msg.user, null, noticeColor, 'bold'); return; } if(!word){ cb.sendNotice(`Must enter a word to ${method === 'remove' ? 'remove from' : 'add to'} the banned words list`, msg.user, null, noticeColor, 'bold'); return; } const idx = BANNED_WORDS.indexOf(word); if(idx === -1){ if(method === 'add'){ BANNED_WORDS.push(word); cb.sendNotice(`${word} added to the banned words list`, null, null, noticeColor, 'bold', 'red'); cb.sendNotice(`${word} added to the banned words list`, cb.room_slug, null, noticeColor, 'bold'); } else { cb.sendNotice(`${word} is not currently on the banned words list`, msg.user, null, noticeColor, 'bold', 'red'); return; } } else { if(method === 'remove'){ BANNED_WORDS.splice(idx, 1); cb.sendNotice(`${word} removed from the banned words list`, null, null, noticeColor, 'bold', 'red'); cb.sendNotice(`${word} removed from the banned words list`, cb.room_slug, null, noticeColor, 'bold'); } else { cb.sendNotice(`${word} is not currently on the banned words list`, msg.user, null, noticeColor, 'bold', 'red'); return; } } BANNED_REGEX_TEXT = `(${BANNED_WORDS.join('|')})`; BANNED_REGEX = new RegExp(BANNED_REGEX_TEXT, 'i'); cb.sendNotice(`regex: ${BANNED_REGEX_TEXT}`, cb.room_slug, null, noticeColor, 'bold'); }; const showCmds = (msg) => { let str = '~~~ BlazeyBot Commands ~~~\n\n'; if (msg.user === cb.room_slug || msg.is_mod || msg.user === 'mrblackhorn') { str += '[Blazey + Mod Commands]\n'; str += '<> brackets = required fields. [] brackets = optional fields. Do not write brackets in your commands. \n\n' str += '/notice - Send a notice for everyone in the channel to see\n'; str += '/tell [message] - Send a message privately to Blazey\n'; str += '/mods [message] - Send a message privately to channel moderators\n'; str += '/ss [username] [off] - Secretly silence a user from the chat. Send with `off` to remove them from the silenced list. Send without parameters to see current list of silenced users\n'; str += '/bw <add|remove> <word> - Add or remove words from the banned list\n'; str += '/nickname <username> <nickname> - Give a user a custom nickname\n'; str += '\n'; } if (msg.user === cb.room_slug) { str += '[Blazey Only Commands]\n'; str += '/spin <major|minor> [username]- Spin the wheel manually. One of the 3 wheel options is required. If spinning for a specific user add their name for better history tracking\n'; str += '/spinhistory - Show the history of spin results \n'; str += '\n'; } str += '/cmds - Show a list of available commands\n'; str += '/tipmenu - Show Blazey\'s tip menu\n'; // str += '/fcprizes - Show the available prizes on Blazey\'s fanclub prize wheel\n'; str += '/minorprizes - Show the available prizes on Blazey\'s minor prize wheel\n'; str += '/majorprizes - Show the available prizes on Blazey\'s major prize wheel\n'; if(msg.in_fanclub || msg.user === cb.room_slug || msg.is_mod || msg.user === 'mrblackhorn'){ str += '/fanclubmenu - Show the available prizes on Blazey\'s fanclub only tip menu\n'; } cb.sendNotice(str, msg.user, null, noticeColor, 'bold'); }; const tipMenu = (msg) => { let str = '~~~ BlazeyBot TipMenu ~~~\n\n'; Object.keys(TIPMENU).forEach(i => str += `${i} tokens - ${TIPMENU[i]}\n`); if (msg.is_mod || msg.user === cb.room_slug) { cb.sendNotice(str, null, null, noticeColor, 'bold'); } else { cb.sendNotice(str, msg.user, null, noticeColor, 'bold'); } }; const fanclubTipMenu = (msg) => { if(!(msg.in_fanclub || msg.is_mod || msg.user === cb.room_slug || msg.user === 'mrblackhorn')){ return; } let str = '~~~ BlazeyBot Fanclub Only TipMenu ~~~\n\n'; Object.keys(FANCLUBTIPMENU).forEach(i => str += `${i} tokens - ${FANCLUBTIPMENU[i]}\n`); if (msg.is_mod || msg.user === cb.room_slug) { cb.sendNotice(str, null, null, noticeColor, 'bold'); } else { cb.sendNotice(str, msg.user, null, noticeColor, 'bold'); } }; const wheelPrizes = (msg, wheel) => { let str = ''; switch(wheel){ /*case 'fanclub': str += '~~~ BlazeyBot Fanclub Wheel Prizes ~~~\n'; fanclubWheelPrizes.forEach((i, k) => str += `${k + 1}: ${i}\n`); break;*/ case 'minor': str += '~~~ BlazeyBot Minor Wheel Prizes ~~~\n'; minorWheelPrizes.forEach((i, k) => str += `${k + 1}: ${i}\n`); break; case 'major': str += '~~~ BlazeyBot Major Wheel Prizes ~~~\n'; majorWheelPrizes.forEach((i, k) => str += `${k + 1}: ${i}\n`); break; } if (msg.is_mod || msg.user === cb.room_slug) { cb.sendNotice(str, null, null, noticeColor, 'bold'); } else { cb.sendNotice(str, msg.user, null, noticeColor, 'bold'); } }; const notice = (msg, command) => { command.shift(); const str = command.join(' '); cb.sendNotice(str, null, null, noticeColor, 'bold'); }; const nickname = (msg, command) => { const user = command[1]; const nickname = command[2]; if(!user){ cb.sendNotice(`Must enter a username to apply a nickname too`, msg.user, null, noticeColor, 'bold'); return; } if(!nickname){ cb.sendNotice(`Must supply a new nickname for the user`, msg.user, null, noticeColor, 'bold'); return; } NICKNAMES[user] = nickname; cb.sendNotice(`User ${user} will now have the nickname ${nickname}`, msg.user, null, noticeColor, 'bold'); }; const tell = (msg, command, toMods) => { command.shift(); const str = command.join(' '); if (msg.user === cb.room_slug) { cb.sendNotice(`Private to mods: ${str}`, cb.room_slug, null, noticeColor, 'bold'); cb.sendNotice(`${msg.user}: ${str}`, null, null, noticeColor, 'bold', 'red'); } else if(toMods){ cb.sendNotice(`${msg.user}: ${str}`, null, null, noticeColor, 'bold', 'red'); cb.sendNotice(`${msg.user}: ${str}`, cb.room_slug, null, noticeColor, 'bold'); } else { cb.sendNotice(`${msg.user}: ${str}`, cb.room_slug, null, noticeColor, 'bold'); cb.sendNotice(`Private to Blazey: ${str}`, msg.user, null, noticeColor, 'bold'); } }; const spin = (user, wheel, forUser) => { let prizes = []; switch (wheel) { /*case 'fanclub': prizes = fanclubWheelPrizes; break;*/ case 'minor': prizes = minorWheelPrizes; break; case 'major': prizes = majorWheelPrizes; break; default: return cb.sendNotice(`No wheel selected, enter one of minor or major`, cb.room_slug, null, noticeColor, 'bold'); } const num = randNumber(0, prizes.length - 1); const prize = prizes[num]; cb.sendNotice(`${forUser || user} spun the ${wheel} wheel and won: ${prize}!`, null, null, noticeColor, 'bold'); SPIN_HISTORY.push(`${forUser || user} won ${prize} from the ${wheel} wheel`); }; const spinHistory = () => { let str = '~~~ Spin History ~~~\n\n'; SPIN_HISTORY.forEach((h) => str += `${h}\n`); cb.sendNotice(str, cb.room_slug, null, noticeColor, 'bold'); }; const secretSilence = (msg, command) => { const username = command[1]; if (!username) { cb.sendNotice(`Silenced users: ${SILENCED_USERS.join(', ')}`, null, null, noticeColor, 'bold', 'red'); return; } const mode = command[2]; const idx = SILENCED_USERS.indexOf(username); if (idx !== -1) { if (mode === 'off') { SILENCED_USERS.splice(idx, 1); cb.sendNotice(`User '${username}' un-silenced by ${msg.user}`, null, null, noticeColor, 'bold', 'red'); cb.sendNotice(`User '${username}' un-silenced by ${msg.user}`, cb.room_slug, null, noticeColor, 'bold'); } else { cb.sendNotice(`User '${username}' already silenced. Run '/ss ${username} off' to un-silence`, msg.user, null, noticeColor, 'bold'); } } else { if (mode === 'off') { cb.sendNotice(`User '${username}' not currently silenced`, msg.user, null, noticeColor, 'bold'); } else { SILENCED_USERS.push(username); cb.sendNotice(`User '${username}' silenced by ${msg.user}`, null, null, noticeColor, 'bold', 'red'); cb.sendNotice(`User '${username}' silenced by ${msg.user}`, cb.room_slug, null, noticeColor, 'bold'); } } }; let noticeIdx = 0; const autoNotice = () => { if (NOTIFY_MESSAGES.length <= 0) { return; } cb.sendNotice(`${NOTIFY_MESSAGES[noticeIdx]}`, null, null, noticeColor, 'bold'); noticeIdx = noticeIdx + 1 < NOTIFY_MESSAGES.length - 1 ? noticeIdx + 1 : 0; setTimeout(autoNotice, cb.settings.notifyDelay * 60 * 1000); }; const tipLeaderboard = () => { if(!TIPPERS.length){ return; } let str = '~~~ BlazeyBot Tip Leaderboard ~~~\n\n'; if (TIPPERS[0]) str += `1) ${TIPPERS[0].name} - ${TIPPERS[0].tips}\n`; if (TIPPERS[1]) str += `2) ${TIPPERS[1].name} - ${TIPPERS[1].tips}\n`; if (TIPPERS[2]) str += `3) ${TIPPERS[2].name} - ${TIPPERS[2].tips}\n`; cb.sendNotice(str, null, null, noticeColor, 'bold'); setTimeout(tipLeaderboard, cb.settings.notifyDelay * 60 * 1000); }; const randNumber = (min, max) => Math.floor(Math.random() * (max + 1 - min) + min); autoNotice(); setTimeout(tipLeaderboard, (cb.settings.notifyDelay * 60 * 1000) / 2);
© Copyright Chaturbate 2011- 2024. All Rights Reserved.