Futurism › object › bot.modules
From Botdom Documentation
The bot.modules object manages the bot modules, and holds various methods to manipulate them.
Contents |
Properties
- str bot.modules.dir — An absolute path to the modules folder, based on gate.path.
- dict bot.modules.list — (Ironically) a dictionary with each bot module loaded as key and the absolute path to the module file as value.
- bool bot.modules.on — Whether bot modules and module management is turned on. This is only off during launch and module reloading.
- dict bot.modules.settings — A dictionary that can hold settings for each module with the module name as key and each module's settings dict as value. The bot internally uses the settings keyword "on" as a bool to indicate whether the user has turned off (on=False) a specific module.
Methods
bool bot.modules.activate()
Attempts to activate all modules listed in bot.modules.list, and inits each module class into an object instance in the bot.module dict. Changes bot.modules.on to True, to indicate that all modules has been attempted started. Always returns this value; True.
bool bot.modules.find()
Searches the module folder (bot.modules.dir) for modules and adds them to bot.modules.list. Returns True on success, False if there are already modules loaded.
bool bot.modules.load()
Finds and activates modules, by calling the bot.modules.find and bot.modules.activate methods. Returns True on success, False if there are already modules loaded.
void bot.modules.reload()
Reloads all modules by turning modules off, resetting the bot.module, bot.commands and bot.modules.list dicts and then loading modules again.
void bot.modules.trigger(str trig[, *args])
Triggers the event with the event code in trig, and executes eventual handlers in all modules, with eventual arguments in the args list as arguments to these events. If triggering default events, this method should only be called internally and not by modules, as it can spoof these events. However, if you want to create your own new event, like recv_note for a note plugin, you can just run this method and trigger for this event code. Any other modules that have handlers for this event will have these handlers executed. Simple!
void bot.modules.turn(str modulename, bool on)
Turns the module specified with modulename on or off, depending on the on parameter, and saves it in bot.modules.settings, so the module stays on/off until the user reverts it, even after bot restarts.

