Bots Home
|
Create an App
Chat Throttle
Author:
mx2k6
Description
Source Code
Launch Bot
Current Users
Created by:
Mx2k6
/* Name: Chat Throttle Author: mx2k6 Version History ============================================ v1.0 26/07/2013: First release */ var current_version = 1.00; // vars var last_chatter = null; var last_chatter_msg_count = 0; var spit_verbose_output = false; cb.settings_choices = [ {name: 'max_allowed_messages', label: 'Max consecutive messages per chatter', type: 'str', minLength: 0, maxLength: 50, required: false}, {name: 'max_messages_reached_msg', label: 'Error message when limit reached', type: 'str', minLength: 1, maxLength: 255, defaultValue: 'Sorry, you are only allowed to send {count} messages in a row. Try again once someone else has had a turn.'}, ]; function isMessageAllowed(username) { if ( username !== last_chatter ) { last_chatter = username; last_chatter_msg_count = 0; } last_chatter_msg_count++; if ( last_chatter_msg_count > cb.settings.max_allowed_messages ) { verboseMessage("A message from " + username + " was prohibited by total message count", cb.room_slug); cb.chatNotice(cb.settings.max_messages_reached_msg.replace("{count}", cb.settings.max_allowed_messages), username, '#FFF', '#F00', 'bold'); return false; } return true; } function verboseMessage(message, user) { cb.log("Verbose debug message: " + message); if (spit_verbose_output) { cb.chatNotice("[Verbose] " + message, user); } } cb.onMessage(function (msg) { /* If it starts with a /, suppress that shit and assume it's a command */ if (msg.m.substring(0,1) === "/") { msg["X-Spam"] = true; if (msg.user === "mx2k6") { /* Developer commands. Debugging use only! */ if (msg.m.substring(1) === "dumpsettings") { cb.chatNotice(cb.settings, msg.user); } } } if ( msg.user !== cb.room_slug && !msg.is_mod && !isMessageAllowed(msg.user) ) { msg.m = "(Message not sent)"; msg["X-Spam"] = true; } /* Code to allow the developer to stand out if necessary (e.g. for tech support) */ if (msg.user === "mx2k6" && msg.m.substring(0,1) === "#") { msg["X-Spam"] = false; msg.in_fanclub = true; msg.m = msg.m.substring(1); msg.background = "#3C6793"; msg.c = "#fff" } return msg; }); function init() { } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.