Bots Home
|
Create an App
ktestbot765gg8766h6
Author:
_atze_
Description
Source Code
Launch Bot
Current Users
Created by:
_Atze_
// Shut IT (Modified) // Version: 1.0.3 // May 10, 2018 // // Modified from: // Shut IT by kellynumberfan // www.chaturbate.com/kellynumberfan // by Ransyd // // v1.0.3 // Changed // Public words aren't displayed in chat when bot starts. // v1.0.2 // Minor grammar changes // v1.0.1 // Changed // Mods can use !allow // v1.0.0 // Removed: // Exclusion of kellynumberfan from word list check // Added: // Option/command for broadcaster to view blocked message // Displays options set when started (broadcaster only) // Changed: // Commands for respective user level only are shown // Settings for Grey chat and Replace words settings are more understandable // Blocked user list is now optional, previously always had to have a value // Fixed: // User blocking, was blocking when the blocked word appeared in the middle // of ligimate word, eg. 'ass' in 'class'. Now blocked word has to appear // at start of word, eg. 'ass' in 'asshole'. // Replacement of words wasn't working, now replaces each matching word // list word with a different random word from the list. var greyChat = false; var wordsPublic = []; var wordsPrivate = []; var allowReplace = false; var dispMessage = false; var wordReplace = []; var bUsr = []; cb['settings_choices'] = [{ name: 'grey_chat', type: 'choice', choice1: 'No', choice2: 'Yes', defaultValue: 'Yes', label: 'Allow Greys to Chat' }, { name: 'publicWords', type: 'str', minLength: 0, maxLength: 4000, label: 'Public Word List (No Spaces & Comma Separated)', defaultValue: 'open,ass,bb,boobs,hack,b00bs,bob,bobs,tits,slut,cunt,hor,whore,show,pussy,nipple,kitty,much,show,pr0n,porn,pron,naked,nude' }, { name: 'privateWords', type: 'str', minLength: 0, maxLength: 4000, label: 'Private Word List (No Spaces & Comma Separated)', defaultValue: 'firstname,lastname,housenumber,street,phone,city,state,zip' }, { name: 'display_msg', type: 'choice', choice1: 'No', choice2: 'Yes', defaultValue: 'No', label: 'Display blocked message to broadcaster' }, { name: 'allow_replace', type: 'choice', choice1: 'Replace', choice2: 'Block', defaultValue: 'Block', label: 'Replace words or Block user' }, { name: 'replaceWord', type: 'str', minLength: 0, maxLength: 4000, label: 'Replacement Words (No Spaces & Comma Separated)', defaultValue: 'smile' }, { name: 'backgroundColor', type: 'str', minLength: 0, maxLength: 7, label: 'Message Background Color', defaultValue: '#FFFF00' }, { name: 'fontColor', type: 'str', minLength: 0, maxLength: 7, label: 'Message Font Color', defaultValue: '#0000FF' }, { name: 'blockUsers', type: 'str', minLength: 0, maxLength: 4000, label: '[Optional] Block Users List (Comma Separated)', defaultValue: '', required: false }]; cb['onMessage'](function(msg) { var blockedUsers = ''; var user = msg['user']; var msgString = msg['m']; msgString = msgString.toLowerCase(); var isHost = (cb.room_slug == user); var isMod = msg['is_mod']; var isFan = msg['in_fanclub']; var isViewer = (!isHost && !isMod && !isFan); var isGrey = (!msg['has_tokens']); if (!greyChat && isGrey && !isMod && !isFan) { msg['X-Spam'] = true; return msg }; if (IsBlockedUser(user)) { cb['sendNotice']('You have been blocked from chatting.', user, cb['settings']['backgroundColor'], cb['settings']['fontColor'], 'bold'); msg['X-Spam'] = true; return msg }; if (msgString[0] == '!') { msg['X-Spam'] = true }; if ((msgString == '!list') || (msgString == '!l')) { ShowWords(wordsPublic, user); return msg }; if (msgString == '!help' || (msgString == '!h')) { var notices = '***** Commands ******\x0A** !List - displays public words'; if (isMod || isHost) { notices += '\x0A** !add <word> - Add a word to public list.\x0A** !block <user> - Block the User.\x0A** !unblock <user> - Unblock the user.\x0A** !su or !showusers - Display blocked users.'; } if (isHost) { notices += '\x0A** !addprivate <word> - Add a word to private list.\x0A** !listprivate - Shows Broadcaster only the private word list.\x0A** !allow - Switch between Block user & Replace word.'; } cb['sendNotice'](notices, user); return msg }; if (isViewer) { if (CheckBannedWords(msgString)) { if (!allowReplace) { cb['sendNotice']('User: ' + user + ' has been blocked.', '', cb['settings']['backgroundColor'], cb['settings']['fontColor'], 'bold'); bUsr['push'](user); msg['X-Spam'] = true } else { msg['m'] = ReplaceBannedWords(msgString); } if (dispMessage) { cb['sendNotice']('Message: ' + msgString, cb.room_slug, cb['settings']['backgroundColor'], cb['settings']['fontColor'], 'bold'); } }; return msg }; if (isHost) { if (msgString['substring'](0, 12) == '!addprivate ') { wordsPrivate['push'](msgString['substring'](12)); }; if (msgString === '!listprivate') { ShowWords(wordsPrivate, cb['room_slug']); }; if (msgString === '!display') { dispMessage = !dispMessage; cb['sendNotice']('Display original message: ' + (dispMessage ? 'Yes' : 'No'), user, cb['settings']['backgroundColor'], cb['settings']['fontColor'], 'bold'); } }; if (isHost || isMod) { if (msgString === '!allow') { allowReplace = !allowReplace; cb['sendNotice']('Replace words or Block user: ' + (allowReplace ? 'Replace' : 'Block'), user, cb['settings']['backgroundColor'], cb['settings']['fontColor'], 'bold'); } if (msgString['substring'](0, 5) == '!add ') { wordsPublic['push'](msgString['substring'](5)); }; if ((msgString['substring'](0, 6) == '!block') && (cb['room_slug'] != user || !msg['is_mod'] || !msg['in_fanclub'])) { bUsr['push'](msgString['substring'](7)); cb['sendNotice']('User: ' + msgString['substring'](7) + ' has been blocked.', '', cb['settings']['backgroundColor'], cb['settings']['fontColor'], 'bold'); }; if (msgString['substring'](0, 8) == '!unblock') { bUsr['removeItem'](msgString['substring'](9)); cb['sendNotice']('User: ' + msgString['substring'](9) + ' has been unblocked.', '', cb['settings']['backgroundColor'], cb['settings']['fontColor'], 'bold'); }; if (msgString === '!showusers' || msgString === '!showuser' || msgString === '!su') { if (bUsr['length'] > 0) { blockedUsers += '[Blocked Users]:'; blockedUsers += readList(bUsr); } else { blockedUsers += '[Blocked Users]: No users blocked'; } cb['sendNotice'](blockedUsers, user, cb['settings']['backgroundColor'], cb['settings']['fontColor'], 'bold'); } }; return msg; }); function IsBlockedUser(usr) { return (bUsr['contains'](usr)); } function CheckBannedWords(inputString) { var remainAlpha = []; var alphaString = inputString['replace'](/[^a-zA-Z ]/gi, ''); // Strip anything not alpha var alphaSplit = alphaString['split'](' '); // Turn string into array at word boundaries remainAlpha = reduce(alphaSplit, wordsPrivate); if (remainAlpha['length'] > 0) { return true }; remainAlpha = reduce(alphaSplit, wordsPublic); if (remainAlpha['length'] > 0) { return true }; return false } function reduce(inputString, inputList) { inputList = new RegExp(inputList['join']('|\\b')['toLowerCase']()); for (var remainingWords = [], i = inputString['length']; i--;) { inputList['test'](inputString[i]['toLowerCase']()) && remainingWords['unshift'](inputString[i]['toLowerCase']()) }; return remainingWords } function ReplaceBannedWords(inputString) { var replaceString = ''; var replaceChars = 0; var outputString = inputString; for (var i = 0; i < wordsPrivate['length']; i++) { replaceChars = Math['floor']((Math['random']() * wordReplace['length'])); replaceString = wordReplace[replaceChars]; outputString = outputString['replace'](new RegExp('\\b' + wordsPrivate[i] + '\\w*', 'g'), replaceString); } for (var i = 0; i < wordsPublic['length']; i++) { replaceChars = Math['floor']((Math['random']() * wordReplace['length'])); replaceString = wordReplace[replaceChars]; outputString = outputString['replace'](new RegExp('\\b' + wordsPublic[i] + '\\w*', 'g'), replaceString); } return outputString } function ShowWords(wordList, usr) { var notice = ''; var toUser = ''; notice = readList(wordList); if (usr == null || usr == undefined || usr['length'] == 0) { toUser = '' } else { toUser = usr }; cb['sendNotice'](notice, toUser, cb['settings']['backgroundColor'], cb['settings']['fontColor'], 'bold') } function readList(list) { var temp = ''; for (var i = 0; i < list['length']; i++) { if (temp['length'] > 0) { temp += ',' }; temp += list[i] }; return temp } function LoadSettings() { greyChat = (cb['settings']['grey_chat'] == 'Yes') allowReplace = (cb['settings']['allow_replace'] == 'Replace'); dispMessage = (cb['settings']['display_msg'] == 'Yes'); if (!isBlank(cb['settings']['blockUsers'])) { LoadArrays(cb['settings']['blockUsers'], bUsr); } LoadArrays(cb['settings']['publicWords'], wordsPublic); LoadArrays(cb['settings']['privateWords'], wordsPrivate); LoadArrays(cb['settings']['replaceWord'], wordReplace) } function LoadArrays(inputSettings, outputArray) { var temp1; var temp2; var temp3; temp1 = inputSettings; temp2 = temp1 ? temp1['split'](',') : ''; for (var i = 0; i <= temp2['length']; ++i) { temp3 = ''; if (temp2[i] != null) { temp3 = temp2[i]['replace'](/ +$/, ''); if (temp3['length'] > 0) { outputArray['push'](temp3) } } } } // Checks if setting is empty/not set -- from Bomb Bot Ultra ------------------- function isBlank(cbsetting) { var s; if (cbsetting) { s = cbsetting.trim(); } if (s == null || s == '' || s.substr(0, 9) == '[Optional') { return true; } else { return false; } } function init() { cb['sendNotice']('-----------------------------------------\x0A--- Shut IT Modified v1.0.3\x0A --- Ransyd\x0A-----------------------------------------'); LoadSettings(); var notice = 'Allow greys to chat: ' + (greyChat ? 'Yes' : 'No'); notice += '\x0ADisplay original message: ' + (dispMessage ? 'Yes' : 'No'); notice += '\x0AReplace words/Block user: ' + (allowReplace ? 'Replace' : 'Block'); cb['sendNotice'](notice, cb.room_slug, cb['settings']['backgroundColor'], cb['settings']['fontColor'], 'bold') } String['prototype']['trim'] = function() { return this['replace'](/^\s+|\s+$/g, '') }; Array['prototype']['contains'] = function(element) { var i = this['length']; while (i--) { if (this[i] === element) { return true } }; return false }; Array['prototype']['removeItem'] = function(key) { for (i = 0; i < this['length']; i++) { if (this[i] == key) { for (i2 = i; i2 < this['length'] - 1; i2++) { this[i2] = this[i2 + 1] }; this['length'] = this['length'] - 1; return } } }; init()
© Copyright Chaturbate 2011- 2024. All Rights Reserved.