Bots Home
|
My Uploads
|
Create an App
Message Counter
Author:
maxgraff2
Description
Source Code
Launch Bot
Current Users
Created by:
Maxgraff2
App Images
/* * Title: "Message Counter" bot * Author: maxgraff * Version: 1.0.2 (09-03-2019) * * Usage: * The main idea of this bot is count how much messages left by viewers in order to measure of activities of model's viewers (and "warm up" their activity). * The bot count only MESSAGES left by broadcaster and other users, not by any Notifiers (including tips notification). * This bot counts the number of messages left in the chat and publishes this info in the chat after a certain number of messages, * for example: "xxx messages was left today, keep going!" will appear in the chat after every 17 messages (you can set the interval in the settings, * and you can choose colors of text and background for counter notice) * You can choose post Counter notice to everyone in the room or this information will be posting only for broadcaster (in this case it will be just numbers, for example "Notice: 17, Notice: 34" and so on) * I made it optional, so you can simply track actions for yourself or for testing purposes. * * Also check out my other bot "Chat Speed Notifier+", it 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. * * Thanks to the author Bobomb, whose bot Notifier I used as a base for creating my own. * And 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.2 (09-03-2019) -- * > The number of messages appear to user who enter to the room, if you choose "YES". * * -- 1.0.1 (05-03-2019) -- * > Added presettings. If you are a new user, just click "Launch Bot" to see how it works. * * -- 1.0.0 (13-02-2019) -- * > Initial release. */ cb.settings_choices = [ { name: 'counterChoice', type: 'choice', choice1: 'YES', choice2: 'NO', defaultValue: 'YES', label: "Show Counter to everyone in the room? (if NO, only you will see Counter in the chat as only numbers)" }, { 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: "Write a message. It will look like 'x (number of messages left) + your message'" }, {name:'messagesFontColor', type:'str', label:'Counter font color (html code default green #008000)', defaultValue: '#008000'}, {name:'messagesBackgroundColor', type:'str', label:'Counter background color (html code default white #FFFFFF)', defaultValue: '#FFFFFF'}, ]; var Plugin = { settings: {counterInterval: true, counterInterval: 9}, messages: [], }; Plugin.Counter4NumbersMessages = function() { var counter = 0; return function() { counter += Plugin.settings.counterInterval; return counter; } }(); Plugin.showNumbersOfMessages = function() { if(cb.settings['counterChoice'] == 'YES'){ cb.sendNotice(Plugin.Counter4NumbersMessages() + " " + cb.settings['counterText'],'',cb.settings['messagesBackgroundColor'],cb.settings['messagesFontColor'],'bold'); } if(cb.settings['counterChoice'] == 'NO'){ cb.sendNotice(Plugin.Counter4NumbersMessages(), cb.room_slug); } }; 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; cb.onMessage(function () { Plugin.Counter4ShowCounter(); numbers += 1; }); //to show numbers after enter cb.onEnter(function(user) { if(cb.settings['counterChoice'] == 'YES') { cb.sendNotice(numbers + " " + cb.settings['counterText'],user['user'],cb.settings['messagesBackgroundColor'],cb.settings['messagesFontColor'],'bold') } }); //to show numbers after lounch the bot if(cb.settings['counterChoice'] == 'YES'){ cb.sendNotice(numbers + " " + cb.settings['counterText'],'',cb.settings['messagesBackgroundColor'],cb.settings['messagesFontColor'],'bold') } }; /* Read the code from there to up^ for andersending how dose it work! */ 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.