The preferences module aims to allow per-user control of output from the bot. Most notably logon spam.
A BeBot preference consists of five elements that are stored in the database.
In addition there is a table that links members to various settings and holds values for individual preferences.
The default option does not have to be one of the listed options, however it’s not very useful to have a default that cannot be chosen after another option has been set.
Maximum lenghts for the preferences are module: 30 name: 30 description: 255 default value: 25 possible values: 255
This stipulates that no preference can have an option that is more than 25 characters long!
Spaces are not allowed in module and setting names. Spaces will be replaced with an underscore.
$this -> bot -> core('prefs') -> function();
This function is used to create new preference. If the preference $name for $module already exists it doesn’t overwrite or change it in any way.
create($module, $name, $description, $default, $options);
create function parameters:
Return value: None
mixed get(string $player, [string $module[, string $pref_name]])
Used to retrieve the value of a setting.
If $pref_name is omitted all preferences for the given module is returned. If $module is omitted all preferences are returned.
Return value: Value of the preference(s).
change(string $name, string $module, string $setting, string $value)
This function should not need to be called by coders as preferences should be altered by the players using the interface.
Creating a preference for a module:
$this -> bot -> core('prefs') -> create('MyModule', 'MySetting', 'This describes the preference', 'Option1', 'Option1;Option2;Option3');
Checking a preference:
$setting = $this -> bot -> core('prefs') -> get ($name, 'MyModule', 'MySetting');