Bots Home
|
Create an App
yuiryu
Author:
mistressadelle
Description
Source Code
Launch Bot
Current Users
Created by:
Mistressadelle
var broadcaster = cb.room_slug; function SpamStatItem() { this.count = 0; this.banExpires = null; } var AntiSpam = {} AntiSpam.registered_managers = []; AntiSpam.register = function(manager){ AntiSpam.registered_managers.push(manager); } AntiSpam.manager = null; AntiSpam.getMainManager = function(){ if (AntiSpam.manager == null){ AntiSpam.manager = new AntiSpam.MainManager(); } return AntiSpam.manager; } AntiSpam.MainManager = function(){ this.humiliation_mode = cb.settings.humiliation_mode; this.broadcaster = cb.room_slug; this.spam_limit = cb.settings.spam_limit; this.banTime = cb.settings.ban_time; for (var i=0; i<AntiSpam.registered_managers.length; i++){ var mgr = AntiSpam.registered_managers[i]; mgr.init(); } this.spam_managers = AntiSpam.registered_managers; this.spam_stats = []; this.timeout = null; this.get_spam_stat = function(user){ if ( ! this.isSpammer(user) ){ this.spam_stats[user] = new SpamStatItem(); } return this.spam_stats[user]; } this.isSpammer = function(user){ return (user in this.spam_stats); } this.checkSpam = function(msg){ if (msg.is_mod || msg.user == broadcaster){ if (msg.m == "/stats"){ msg["X-Spam"] = true; this.showStats(msg.user); return; } } if ( msg["X-Spam"] == true ){ return; // if already marked as spam, do nothing } if (this.isSpammer(msg.user)) { var spam_stat = this.get_spam_stat(msg.user); if (spam_stat.banExpires != null){ var now = new Date().getTime(); if (spam_stat.banExpires <= now){ spam_stat.banExpires = null; } else { msg["X-Spam"] = true; cb.chatNotice("Your message was not displayed", msg.user); return; } } } for (var i=0; i<this.spam_managers.length; i++){ var spam_mgr = this.spam_managers[i]; if (spam_mgr.isSpam(msg)) { msg["X-Spam"] = true; cb.chatNotice("Your message was not displayed", msg.user); spam_mgr.onSpam(msg); var spam_stat = this.get_spam_stat(msg.user); spam_stat.count ++; this.checkBan(msg); break; } } } this.checkBan = function(msg){ var spam_stat = this.get_spam_stat(msg.user); if (spam_stat.count >= this.spam_limit){ spam_stat.banExpires = new Date().getTime() + this.banTime * 60000; if (this.humiliation_mode == 'True'){ cb.chatNotice("User " + msg.user + " has been silenced for "+ this.banTime + " minutes!"); } else { cb.chatNotice("You have been silenced for "+ this.banTime + " minutes!", msg.user); } } } this.showStats = function(caller){ var message = "Spammers:\n"; for (var user in this.spam_stats){ var spam_stat = this.spam_stats[user]; message+= user + " " + spam_stat.count; if (spam_stat.banExpires != null){ message+= " (banned)"; } message += "\n"; } cb.chatNotice(message, caller); } } /*=========== end of fixed part of the code ==========================*/ /*========== Spam managers ===========================================*/ if(typeof(String.prototype.trim) === "undefined") { String.prototype.trim = function() { return String(this).replace(/^\s+|\s+$/g, ''); }; } // Manages list of forbidden expressions function BadWordsManager() { this.init = function(){ this.bad_words = []; var bad_words = cb.settings.bad_words.split(','); for (var i=0; i<bad_words.length; i++ ){ var word = bad_words[i]; this.bad_words.push(word.trim()); } } this.isSpam = function (msg){ var message = msg["m"]; if (msg.user == broadcaster || msg.is_mod){ return false; } for (var i=0; i<this.bad_words.length; i++){ var word = this.bad_words[i]; if (message.indexOf(word) >= 0 ) return true; } return false; } this.onSpam = function(msg){ cb.chatNotice("Forbidden words detected!", msg.user); } } AntiSpam.register(new BadWordsManager()); // Detect flooding users function FloodManager() { this.init = function(){ this.flood_limit = cb.settings.flood_limit; this.last_speaker = null; this.count = 0; } this.isSpam = function (msg){ if (msg.user == broadcaster || msg.is_mod){ this.last_speaker == null; this.count = 0; return false; } if (this.last_speaker == msg.user){ this.count ++; } else { this.last_speaker = msg.user; this.count = 1; } return (this.count >= this.flood_limit); } this.onSpam = function(msg){ cb.chatNotice("Flood detected!", msg.user); } } AntiSpam.register(new FloodManager()); function NoCapsManager() { this.init = function(){ this.noCaps = cb.settings.no_caps; }; this.isSpam = function(msg){ if (this.noCaps == 'True'){ if (msg.m == msg.m.toUpperCase()){ msg.m = msg.m.toLowerCase(); } } return false; } this.onSpam = function(msg){} } AntiSpam.register(new NoCapsManager()); //штука для кастома if (cb.room_slug == 'mistressadelle') { cb.settings_choices = [ {name: 'toc0', label: '**************************************************************** Welcome back, Mistress! ****************************************************************', type: 'choice',required: false}, {name: 'toc1', label: 'Section_1_Notices************', type: 'choice',required: false}, {name: 'msgonentry', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Display Message 1 privately on entry - set to no for busy rooms"}, {name:'msg1', type:'str', required: false, label:'Message 1',}, {name:'msg2', type:'str', required: false, label:'Message 2',}, {name:'msg3', type:'str', required: false, label:'Message 3',}, {name:'msg4', type:'str', required: false, label:'Message 4',}, {name:'msg5', type:'str', required: false, label:'Message 5',}, {name:'msg6', type:'str', required: false, label:'Message 6',}, {name:'msg7', type:'str', required: false, label:'Message 7',}, {name:'msg8', type:'str', required: false, label:'Message 8',}, {name:'msg9', type:'str', required: false, label:'Message 9',}, {name:'msg10', type:'str', required: false, label:'Message 10',}, {name:'msg11', type:'str', required: false, label:'Message 11',}, {name:'msg12', type:'str', required: false, label:'Message 12',}, {name:'msg13', type:'str', required: false, label:'Message 13',}, {name:'msg14', type:'str', required: false, label:'Message 14',}, {name:'msg15', type:'str', required: false, label:'Message 15',}, {name:'msg16', type:'str', required: false, label:'Message 16',}, {name:'msg17', type:'str', required: false, label:'Message 17',}, {name:'msg18', type:'str', required: false, label:'Message 18',}, {name:'msg19', type:'str', required: false, label:'Message 19',}, {name:'msg20', type:'str', required: false, label:'Message 20',}, {name:'msg21', type:'str', required: false, label:'Message 21',}, {name:'msg22', type:'str', required: false, label:'Message 22',}, {name:'msg23', type:'str', required: false, label:'Message 23',}, {name:'msg24', type:'str', required: false, label:'Message 24',}, {name:'msg25', type:'str', required: false, label:'Message 25',}, {name:'msg26', type:'str', required: false, label:'Message 26',}, {name:'msg27', type:'str', required: false, label:'Message 27',}, {name:'msg28', type:'str', required: false, label:'Message 28',}, {name:'msg29', type:'str', required: false, label:'Message 29',}, {name:'msg30', type:'str', required: false, label:'Message 30',}, {name:'msg31', type:'str', required: false, label:'Message 31',}, {name:'msg32', type:'str', required: false, label:'Message 32',}, {name:'msg33', type:'str', required: false, label:'Message 33',}, {name:'msg34', type:'str', required: false, label:'Message 34',}, {name:'msg35', type:'str', required: false, label:'Message 35',}, {name:'msg36', type:'str', required: false, label:'Message 36',}, {name:'msg37', type:'str', required: false, label:'Message 37',}, {name:'msg38', type:'str', required: false, label:'Message 38',}, {name:'msg39', type:'str', required: false, label:'Message 39',}, {name:'msg40', type:'str', required: false, label:'Message 40',}, {name:'msg41', type:'str', required: false, label:'Message 41',}, {name:'msg42', type:'str', required: false, label:'Message 42',}, {name:'msg43', type:'str', required: false, label:'Message 43',}, {name:'msg44', type:'str', required: false, label:'Message 44',}, {name:'msg45', type:'str', required: false, label:'Message 45',}, {name:'msg46', type:'str', required: false, label:'Message 46',}, {name:'msg47', type:'str', required: false, label:'Message 47',}, {name:'msg48', type:'str', required: false, label:'Message 48',}, {name:'msg49', type:'str', required: false, label:'Message 49',}, {name:'msg50', type:'str', required: false, label:'Message 50',}, {name:'msg51', type:'str', required: false, label:'Message 51',}, {name:'msg52', type:'str', required: false, label:'Message 52',}, {name:'msg53', type:'str', required: false, label:'Message 53',}, {name:'msg54', type:'str', required: false, label:'Message 54',}, {name:'msg55', type:'str', required: false, label:'Message 55',}, {name:'msg56', type:'str', required: false, label:'Message 56',}, {name:'msg57', type:'str', required: false, label:'Message 57',}, {name:'msg58', type:'str', required: false, label:'Message 58',}, {name:'msg59', type:'str', required: false, label:'Message 59',}, {name:'msg60', type:'str', required: false, label:'Message 60',}, {name:'msg61', type:'str', required: false, label:'Message 61',}, {name:'msg62', type:'str', required: false, label:'Message 62',}, {name:'msg63', type:'str', required: false, label:'Message 63',}, {name:'msg64', type:'str', required: false, label:'Message 64',}, {name:'msg65', type:'str', required: false, label:'Message 65',}, {name:'msg66', type:'str', required: false, label:'Message 66',}, {name:'msg67', type:'str', required: false, label:'Message 67',}, {name:'msg68', type:'str', required: false, label:'Message 68',}, {name:'msg69', type:'str', required: false, label:'Message 69',}, {name:'msg70', type:'str', required: false, label:'Message 70',}, {name:'msg71', type:'str', required: false, label:'Message 71',}, {name:'msg72', type:'str', required: false, label:'Message 72',}, {name:'msg73', type:'str', required: false, label:'Message 73',}, {name:'msg74', type:'str', required: false, label:'Message 74',}, {name:'msg75', type:'str', required: false, label:'Message 75',}, {name:'msg76', type:'str', required: false, label:'Message 76',}, {name:'msg77', type:'str', required: false, label:'Message 77',}, {name:'msg78', type:'str', required: false, label:'Message 78',}, {name:'msg79', type:'str', required: false, label:'Message 79',}, {name:'msg80', type:'str', required: false, label:'Message 80',}, {name:'msg81', type:'str', required: false, label:'Message 81',}, {name:'msg82', type:'str', required: false, label:'Message 82',}, {name:'msg83', type:'str', required: false, label:'Message 83',}, {name:'msg84', type:'str', required: false, label:'Message 84',}, {name:'msg85', type:'str', required: false, label:'Message 85',}, {name:'msg86', type:'str', required: false, label:'Message 86',}, {name:'msg87', type:'str', required: false, label:'Message 87',}, {name:'msg88', type:'str', required: false, label:'Message 88',}, {name:'msg89', type:'str', required: false, label:'Message 89',}, {name:'msg90', type:'str', required: false, label:'Message 90',}, {name:'msg91', type:'str', required: false, label:'Message 91',}, {name:'msg92', type:'str', required: false, label:'Message 92',}, {name:'msg93', type:'str', required: false, label:'Message 93',}, {name:'msg94', type:'str', required: false, label:'Message 94',}, {name:'msg95', type:'str', required: false, label:'Message 95',}, {name:'msg96', type:'str', required: false, label:'Message 96',}, {name:'msg97', type:'str', required: false, label:'Message 97',}, {name:'msg98', type:'str', required: false, label:'Message 98',}, {name:'msg99', type:'str', required: false, label:'Message 99',}, {name:'msg100', type:'str', required: false, label:'Message 100',}, {name:'msgcolor', type:'str', label:'Notice color (html code default dark red #9F000F)', defaultValue: '#9F000F'}, {name: 'chat_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 1, label: 'Delay in minutes between notices being displayed (minimum 1)'}, {name: 'toc2', label: 'Section_2_Rainbow_chat************', type: 'choice',required: false}, {name: 'InputName1', type: 'str', label: 'Not used for anything', defaultValue: 'SomeText'}, {name: 'toc3', label: 'Section_3_Hide_gray_chatting************', type: 'choice',required: false}, { name: "msg_replace", type: "str", minLength: 1, maxLength: 255, defaultValue: "[message hidden. please purchase tokens to chat and tip.]", label: "Replace messages of users without tokens with this message", required: true }, { name: "msg_control", label: "Show message to all", type: "choice", choice1: "yes", choice2: "no", defaultValue: "no", required: true }, { name : "humiliation_mode", label : 'Humiliation Mode', type : 'choice', choice1 : true, choice2 : false, default: false }, { name : 'spam_limit', label : 'Max number of authorized spams', type : 'int', minValue: 0, maxValue: 15, default: 5 }, { name : "flood_limit", label : 'Maximum consecutive messages before flooding', type : 'int', minValue: 5, maxValue: 20, default: 5 }, { name : "ban_time", label : "Ban duration (in minutes)", type : 'int', minValue: 1, maxValue: 30, default: 5 }, { name : "bad_words", label: "Banned words (separate with comma)", type : 'str', default: "will u, show me, can u" },{ name : "no_caps", label : 'Convert messages in caps ?', type : 'choice', choice1 : true, choice2 : false, default: true } //кастом условие два ]; } else { cb.settings_choices = [ {name: 'warning', label: 'Sorry, this bot is only usable for broadcaster Mistress Adele', type: 'choice',required: false}, ]; } var i=1; cb.onEnter(function(user) { if (cb.settings['msgonentry'] == 'yes') { cb.sendNotice('Welcome ' + user['user'] + '! ' + cb.settings['msg1'],user['user'],'',cb.settings['msgcolor'],'bold'); } }); function chatAd() { var msg; while (cb.settings['msg' + i] == 0) { //skip empty messages i++; if (i > 100) { //loop back to first message i=1; } } msg = cb.settings['msg' + i]; i++; if (i > 100) { //loop back to first message i=1; } cb.sendNotice(msg,'','',cb.settings['msgcolor'],'bold'); cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); } cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); function is_model(message) { return (message.user == cb.room_slug); } cb.onMessage(function (message) {message['background'] = "linear-gradient(to right, rgba(255,50,50,0.3) 0%,rgba(255,255,48,0.3) 26%,rgba(40,255,251,0.3) 60%,rgba(169,40,255,0.3) 99%)"; var antiSpam = AntiSpam.getMainManager(); antiSpam.checkSpam(msg); var msg = cb.settings.msg_replace; if ((!message.has_tokens) && (!message.is_mod) && (!message.in_fanclub) && (!is_model(message))) { message.m = msg; if (cb.settings.msg_control == "no"){ message.m = msg; message['X-Spam'] = true; } } return message; });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.