|BRenBot for 4.1 [message #485718]
||Thu, 06 February 2014 07:28
Registered: June 2004
The server files for TT 4.1 include the very latest version of BRenBot, the source of which is available on the BRenBot SVN. This topic will cover a few of the important changes server owners should be aware of and I may update it from time to time if there is anything else suitable to add.|
Reduced built-in functionality
As has been the trend with BRenBot for a while now I've been steadily removing features from the core of the bot in favour of providing plugins for those features.
The reason for this is to reduce the complexity of the core codebase and make it more maintainable as well as reducing the amount of configuration settings and commands that come with a stock installation. It also helps to improve the plugin API as I add new functions to expose functionality required by plugins.
The following functionality has been moved into plugins since the 4.0 release of BRenBot;
- Donations (Note: Also gained an additional !teamdonate command as part of the move to a plugin)
- Join Messages
These plugins are available on the BRenBot SVN.
Reworked Map Settings
The map settings code in BRenBot has been substantially overhauled to reduce code duplication and provide a more flexible architecture. Plugins can now access the global and per-map settings as well as their own custom settings which can be placed in the mapsettings.xml file.
Mainly intended for use with mods, this file replaces the old autodetection logic which used to provide limited support for APB. This file contains the abbreviation, name and IRC colours to use for team 0 (Nod), 1 (GDI) and 2 (Neutral). The stock copy of this file contains the default settings for use with Renegade, however if you prefer to use different colours (or add background colours) for teams in IRC you can customise them through this file.
BRenBot 1.53.19 is now built against Strawberry Perl rather than ActivePerl and is using a much newer version than before. No longer will you get the message about tied XML handles being deprecated.
Overhauled Plugin Loader
The plugin loader has been completely overhauled and now supports loading and unloading plugins at runtime. This allows you to turn features on and off in much the same way as the !modules and !set commands used to do. Those modules are being phased out in favour of plugin based solutions.
As well as offering improved functionality the new code should be much more efficient in terms of memory usage as it previously duplicated quite a lot of data between a few different hashes.
!plugins - List all installed plugins. Green plugins are loaded, red plugins are not loaded and orange plugins have halted due to an error, or failed to load in the first place.
!plugin_load <name> - Loads the named plugin
!plugin_unload <name> - Unloads the named plugin
BRenBot will additionally remember which plugins are loaded and unloaded and on startup will only load those which were previously loaded the last time it was run. By default it will not load new plugins until it is told to do so.
Caveat: Due to the way Perl loads modules it is not possible to load a plugin a second time if it failed to load due to a syntax or other compilation error. This is because the module was partially loaded, but not to the point were the unloading mechanism can clear out the cached data, preventing !plugin_load from getting a fresh copy.
Notes for plugin developers
BRenBot now required that plugins return 1 from their start function to indicate that they have loaded successfully. Returning 0 or nothing tells BRenBot that you have failed to load and it will immediately unload the plugin and mark it as being in error.
You might want to return 0 if the version of BRenBot is too old to support the plugin. Examples of this can be found in the plugins mentioned at the top of this post.
There is also an additional, optional, function you may wish to implement which is called when BRenBot is about to unload your plugin. Since plugins can be unloaded it is important that your shutdown function tidies up any open file handles and whatnot in case your plugin is loaded again in future to avoid file permission problems or dangling handles.
There are now many more plugin API commands available for use in your plugins, which can be found in the plugins.pm source in the API. Additionally the regex hooks system used with renlog and gamelog has been extended to support ssgmlog.
Please report any bugs you might find or submit feature requests on the BRenBot Trello page at https://trello.com/b/dlqadUmV by commenting on the cards under "BRenBot 1.53.19".
Thanks to Ethenal for contributing some bug fixes to the BRenBot SVN.
There's probably a few more things that I'll add to this later, but for now it's a good starting point
[Updated on: Thu, 06 February 2014 08:01]