Bots Home
|
Create an App
Shut It Tingles
Author:
rickblast
Description
Source Code
Launch Bot
Current Users
Created by:
Rickblast
/** Name: TinglesBadWordReplacer Author: Blastfuhler aka RickBlast Created: 2021-01-16 Version: 0.4 credits: chelsea2950 and the Dorothy's Ultra Fembot - i've learned a lot from you and took some snippets, thank you **/ /** ========= Changelog ========= Version 0.2: show message with bad words to mod Version 0.3: - special greetings to male / female - allow grey from nicelist to chat when grey are muted Version 0.4 - replaceText will be split at | - you can specify a seprate replace word for every bad word Version 1.0 - bugfixes: check bad words for fanclub members - set interval tipjar notice - set start amount tip jar */ /** *** BETA *** Give "bad Words" a coma separated list of word you would not like to see in your room. Every bad word will be replaced and the user gets a warning. You can customize the warning message using "Warning to an user for using bad words". You can also greet any new registered user in your room and show the bad word list. Greetings and welcome message can be customized with "Show greetings and bad word list when a registered user enters the room" and "Welcome Message to new registred users". The term {username} will be replaced with the name of the user entering yout room. You may add user to a nice list. Users from the nice list can use bad words without replacing or warning. <h1>BETA - Bad Word blocker & Hidden Show 4 Tingles</h1> <p>Give "bad Words" a coma separated list of word you would not like to see in your room. Every bad word will be replaced and the user gets a warning. You can customize the warning message using "Warning to an user for using bad words".</p> <p>You can also greet any new registered user in your room and show the bad word list. Greetings and welcome message can be customized with "Show greetings and bad word list when a registered user enters the room" and "Welcome Message to new registred users". The term {username} will be replaced with the name of the user entering yout room.</p> <p>You may add user to a nice list. Users from the nice list can use bad words without replacing or warning.</p> <h2>Commands</h2> <ul> <li>!help-badwords - shows commands</li> <li>!add:{word} - adds {word} to bad list</li> <li>!bad words - shows list of bad words</li> <li>!niceuser:{username} - adds an user to the nicelist (no bad word check)</li> <li>!removenice:{username} - removes an user from the nicelist</li> <li>!b4t-mute-greys - blocks messages from grey users</li> <li>!b4t-unmute-greys - unmutes grey users</li> <li>!b4t-hiddenshow-start - starts hidden show, uses limit api</li> <li>!b4t-hiddenshow-stop - stops hidden show</li> <li>!b4t-hiddenshow-add:{username} - adds an user to access list for hidden show</li> <li>!b4t-hiddenshow-remove:{username} - removes an user from access </li> <li>!b4t-hiddenshow-check:{username} - check if {username} has access to hidden show</li> <li>!b4t-hiddenshow-list</li> <li>!b4t-hangman-start:{WORD} - starts a new game hangman</li> <li>!b4t-tipjar - tips in my special jar</li> </ul> **/ cb.settings_choices = [ { name: 'badWords', type: 'str', label: 'Bad Words' }, { name: 'replaceText', type: 'str', label: 'Replacetext for bad words (single Text or one for every bad word seperated by |)', defaultValue: 'boeses Wort! Pfui!' }, { name: 'niceUserList', type: 'str', label: 'A list of nice users - may be short ;-)' }, { name: 'badWordWarning', type: 'str', label: 'Warning to an user for using bad words', reqiured: false, defaultValue: 'you typed a bad word, please stay nice or leave my room' }, { name: 'showBadWordToBC', type: 'choice', choice1: 'yes', choice2: 'no', label: 'Show complete message incl. bad words for broadcaster only' }, { name: 'messageFontColor', type: 'str', label: 'Font color messages broadcaster only', defaultValue: '#0000FF', minLength: 7, maxLength: 7 }, { name: 'messageBackgroundColor', type: 'str', label: 'Background color messages broadcaster only', defaultValue: '#FFFF00', minLength: 7, maxLength: 7 }, { name: 'checkFanclubMembers', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: 'Check Fanclub Members' }, { name: 'showWelcomeMessage', label: 'Show greetings and bad word list when a registered user enters the room', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes' }, { name: 'welcomeMessage', label: 'Welcome Message to new registred users', type: 'str', defaultValue: 'Welcome {username}! Please be kind - don\'t use the following words:' }, { name: 'hide_message', label: 'Message when hiden show runs', type: 'str', defaultValue: 'hidden show running, tip x tokens to watch' }, { name: 'min_start_tokens', label: 'Tokens to join before the show starts (enter 0 to disbale)', type: 'int', defaultValue: 1 }, { name: 'min_join_tokens', label: 'Tokens to join after the show starts (enter 0 to disbale)', type: 'int', defaultValue: 1 }, { name: 'special_greetings', label: 'Show special greetings to', type: 'choice', choice1: 'no special greetings', choice2: 'female', choice3: 'male', defaultValue: 'no special greetings' }, { name: 'special_greeting_text', label: 'Special greeting to gender of your choice', type: 'str', required: false }, { name: 'muteGreysFromNiceList', label: 'Mute grey users from nice list (command !b4t-mute-greys)', type: 'choice', choice1: 'yes', choice2: 'no' }, { name: 'block_grey_message', label: 'Notice when you block greys users', type: 'str', defaultValue: 'This performer does not allow accounts without tokens to chat, please purchase tokens or use an account with tokens to chat here' }, { name: 'tipjar', label: 'tip jar - count only this tip into the jar', type: 'int', minValue: 0, maxValue: 999, defaultValue: 0 }, { name: 'show_tipjar_thankyou', label: 'Show thank-you-message after tipping to the jar', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes' }, { name: 'tipjar_thankyou', label: 'Thank you message after tipping the jar', type: 'str', defaultValue: 'Thank you {username} - your tip goes to my jar.' }, { name: 'promoteTipJarInteral', label: 'Promote tip jar every X minutes (set 0 to disable)', type: 'int', minValue: 0, maxValue: 999, defaultValue: 5 }, { name: 'promoteTipJar', label: 'Text to promote your tip jar', type: 'str', defaultValue: 'Tip 20 token to my jar - target: 2.000 token for flowers' }, { name: 'startTipJarAt', label: 'Token in tip jar at app start', type: 'int', minValue: 0, maxValue: 999999, defaultValue: 0 } ]; var niceListArray = []; let badWordsArray = []; let replacerArray = []; var BC = cb.room_slug; var checkSpecial = /[!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?]+/; var muteGreyUsers = false; var ratings = []; let muteGreyFromNicelist = cb.settings.muteGreysFromNiceList === 'yes' ? true : false; let tippers = []; let tipJar = 0; // current stream let tipJarStartAt = 0; // tokens in tipr jar at start time /** Hangman style ... */ let hangman_phrase = 'badehose'; let hangman_guess = []; let hangman_hits = []; let hangman_fails = []; let hangman_counter = 0; let hangman_status = ''; function validateUserID(validateuser,validatetype,validateby,validatestartup) { if (validateuser.length < 3 || validateuser.includes(' ')) { if (validatestartup) { botLoadErrors.push('Cannot load ' + validatetype + ' entry "' + validateuser + '", it is improperly formatted (either contains a blank or is less than 3 characters).'); } else { cb.sendNotice(botName + 'Cannot load ' + validatetype + ' entry "' + validateuser + '", it is improperly formatted (either contains a blank or is less than 3 characters).', validateby, appWarningColor); } return false; } else if (checkSpecial.test(validateuser)) { if (validatestartup) { botLoadErrors.push('Cannot load ' + validatetype + ' entry "' + validateuser + '", it contains a special character.'); } else { cb.sendNotice(botName + 'Cannot load ' + validatetype + ' entry "' + validateuser + '", it contains a special character.', validateby, appWarningColor); } return false; } else { return true; } } if (cb.settings.niceUserList) { let niceary = cb.settings.niceUserList.toLowerCase(); let tempnicearray = niceary.split(','); let initnicetoadd = ''; for (let niceloadidx = 0; niceloadidx < tempnicearray.length; niceloadidx++) { initnicetoadd = tempnicearray[niceloadidx].trim(); if (validateUserID(initnicetoadd,'Nice List',BC,true)) { if (cbjs.arrayContains(niceListArray, initnicetoadd)) { botLoadErrors.push('Skipping duplicate entry for user "' + initnicetoadd + '" in the Nice List.'); } else { niceListArray.push(initnicetoadd); } } } } if(cb.settings.badWords) { const badWordsLower = cb.settings.badWords.toLowerCase(); const tempBadWordsArray = badWordsLower.split(','); for(let i=0; i < tempBadWordsArray.length; i++) { let candidate = tempBadWordsArray[i].trim(); if(!cbjs.arrayContains(badWordsArray, candidate)) { badWordsArray.push(candidate); } } } if(cb.settings.replaceText) { replacerArray = cb.settings.replaceText.split('|'); } function init() { promoteTipJar(); } function promoteTipJar() { const interval = parseInt(cb.settings.promoteTipJarInteral, 10); const timeout_minutes = interval * 1000 * 60; if(interval > 0) { let msg = cb.settings.promoteTipJar; const tip = parseInt(cb.settings.tipjar, 10); const totalAmount = (tipJar * tip) + tipJarStartAt; msg += '\x0A' + tipJar + (tipJar === 1 ? ' tip' : ' tips') + ' = '+ (tip * tipJar) + ' tokens'; msg += '\x0AGesamtsaldo: ' + totalAmount + ' tokens'; cb.chatNotice(msg, '', cb.settings.messageBackgroundColor, cb.settings.messageFontColor); cb.setTimeout(promoteTipJar, timeout_minutes); } } cb.onEnter(function(user) { if('yes' === cb.settings.showWelcomeMessage) { let message = cb.settings.welcomeMessage.replace('{username}', user['user']); cb.chatNotice(message + ' ' + cb.settings.badWords); } //special greeting to gender /* if((cb.settings.special_greetings === 'female' && user['gender'] == 'f') || ()) { const message = cb.settings.special_greeting_text.replace('{username}', user['user']); cb.chatNotice(message); } */ }); cb.onStart(function(user){ cb.chatNotice('Hello ' + user['user'] + ', Shut It 4 Tingles was startet, type !b4t-help for available commands. Thank you', user['user']); }); cb.onMessage(function (message) { let m = message['m']; const user = message['user']; const isMod = message['is_mod']; const isFan = message['in_fanclub']; const isModel = message['user'] == cb.room_slug; const hasTokens = message['has_tokens']; const hasTipped = message['tipped_recently']; const isGrey = !(hasTokens || isMod || isModel || isFan); let matchBadWord = false; if(true === checkThisUsersMessage(message)) { const replacer = cb.settings['replaceText']; for(let i=0; i < badWordsArray.length; i++) { let test = new RegExp('\\b' + badWordsArray[i] + '\\b', 'ig'); if(matchBadWord === false && m.match(test)) { matchBadWord = true; } //m = m.replace(test, replacer); if(replacerArray.length >= i) { m = m.replace(test, replacerArray[i]); } else { m = m.replace(test, replacerArray[0]); } } if(matchBadWord === true && cb.settings.badWordWarning !== '') { cb.chatNotice(cb.settings.badWordWarning, user); if('yes' === cb.settings.showBadWordToBC) { cb.chatNotice(user + ' schrieb: ' + message['m'], cb.room_slug, cb.settings.messageBackgroundColor, cb.settings.messageFontColor); } } message['m'] = m; } if(true === isGrey && true === muteGreyUsers && !(false === muteGreyFromNicelist && cbjs.arrayContains(niceListArray, user))) { message['X-Spam'] = true; message['m'] = "**Chat silenced**"; cb.chatNotice(cb.settings.block_grey_message,message['user'],'','bold'); return message; } //help media if((m.substring(0,14) === '!help-badwords' || m.substring(0,) === '!b4t-help') && user === cb.room_slug) { let notice = '*** Shut It 4 Tingles: Help Me ***'; notice += '\x0Atype !add:<word> to add a new word to the bad list'; notice += '\x0Atype !bad words to show the bad words in public chat'; notice += '\x0Atype !niceuser:<username> to add a new user to the nice list'; notice += '\x0Atype !removenice:<username> to remove a user from the nice list'; notice += '\x0Atype !b4t-mute-greys to mute grey users'; notice += '\x0Atype !b4t-unmute-greys to unmute grey users'; notice += '\x0Atype !b4t-hiddenshow-start to start hidden show / ticket show'; notice += '\x0Atype !b4t-hiddenshow-stop to stop hidden show / ticket show'; notice += '\x0Atype !b4t-hiddenshow-add:<username> to add a user to the show'; notice += '\x0Atype !b4t-hiddenshow-remove:<username> to remove a user from hidden show'; notice += '\x0Atype !b4t-hiddenshow-check:<username> to check if the user has a ticket'; notice += '\x0Atype !b4t-hiddenshow-list show a list with all ticket holders'; notice += '\x0Atype !b4t-silence i will be silent - for 60 secondes - with conutdown'; notice += '\x0Atype !b4t-hangman-start:<word> to start a game of hangman'; notice += '\x0Atype !b4t-tipjar-show to show the content of the tip jar'; notice += '\x0Atype !b4t-tipjar-set to set the start amount in the tipjar in tokens'; notice += '\x0Athank you for using Shut It 4 Tingles'; cb.sendNotice(notice, user); } //add new bad word to list if(m.substring(0,5) === '!add:' && user === cb.room_slug) { const newWord = m.substring(5).trim(); badWordsArray.push(newWord); message['X-Spam'] = true; cb.sendNotice('new bad word was added to list', user); } //show bad words to all users if(m.substring(0,10) === '!bad words' && user === cb.room_slug) { let notice = '*** Shut It 4 Tingles ***\x0A'; notice += 'Bot is running to prevent bad words, please stay nice\x0A'; notice += 'banned words: ' + badWordsArray.join(', '); notice += '\x0AThank you!'; cb.sendNotice(notice); } //add user to nice list if(m.substring(0,10) === '!niceuser:' && user === cb.room_slug) { const newUser = m.substring(10).trim().toLowerCase(); if (!cbjs.arrayContains(niceListArray, newUser)) { niceListArray.push(newUser); cb.sendNotice('new user was added to nice list', user); } message['X-Spam'] = true; } //remove user from nice lst if(m.substring(0,12) === '!removenice:' && user === cb.room_slug) { const removeUser = m.substring(12).trim().toLowerCase(); if(cbjs.arrayContains(niceListArray, removeUser)) { niceListArray = niceListArray.filter(x => x !== removeUser); cb.sendNotice('user was removed from nice list', user); } message['X-Spam'] = true; } //mute grey users if(m.substring(0, 15) === '!b4t-mute-greys' && user === cb.room_slug) { muteGreyUsers = true; cb.sendNotice('grey users has been muted - sorry.'); message['X-Spam'] = true; } //unmute grey users if(m.substring(0, 17) === '!b4t-unmute-greys' && user === cb.room_slug) { muteGreyUsers = false; cb.sendNotice('grey users has been unmuted - please be kind.'); message['X-Spam'] = true; } if(user === cb.room_slug && m.substring(0,4) === '!b4t') { //start hidden show if(m.substring(0, 21) === '!b4t-hiddenshow-start' && !cb.limitCam_isRunning()) { cb.chatNotice(cb.room_slug + ' has started the show!'); cb.limitCam_start(cb.settings.hide_message); } // stop hidden show if(m.substring(0, 20) === '!b4t-hiddenshow-stop' && cb.limitCam_isRunning()) { cb.chatNotice(cb.room_slug + ' has stopped the show!'); cb.limitCam_stop(); } //add user to hidden show if(m.substring(0, 20) === '!b4t-hiddenshow-add:') { const newGuest = m.substring(20).trim(); if (!cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), newGuest)) { cb.chatNotice('Added '+ newGuest + ' to secret show!'); cb.limitCam_addUsers(newGuest); } } //remove user from hidden show if(m.substring(0, 23) === '!b4t-hiddenshow-remove:') { const guestToRemove = m.substring(23).trim(); if (cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), guestToRemove)) { cb.chatNotice(cb.room_slug + ' removed ' + guestToRemove + ' from secret show!'); cb.limitCam_removeUsers(guestToRemove); } } //check if user is in hidden show if(m.substring(0, 22) === '!b4t-hiddenshow-check:') { const username = m.substring(22).trim(); if (cb.limitCam_userHasAccess(username)) { cb.chatNotice('Yes, ' + username + ' is in the show!'); } else { cb.chatNotice('No, ' + username + ' is NOT in the show'); } } //hidden show: list users if(m.substring(0, 20) === '!b4t-hiddenshow-list') { const users = cb.limitCam_allUsersWithAccess().join(', '); cb.chatNotice('Tickets: ' + users, cb.room_slug, cb.settings.messageBackgroundColor, cb.settings.messageFontColor); } //silence me if(m.substring(0,12) === '!b4t-silence') { const timeout = 60000; cb.chatNotice('Enjoy the silence - countdown has started', '', cb.settings.messageBackgroundColor, cb.settings.messageFontColor); const silenceStatus = [ { timeout: timeout / 2, message: 'Halbzeit - ich schweige weiter ...' }, { timeout: timeout - 15000, message: '... noch 15 Sekunden' }, { timeout: timeout - 10000, message: '... noch 10 Sekunden' }, { timeout: timeout - 5000, message: '... noch 5 Sekunden' }, { timeout: timeout, message: 'Das vielsagende Schweigen ist vorbei. Bis zum nächsten Tip ...'} ]; silenceStatus.map(stat => { cb.setTimeout(() => { cb.chatNotice(stat.message, '', cb.settings.messageBackgroundColor, cb.settings.messageFontColor); }, stat.timeout); }); } //display king/queen tippers if(m.substring(0,) === '!b4t-kings') { const kings = getKingTippers(); const msg = kings.map(t => `${t.username}: ${t.total}`).join('\x0A'); cb.chatNotice(msg); } if(m.substring(0, 19) === '!b4t-hangman-start:') { const phrase = m.substring(19).trim(); startHangman(phrase); } if(m.substring(0, 16) === '!b4t-tipjar-show') { const tip = parseInt(cb.settings.tipjar, 10); const totalAmount = (tipJar * tip) + tipJarStartAt; const msg = 'Tokens in meinem Sparschwein: ' + totalAmount; cb.chatNotice(msg, cb.room_slug, cb.settings.messageBackgroundColor, cb.settings.messageFontColor); } if(m.substring(0, 16) === '!b4t-tipjar-set:') { const value = m.substring(16).trim(); const tokens = parseInt(value, 10); if(!isNaN(tokens)) { tipJarStartAt = tokens; const msg = 'success: set tip jar start value to ' + tokens + ' tokens.'; cb.chatNotice(msg, cb.room_slug, cb.settings.messageBackgroundColor, cb.settings.messageFontColor); } } message['X-Spam'] = true; } if(m.substring(0, 9) === '!hangman ') { let g = m.substring(9).trim().toLowerCase(); getHangmanGuess(g); } return message; }); cb.onTip(function (tip) { const username = tip['from_user']; const amount = parseInt(tip['amount']); const m = tip['message']; if (!cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), username)) { if(!cb.limitCam_isRunning() && amount >= cb.settings.min_start_tokens && cb.settings.min_start_tokens > 0) { cb.chatNotice('Added '+ username + ' to secret show!'); cb.limitCam_addUsers(username); } if(cb.limitCam_isRunning() && amount >= cb.settings.min_join_tokens && cb.settings.min_join_tokens > 0) { cb.chatNotice('Added '+ username + ' to secret show!'); cb.limitCam_addUsers(username); } } let tipper = tippers.find(t => t.username == username); if(tipper) { tipper.total += amount; } else { tippers.push({username: username, total: amount}); } // add to show? if(!cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), username) && cb.settings.min_start_tokens > 0) { const total = tippers.find(t => t.username === username).total; if(!cb.limitCam_isRunning() && total > cb.settings.min_start_tokens) { cb.chatNotice('Added '+ username + ' to secret show!', cb.room_slug, cb.settings.messageBackgroundColor, cb.settings.messageFontColor); cb.limitCam_addUsers(username); } } //tipJar if(amount === cb.settings.tipjar) { tipJar++; if(cb.settings.show_tipjar_thankyou === 'yes') { const msg = cb.settings.tipjar_thankyou.replace('{username}', username); cb.chatNotice(msg, '', cb.settings.messageBackgroundColor, cb.settings.messageFontColor); } } /* if(amount === cb.settings.tokens_to_rate) { cb.chatNotice(username + ' rates a ' + m, cb.room_slug); const rating = parseInt(m, 10); if(NaN !== rating) { ratings.push({username: username, rating: rating}); } } */ }); function getRatingAvg() { return ratings.reduce((total, next) => total + next.rating, 0) / ratings.length; } function checkThisUsersMessage(message) { user = message['user']; /* if(user === cb.room_slug) { return false; } */ if(cbjs.arrayContains(niceListArray, user)) { return false; } if('no' === cb.settings['checkFanclubMembers'] && message['in_fanclub'] === true) { return false; } if(message['is_mod'] === true) { return false; } return true; } function getKingTippers() { const tippers_sorted = tippers.sort((a, b) => a.total - b.total).reverse(); const kings = tippers_sorted.slice(0,4); return kings; } /** Hangman functions ... */ function startHangman(phrase) { hangman_phrase = phrase; hangman_counter = 0; hangman_guess = Array(phrase.length).fill('_'); hangman_fails = []; hangman_hits = []; let msg = '***** Hangman *****\x0A'; msg += cb.room_slug + ' hat ein neues Spiel gestartet - viel Erfolg!\x0A'; msg += 'raten: !hangman x - um einen Buchstaben zu raten\x0A'; msg += 'oder !hangman WORT - um das gesamte Worten zu erraten \x0A'; msg += 'Aber Vorsicht - nach 10 Versuchen gewinnt ' + cb.room_slug; msg += '\x0A' + hangman_guess.join(' '); output(msg); hangman_status = 'running'; } function getHangmanGuess(guess) { if(hangman_status !== 'running') { msg = 'Kein Spiel gestartet ...'; output(msg, ''); return; } if(guess.trim().length === 1) { const clean = guess.trim().toLowerCase(); if(hangman_phrase.toLowerCase().indexOf(clean) > -1) { if(hangman_hits.indexOf(clean) === -1) { hangman_hits.push(clean); } for(let i=0; i < hangman_phrase.length; i++) { if(hangman_phrase[i].toLowerCase() === clean) { hangman_guess[i] = hangman_phrase.substring(i, i+1); } } let msg = 'Treffer: ' + hangman_guess.join(' '); output(msg); } else { if(hangman_fails.indexOf(clean) === -1) { hangman_fails.push(clean); hangman_counter ++; } msg = 'Leider nein - nicht enthalten sind: ' + hangman_fails.sort().join(', '); output(msg); } } else { //try to solve... if(guess === hangman_phrase.toLowerCase()) { for(let i=0; i < hangman_phrase.length; i++) { hangman_guess[i] = hangman_phrase.substring(i,i+1); } let msg = 'Richtig, du hast das Wort erraten! ' + hangman_guess.join(' '); output(msg); hangman_status = 'won'; } else { msg = 'Das ist nicht das Wort, das ich suche ...'; output(msg); hangman_counter ++; } } cb.chatNotice(hangman_counter + ' Fehlversuche'); if(hangman_counter >= 10) { msg = 'Das war Versuch Nummer 10 - verloren! Das Wort lautet: ' + hangman_phrase; output(msg); hangman_status = 'lost'; } } function output(msg, user = '') { cb.chatNotice(msg, user); } tipJarStartAt = parseInt(cb.settings.startTipJarAt, 10); init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.