Bots Home
|
Create an App
PoisonHoney Bot
Author:
poison__honey
Description
Source Code
Launch Bot
Current Users
Created by:
Poison__Honey
cb.settings_choices = function () { var output = []; var ins_index = 0; makeInstructions('[TEXT] ---------------------- The appearance of generic text.'); output.push({name: 'wt', label: 'Weight', type: 'choice', choice1: 'normal', choice2: 'bold', defaultValue: 'bold'}); output.push({name: 'roomfgcolor', label: 'Room notice text color', type: 'str', defaultValue: '#000000', required: false}); output.push({name: 'roombgcolor', label: 'Room notice background color', type: 'str', defaultValue: '#FFFFFF', required: false}); output.push({name: 'welcome', label: '[WELCOME MESSAGE]', type: 'str', defaultValue: 'Welcome to my room. Read my bio to get in touch with me.'}); makeInstructions('[KING TIPPER] ---------------------- King tipper options.'); output.push({name: 'kt_username', label: 'All Time King tipper username', type: 'str', required: false}); output.push({name: 'kt_num', label: 'All Time King tipper amount', type: 'int', minValue: 1, defaultValue: 1000}); output.push({name: 'kt_emote', label: 'All Time King tipper emote', type: 'str', defaultValue: ':crown01', required: false}); output.push({name: 'ktd_emote', label: 'King Tipper of the Day emote', type: 'str', defaultValue: ':crown02', required: false}); output.push({name: 'kt_timer', label: 'Seconds between displays (alternating between all time and daily)', type: 'int', minValue: 30, defaultValue: 120}); makeInstructions('[CENSORING] -------------------- These options allow you to automatically censor, restrict, and hide chat messages that you don\'t like.'); output.push({name: 'block_for', label: 'Censoring applies to', type: 'choice', choice1: 'Everyone', choice2: 'Greys', choice3: 'Nobody', defaultValue: 'Greys'}); output.push({name: 'blocked', label: 'Blocked words', type: 'str', required: false, defaultValue: 'bb,baby,babe,slut,whore,dick,penis,masturbate'}); output.push({name: 'block_type', label: 'Action for blocked words', type: 'choice', choice1: 'Censor word', choice2: 'Hide entire message', defaultValue: 'Hide entire message'}); output.push({name: 'sticky_keys', label: 'Block sticky keys', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}); output.push({name: 'capslock', label: 'Auto-fix caps lock', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}); output.push({name: 'block_grey_emotes', label: 'Block grey emotes (even if censoring not applied)', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}); makeInstructions('[AUTO-THANK YOU] ---------------------- Automatically display a thank you notice to everyone when a user tips. Specify the exact amount required and the exact message to be displayed.'); makeThankYou(1, 111, 'Thank you for showing me that you like me, {user}!'); makeThankYou(2, 222, 'Thank you for showing me that you want me, {user}!'); makeThankYou(3, 555, 'Thank you for showing me that you love me, {user}!'); makeThankYou(4, 888, 'Thank you for showing me that you are a real man, {user}!'); makeThankYou(5, 1000, 'Hmmm, thank you for make me feel desired, {user}!'); output.push({name: 'thanks_5_overlimit', label: 'Dispaly level 5 message for tips over that number', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}); makeInstructions('[WHISPERS] ---------------------- Send private messages in the main chat window.'); output.push({name: 'whisper_allow_mods', label: 'Allow all mods to whisper', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}); output.push({name: 'whisper_allow_users', label: 'Allow these users to whisper', type: 'str', defaultValue: 'codeanon, user12345', required: false}); output.push({name: 'whisper_fg', label: 'Whisper text color', type: 'str', defaultValue: '#FFFFFF', required: false}); output.push({name: 'whisper_bg', label: 'Whisper highlight color', type: 'str', defaultValue: '#000000', required: false}); makeInstructions('[ROTATING MESSAGES] -------------------- These messages appear automatically in the chat at regular intervals on a rotating basis.'); output.push({name: 'message_0', label: 'Message 01', required: false, type: 'str'}); output.push({name: 'message_1', label: 'Message 02', required: false, type: 'str'}); output.push({name: 'message_2', label: 'Message 03', required: false, type: 'str'}); output.push({name: 'message_2', label: 'Message 03', required: false, type: 'str'}); output.push({name: 'message_3', label: 'Message 04', required: false, type: 'str'}); output.push({name: 'message_4', label: 'Message 05', required: false, type: 'str'}); output.push({name: 'messages_interval', label: 'Seconds between displays of the rotating messages (0 = off)', type: 'int', defaultValue: 60, minvalue: 0}); output.push({name: 'messages_delay', label: 'Seconds before messages start rotating', type: 'int', defaultValue: 30, minvalue: 0}); output.push({name: 'tipTitles', label: '[TITLES] -------------------- Display a user\'s total tips as a title in chat', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}); function makeThankYou (i, min, txt) { var str = 'thanks_' + i + '_'; output.push({name: str + 'min', label: 'Tokens required', type: 'int', minValue: 1, defaultValue: min}); output.push({name: str + 'txt', label: 'Message', type: 'str', required: false, defaultValue: txt}); } function makeInstructions(text) { output.push({name: 'instructions_' + ins_index, label: text, type: 'choice', choice1: '', required: false}); ins_index++; } return output; }(); var cbs = JSON.parse(JSON.stringify(cb.settings)); var whisperList = cbs.whisper_allow_users ? cbs.whisper_allow_users.toLowerCase().split(/\s*,\s*/) : []; var tipTotal = 0; var tipLedger = {'---': 0}; var leaderBoard = []; var blocked = []; var blockType = cbs.block_type; var thanks = []; for (var i = 5; i > 0; i--) { var str = 'thanks_' + i + '_'; var min = cbs[str + 'min']; var txt = cbs[str + 'txt']; if (txt && min) thanks.push({min: min, txt: txt}); } thanks.sort((a, b) => b.min - a.min); var kt = {user: cbs.kt_username || '---', num: cbs.kt_num || 100, emote: cbs.kt_emote || '\u2655'}; var ktd = {user: '---', emote: cbs.ktd_emote || '\u265B'}; kt.emote = kt.emote.replace(':crowngold', ':crown01'); ktd.emote = ktd.emote.replace(':crownsilver', ':crown02'); /********** ------------ EVENT HANDLERS ------------ **********/ //when a new tip comes in, increment everything cb.onTip((tip) => doTip(tip)); function doTip(tip) { cb.log('Checking tip...'); var amount = tip['amount']; var user = tip['from_user']; addTip(user, amount); thankYou(user, amount); checkKing(tip); } //when a new message comes in, either process a command or change the display cb.onMessage(function (msg) { if (msg['m'].charAt(0) === '/') { msg['X-Spam'] = true; var user = msg['user']; if (checkWhisper(msg)) { cb.log('Whisper processed'); } else if (user === cb.room_slug) { cmd(msg.m, user); } } else { censor(msg); displayTips(msg); displayKing(msg); } return msg; }); cb.onEnter(function (user) { if (cbs.welcome) tellUser(cbs.welcome.trim(), user.user); }); /********** ------------ CENSORING ------------ **********/ //check if the messsage should be processed through the filter function shouldBeCensored(msg) { return cbs.block_for === 'Everyone' || (cbs.block_for === 'Greys' && !hasImmunity(msg)); } //checks user for immunity to stickyKeys and Emoticons... function hasImmunity(msg) { return (msg['user'] === cb.room_slug || msg['is_mod'] || msg['has_tokens'] || msg['tipped_recently'] || msg['tipped_alot_recently'] || msg['tipped_tons_recently']); } //censor the message function censor(msg) { var warningMessage; var text = msg['m']; if (shouldBeCensored(msg) && containsBlockedWord(text)) { if (blockType === 'Hide entire message') { warningMessage = 'Your message has been removed due to the use of innapropriate word(s).' msg = processCensor(msg, warningMessage); } else { msg['m'] = censorBlockedWords(text); } } else if (!hasImmunity(msg)) { if (hasStickyKeys(text) && cbs.sticky_keys) { warningMessage = 'Your message has been removed due to constant repitition of the same letter (Sticky Keys).' msg = processCensor(msg, warningMessage); } else if (hasEmoticon(text) && cbs.block_grey_emotes === 'Yes') { warningMessage = 'I\'m sorry. grey users are not allowed to post emoticons.' msg = processCensor(msg, warningMessage); } else if (hasCapslock(text) && cbs.capslock === 'Yes') { warningMessage = 'We\'ve detected that you\'re using too many capital letters. Here, let me fix that for you.'; tellUser(warningMessage, msg['user']); msg['m'] = String(msg['m']).toLowerCase(); } else if (containsBlockedWord(text)) { msg['X-Spam'] = true; } } return msg; } //added new method rather than duplicate code. function processCensor(msg, warningMessage) { tellUser(warningMessage, msg['user']); msg['X-Spam'] = true; msg['m'] = '*******'; } //check if text contains sticky keys function hasStickyKeys(input) { str = input.replace(/\s+/g, '_'); return /(\S)(\1{2,})/g.test(str); } //check if text contains an emoticon function hasEmoticon(input) { return /(^|\s):\w{3,}($|\s)/.test(input); } //check if text contains capslock function hasCapslock(input) { str = input.replace(/\s+/g, '_'); return /([A-Z]{3,})/g.test(str); } //censor only blocked words function censorBlockedWords(text) { var sanitized = text.replace(/\s+/g, ' '); var words = sanitized.split(' '); var censored = sanitized; for (var i = 0; i < blocked.length; i++) { for (var j = 0; j < words.length; j++) { if (remPunk(words[j].toLowerCase()) === blocked[i]) words[j] = '*******'; return words.join(' '); } } } //remove punctuation from a string function remPunk(text) { return text.replace(/[^A-Za-z0-9]/g, ''); } //see if a string contains a blocked word function containsBlockedWord(input) { var text = input.replace(/\s+/g, ' ').toLowerCase(); for (var i = 0; i < blocked.length; i++) { var exp = RegExp('\\b' + blocked[i] + '\\b'); if (exp.test(text)) return true; } return false; } /********** ------------ TIP DISPLAY ------------ **********/ //add the number of tips to the beginning of a user's message function displayTips(msg) { if (cbs.tipTitles === 'Yes') { var user = msg['user']; if (tipLedger[user]) msg['m'] = '|' + tipLedger[user] + '| ' + msg['m']; } return msg; } //increment the user's entry in tipLedger function addTip(user, number) { tipTotal += number; tipLedger[user] ? tipLedger[user] += number : tipLedger[user] = number; } function thankYou(user, number) { if (thanks.length) { if (number == thanks[0].min || (number > thanks[0].min && cbs.thanks_5_overlimit === 'Yes')) { tellUser(thanks[0].txt.replace(/\{user\}/g, user)); } else { for (var i = 1; i < thanks.length; i++) { if (number === thanks[i].min || (i == 0 && cbs.thanks_5_overlimit === 'Yes')) { tellUser(thanks[i].txt.replace(/\{user\}/g, user)); return void 0; } } } } } /********** ------------ LEADERBOARD ------------ **********/ function displayKing(msg) { if (msg.user === kt.user) msg.m = kt.emote + ' ' + msg.m; if (msg.user === ktd.user) msg.m = ktd.emote + ' ' + msg.m; } function checkKing(tip) { if (tip.amount > kt.num) { if (tip.from_user !== kt.user) tellUser(kt.emote + ' ' + tip.from_user + ' tipped ' + tip.amount + ' to become the new King Tipper Ever! ' + kt.emote); kt.user = tip.from_user; kt.num = tip.amount; } if (tipLedger[tip.from_user] > tipLedger[ktd.user]) { if (tip.from_user !== ktd.user) tellUser(ktd.emote + ' ' + tip.from_user + ' tipped ' + tip.amount + ' to become the new King Tipper! ' + ktd.emote); ktd.user = tip.from_user; ktd.num = tip.amount; } } /********** ------------ ROTATORS ------------ **********/ var rotatingMessages = []; for (var i = 0; i < 6; i++) { var message = cb.settings['message_' + i]; if (message && message.length > 0) rotatingMessages.push(message); } //rotate displays of messages function messageRotator() { var message = rotatingMessages[0]; tellUser(message); rotatingMessages.push(rotatingMessages.shift()); cb.setTimeout(messageRotator, cbs.messages_interval * 1000); } function kingRotator(displayed) { if (cbs.kt_timer) { cb.setTimeout(function () { var text = displayed ? ktd.emote + ' Tip a total of ' + (tipLedger[ktd.user] + 1) + ' to become the new King of the Day! ' + ktd.emote : kt.emote + ' Be the High Tip King: tip ' + (kt.num + 1) + ' or more to replace ' + kt.user + ' as the new High Tip King, and wear the high tip ' + kt.emote; tellUser(text); kingRotator(!displayed); }, cbs.kt_timer * 1000); } } function startRotators() { if (cbs.messages_interval && rotatingMessages.length) { cb.setTimeout(messageRotator, cbs.messages_delay * 1000); } kingRotator(true); } /********** ------------ GENERAL ------------ **********/ //process superuser commands function cmd(input, user) { cb.log(input); var msg = input.substring(1).split(/\s+/); switch (msg[0]) { case 'h': if (user === cb.room_slug) showHelp(user); break; case 'bbt': if (msg[1] && Number(msg[1]) !== NaN) { doTip({from_user: (msg[2] || 'InvisiMod'), amount: Number(msg[1])}); } break; case 'bb#': if (user === cb.room_slug && msg[1]) evaluate(msg.slice(1).join(' '), user); break; case 'addWhisper': if (msg[1]) { var w = msg[1].toLowerCase(); if (!whisperList.includes(w)) whisperList.push(w); tellMe(w + ' can now whisper.'); } break; case 'remWhisper': if (msg[1]) { var w = msg[1].toLowerCase(); while (whisperList.includes(w)) whisperList.splice(whisperList.indexOf(w), 1); tellMe(w + ' can no longer whisper.'); } break; case 'block': if (msg[1]) { blocked.push(msg[1].toLowerCase()); tellMe(msg[1] + ' is blocked.'); } break; case 'unblock': if (msg[1]) { var w = msg[1].toLowerCase(); while (blocked.includes(w)) blocked.splice(blocked.indexOf(w), 1); tellMe(w + ' is no longer blocked.'); } break; } } function checkWhisper(input) { if (whisperList.includes(input.user) || input.user === cb.room_slug || (input.user.is_mod && cbs.whisper_allow_mods === 'Yes')) { var msg = input.m.substring(1).split(/\s+/); var user = input.user; switch (msg[0]) { case 'w': if (msg[1]) { whisper(cb.room_slug, msg.slice(1).join(' '), user); if (user !== cb.room_slug) lastWhisper = user; } return true; case 'wu': if (msg[1] && msg[2]) { whisper(msg[1], msg.slice(2).join(' '), user); } return true; case 'r': if (user === cb.room_slug && msg[1] && lastWhisper !== '') { whisper(lastWhisper, msg.slice(1).join(' '), user); } return true; } } return false; } function evaluate(str, user) { try { var result = eval(str); var notice = 'INPUT: ' + str + '\nTYPE: ' + typeof result + '\nVALUE: '; result === void 0 ? notice += 'undefined' : notice += JSON.stringify(result, null, '\u2007\u2007\u2007\u2007'); cb.setTimeout(() => {cb.sendNotice(newLines(notice), user, '', '#00CC00', '', '')}, 100); } catch (e) { cb.setTimeout(() => {cb.sendNotice(newLines(e.name + ': ' + e.message), user, '', '#FF0000', '', '')}, 100); } } function giveTitle (user, title) { specTitles[user] = title; tellUser(user + ' shall henceforth be known as "' + title + '"!'); } function remTitle(user) { if (specTitles[user]) delete specTitles[user]; } function whisper(recipient, message, sender) { whisperNotice('[' + sender.toUpperCase() + '] :: "' + message + '"', recipient); whisperNotice('Message sent to ' + recipient + '.', sender); } //block a word function block(word, array) { if (word && array) { word = word.replace(',', '').toLowerCase(); if (word.length > 0) { array.push(word); tellBoth('The word "' + word + '" has been ' + array.name + '.'); } } } //unblock a word function allow(word, array) { if (word && array) { var index = array.indexOf(word.toLowerCase()); if (index > -1) { array.splice(index, 1); tellBoth('The word "' + word + '" is no longer ' + array.name + '.'); } } } //sanitize a string for consistency function sanitize(input) { if (input) { var s = input.replace(/\s/g, ''); s = s.replace('}{', '} {'); s = s.replace('\s+', ' '); s = s.replace(':', ': '); return s; } return void 0; } /********** ------------ COMMUNICATION ------------ **********/ //send a message to the user with special formatting function whisperNotice(msg, username) { if (msg && username) cb.sendNotice(newLines(msg), username, cbs.whisper_bg, cbs.whisper_fg, cbs.wt, ''); } //send a message to the user function tellUser(msg, user) { cb.sendNotice(newLines(msg), user, cbs.roombgcolor, cbs.roomfgcolor, cbs.wt, ''); } //send a message to the broadcaster function tellMe(msg) { cb.sendNotice(newLines(msg), cb.room_slug, cbs.roombgcolor, cbs.roomfgcolor, cbs.wt, ''); } //send a message to mods function tellMods(msg) { cb.sendNotice(newLines(msg), '', cbs.roombgcolor, cbs.roomfgcolor, cbs.wt, 'red'); } //send a message to broadcaster and mods function tellBoth(msg) { tellMe(msg); tellMods(msg); } //show the help menu to mods and broadcaster function showHelp(user) { var output = '---- Commands ---- \ \n(Mods can only use the /w and /wu commands.) \ \n/h :: show this menu again \ \n/w [message] :: whisper to the broadcaster \ \n/r [message] :: reply to the most recent whisper \ \n/wu [user] [message] :: whisper to a user \ \n/addWhisper [user] :: allow user to whisper \ \n/remWhisper [user] :: remove a user\'s whisper privileges \ \n/block [word] :: block a word from appearing in the chat \ \n/unblock [word] :: allow a word to appear in the chat'; tellUser(output, user); } /********** ------------ MISCELLANEOUS ------------ **********/ //add to all newline characters in a string for readability function newLines(input) { return '\u25CF ' + input.replace(/\n/g, '\n\u25CF '); } //check if an array contains an instane of the object function arrayIndexOf(array, obj) { for (var i = 0; i < array.length; i++) if (array[i] === obj) return i; return -1; } /********** ------------ INITIALIZATION ------------ **********/ //parse the blocked words function parseBlocked(input) { if (input) { var s = input.replace(/\s/g, '').replace(/,{2,}/g, ',').toLowerCase(); var arr = s.split(','); blocked = arr; blocked.name = 'blocked'; } } /********** ------------ EXECUTE ------------ **********/ parseBlocked(cbs.blocked); showHelp(cb.room_slug); startRotators();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.