Bots Home
|
Create an App
All In One Bot - 2048 edition (2
Author:
axmcb
Description
Source Code
Launch Bot
Current Users
Created by:
Axmcb
/*************************************************************************************************** * Bot logic class ***************************************************************************************************/ class AxMCBBot { /*********************************************************************************************** * Create empty handler and settings arrays ***********************************************************************************************/ constructor() { this._handlers = [ ]; this._settings = [ ]; } /*********************************************************************************************** * function add(handler) * - handler: Reference of handler to add * Appends the given handler to our internal list of handlers * Appends any handler settings to our internal list of settings ***********************************************************************************************/ add(handler) { this._handlers.push(handler); if (handler.settings) { var settings = this._settings.concat(handler.settings()); var header_set = false; for (var setting of settings) { // Do some sanity checking first if ( !('name' in setting) || !('type' in setting) ) { // Invalid setting, name and type are required continue; } if (setting['type'] == 'choice') { if ( !('choices' in setting) ) { // Invalid setting, choices are required for type choice continue; } } if (!header_set) { // Update first setting as a section header var label = ('label' in setting) ? setting['label'] : setting['name']; var label_start = (this._handlers.length + 1) + ') '; setting['label'] = label_start + label; header_set = true; } // Add setting to full list of settings this._settings.push(setting); } } } /*********************************************************************************************** * function buildSettings() * Build an array of settings for use by the cb object ***********************************************************************************************/ buildSettings() { var settings = [ ]; for (var _setting of this._settings) { var setting = { }; setting['name'] = _setting['name']; setting['type'] = _setting['type']; if ('label' in _setting) { setting['label'] = _setting['label']; } if (setting['type'] == 'choice') { for (var i = 1; i <= _setting['choices'].length; i++) { setting['choice'+i] = _setting['choices'][i-1]; } } setting['required'] = ('required' in _setting && _setting['required']); if ('default' in _setting) { setting['defaultValue'] = _setting['default']; } if ('minLength' in _setting) { setting['minLength'] = _setting['minLength']; } if ('maxLength' in _setting) { setting['maxLength'] = _setting['maxLength']; } settings.push(setting); } return settings; } } /*************************************************************************************************** * Base handler class ***************************************************************************************************/ class AxMCBBotHandler { /*********************************************************************************************** * Initialize local settings variable ***********************************************************************************************/ constructor() { this._enabled = false; this._settings = [ ]; } /*********************************************************************************************** * function settings() * Return reference to local settings ***********************************************************************************************/ settings() { return this._settings; } } /*************************************************************************************************** * Personalization handler class ***************************************************************************************************/ class AxMCBBotPersonalization extends AxMCBBotHandler { /*********************************************************************************************** * Initialize local variables ***********************************************************************************************/ constructor() { super(); // Call base class constructor this._enabled = true; this._settings.push({ name: 'colorscheme', label: 'Color Scheme', type: 'choice', choices: [ 'Purple', 'Pink', 'Blue', 'Red', 'Green', 'Halloween', 'Christmas', 'Custom (Define below)' ] }); this._settings.push({ name : "darkcolor", label : 'Custom Text Color (Html #code)', type : "str" }); this._settings.push({ name : "lightcolor", label : 'Custom Highlight Color (Html #code)', type : "str" }); this._settings.push({ name: 'crazyNoteColorscheme', label: 'Crazy Note Color Scheme (Only for /cn /cnd /cnh /cndh) - Theme is colors picked above', type: 'choice', choices: [ 'Theme', 'Custom (Define below)' ], default: 'Theme' }); this._settings.push({ name : "crazyNoteText", label : 'Custom Text Color - HTML color code (without #)', type : "str" }); this._settings.push({ name : "crazyNoteBackground", label : 'Custom Highlight Color - HTML color code (without #)', type : "str" }); this._settings.push({ name: 'enterMessage', label: 'Welcome Message', type: 'str', minLength: 1, maxLength: 1000 }); } } /*************************************************************************************************** * Room Control handler class ***************************************************************************************************/ class AxMCBBotRoomControl extends AxMCBBotHandler { } /*************************************************************************************************** * Word Lists handler class ***************************************************************************************************/ class AxMCBBotWordLists extends AxMCBBotHandler { } /*************************************************************************************************** * King Tippers handler class ***************************************************************************************************/ class AxMCBBotKingTippers extends AxMCBBotHandler { } /*************************************************************************************************** * Fan Clubs handler class ***************************************************************************************************/ class AxMCBBotFanClubs extends AxMCBBotHandler { } /*************************************************************************************************** * Notifiers handler class ***************************************************************************************************/ class AxMCBBotNotifiers extends AxMCBBotHandler { } /*************************************************************************************************** * Tip Menu handler class ***************************************************************************************************/ class AxMCBBotTipMenu extends AxMCBBotHandler { } /*************************************************************************************************** * Main program execution start point ***************************************************************************************************/ var bot = new AxMCBBot(); bot.add(new AxMCBBotPersonalization()); cb.settings_choices = bot.buildSettings(); //console.log(bot.buildSettings());
© Copyright Chaturbate 2011- 2025. All Rights Reserved.