Bots Home
|
My Uploads
|
Create an App
tattesttttttt
Author:
maxgraff2
Description
Source Code
Launch Bot
Current Users
Created by:
Maxgraff2
App Images
/* * Title: "Chat Speed Notifier" bot * Author: maxgraff * Version: 1.0.3 (05-03-2019) * * Usage: * How to equal Notice speed with chat speed? Let's make chat more countable! * This bot counts the number of messages left in the chat and publishes a Notice after a certain number of messages, not time. * So you can keep Notice separately if chat is slow, and show Notice more often if chat is fast. * The Chat Speed Notifier count only messages left by broadcaster and other users, not by any Notifier. * This bot can display one by one UNLIMITED number of notifications, separated by ";" in settings. * This bot can also display a tip menu in a single line notice. * You can use one of the characters: ❤ ♥ ♡ ★ ☆ ● • █ ■ ◆ ◇ ✿, or any others for separate tip menu messages in one line tip menu. * You can choose colors of text and background for Notice * All messages appear once you start the bot and also once user enter to your room. * * Also you could choose in settings post or not a "special Counter notice" that will display numbers of left messages for the session with a message, for example: "xxx messages was left today, keep going!", * so it's can make chat a bit more interesting for everyone. * * Thanks to the author Bobomb, whose bot Notifier I used as a base for creating my own. * Also feel free to use my code but don't forget mention my name then, I will appreciate that. * * To leave a feedback or suggestion contact me: maxgraff99@gmail.com * * * Change log: * -- 1.0.3 (05-03-2019) -- * > Added presettings. If you are a new user, just click "Launch Bot" to see how it works. * * -- 1.0.2 (12-02-2019) -- * > All messages appear to user who enter to the room. * > You can change message for Counter on whatever you want, but know that number of left messages would be before your Counter message. * * -- 1.0.1 (10-02-2019) -- * > All messages appear once you start the bot. * * -- 1.0.0 (09-02-2019) -- * > Initial release. */ cb.settings_choices = [ {name:'messagesFontColor', type:'str', label:'Notice and Counter font color (html code default green #008000)', defaultValue: '#008000'}, {name:'messagesBackgroundColor', type:'str', label:'Notice and Counter background color (html code default white #FFFFFF)', defaultValue: '#FFFFFF'}, { name: 'messagesChoice', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Post a Notice after amount of messages in the chat?" }, { name: 'interval', type: 'int', minValue: 1, defaultValue: 7, maxValue: 6000, label: "The interval for posting Notice (in messages in the chat)" }, { name: 'messageText', type: 'str', minLength: 1, required: false, defaultValue: 'Wish you all have a good time :thumbsup ; :FollowCandy ; :biorymels ; :keepgoingtip', label: "Messages for Notice, separated by a ; " }, { name: 'counterChoice', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Post a special Counter notice after amount of messages in the chat?" }, { name: 'counterInterval', type: 'int', minValue: 1, defaultValue: 9, maxValue: 6000, label: "The interval for posting a special Counter notice (in messages in the chat)" }, { name: 'counterText', type: 'str', minLength: 1, required: false, defaultValue: ' messages was left today! :Chat :innocent', label: "Message following the counted number of messages in the chat" }, ]; var Plugin = { settings: { interval: true, interval: 9, counterInterval: true, counterInterval: 9 }, messages: [], }; Plugin.Counter4NumbersMessages = function() { var counter = 0; return function() { counter += Plugin.settings.counterInterval; return counter; } }(); Plugin.showNumbersOfMessages = function() { cb.sendNotice(Plugin.Counter4NumbersMessages() + " " + cb.settings['counterText'],'',cb.settings['messagesBackgroundColor'],cb.settings['messagesFontColor'],'bold'); }; Plugin.Counter4RotateMessages = function() { var counter = -1; return function() { if(counter < Plugin.messages.length) { counter += 1; } if(counter >= Plugin.messages.length) { counter = 0; } return counter; } }(); Plugin.showAllMessagesForStart = function() { var x = 0; return function() { while(x < Plugin.messages.length) {cb.sendNotice(Plugin.messages[x],'',cb.settings['messagesBackgroundColor'],cb.settings['messagesFontColor'],'bold'); x += 1;} } }(); Plugin.showAllMessagesForEnter = function(user) { var x = 0; return function(user) { while(x < Plugin.messages.length) {cb.sendNotice(Plugin.messages[x],user['user'],cb.settings['messagesBackgroundColor'],cb.settings['messagesFontColor'],'bold'); x += 1;} if(x >= Plugin.messages.length){ x = 0; } } }(); Plugin.sendNotice = function() { var oneByOneIndex = Plugin.Counter4RotateMessages(); cb.sendNotice(Plugin.messages[oneByOneIndex],'',cb.settings['messagesBackgroundColor'],cb.settings['messagesFontColor'],'bold'); }; Plugin.Counter4ShowNotice = function() { var counter2 = 0; return function() { if(counter2 < Plugin.settings.interval) { counter2 += 1; } if(counter2 >= Plugin.settings.interval) { counter2 = 0; Plugin.sendNotice(); } return counter2; } }(); Plugin.Counter4ShowCounter = function() { var counter2 = 0; return function() { if(counter2 < Plugin.settings.counterInterval) { counter2 += 1; } if(counter2 >= Plugin.settings.counterInterval) { counter2 = 0; Plugin.showNumbersOfMessages(); } return counter2; } }(); Plugin.init = function() { var numbers = 0; if(cb.settings['messagesChoice'] == 'Yes') { Plugin.showAllMessagesForStart(); } cb.onMessage(function () { if(cb.settings['messagesChoice'] == 'Yes') { Plugin.Counter4ShowNotice(); } if(cb.settings['counterChoice'] == 'Yes') { Plugin.Counter4ShowCounter(); numbers += 1; } }); cb.onEnter(function(user) { if(cb.settings['messagesChoice'] == 'Yes') { Plugin.showAllMessagesForEnter(user); } if(cb.settings['counterChoice'] == 'Yes') { cb.sendNotice(numbers + " " + cb.settings['counterText'],user['user'],cb.settings['messagesBackgroundColor'],cb.settings['messagesFontColor'],'bold') } }); }; /* Read the code from there to up^ for andersending how dose it work! Sorry I'm not cleaned up the code yet */ var Bobomb = { // Function grouping SettingsManager: {}, // Constants delimiter: ";" }; /* Settings Manager */ /* translateSetting */ /* Resolve a setting and see if there is a corresponding setting in the ChaturBate settings object */ Bobomb.SettingsManager.translateSetting = function(parentObject, settingName) { // Base the primary action of the type of setting. if(parentObject[settingName].constructor === Object) { // If this is an object, we will want to look at it's children. for(var part in parentObject[settingName]) { // Give every child some attention. Bobomb.SettingsManager.translateSetting(parentObject[settingName], part); } } else { // First, prepare the cb setting name. var cbSettingName = settingName; if(parentObject[settingName].constructor === Array) { cbSettingName = settingName.substring(0, (settingName.length - 1)); cbSettingName += "Text"; } // Now check if there is such a field to be found. if(cb.settings[cbSettingName] !== undefined) { // If the type is array and the cb type is string, try to parse it. if(parentObject[settingName].constructor === Array && cb.settings[cbSettingName].constructor === String) { // If such a setting exists, split up the string using the delimiter. var parts = cb.settings[cbSettingName].split(Bobomb.delimiter); for(var part in parts) { // And add them to the array. parentObject[settingName].push(parts[part].trim()); } } // Else, check if the types are alike. else if(parentObject[settingName].constructor === cb.settings[cbSettingName].constructor) { if(parentObject[settingName].constructor === Number) { // If it is a number, parse it as such and then set it. parentObject[settingName] = parseInt(cb.settings[cbSettingName]); } } } } }; /* translateSettings */ /* Loop through all settings and check for a CB version of it */ Bobomb.SettingsManager.translateSettings = function() { // Check each part in Plugin that is not a constant. for(var part in Plugin) { // And feed it to the translator. Bobomb.SettingsManager.translateSetting(Plugin, part); } }; /* init */ /* Initializes the basic parts of the framework */ Bobomb.init = function() { // Start the translation. Bobomb.SettingsManager.translateSettings(); Plugin.init(); }; /* END */ Bobomb.init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.