To work, Apibot needs a wiki login, and optionally bot settings.
In practically all wikis, good manners (and quite often rules) require a bot to operate through an account. Anonymous bot usage is usually prohibited. For this reason, Apibot will require a login to a wiki account to be able to work.
A wiki login is a PHP array variable with three mandatory fields, and possibly others. For example:
$my_bot_login = array ( 'user' => "My Great Bot", 'password' => "1234mybotpassword5678", 'wiki' => $Wikipedia_EN, );
The 'user' and 'password' values are strings. The 'wiki' value is a wiki description variable (see below).
The 'wiki' value does not need to be defined as a separate variable - you can insert the wiki description right there. However, if you use more than one account for your bot at this wiki, defining the wiki desc as a variable might avoid unnecessary redundancy.
Often a bot will be used on multiple wikis. Sometimes a bot will perform several different tasks on the same wiki, and in some cases the wiki rules will require it to use different accounts for the different tasks. In such cases, the bot operator will need to define several different login variables. Usually (but not mandatory), they are defined as values in an array, typically named
$logins = array ( 'MeAtWEN' => array ( 'user' => "Joe Editor", 'password' => "pwdofjoeeditor", 'wiki' => $Wikipedia_EN, ), 'MyBotAtWEN' => array ( 'user' => "Joe's Bot", 'password' => "pwdofjoesbot", 'wiki' => $Wikipedia_EN, ) 'MyBotAtWDE' => array ( 'user' => "Joe's Bot", 'password' => "pwdofjoesbot", 'wiki' => $Wikipedia_DE, ) );
As we saw, a wiki login needs a wiki description. It is a PHP array variable with the following structure:
$Wikipedia_EN = array ( 'name' => 'en', 'urls' => array ( 'api' => "http://en.wikipedia.org/wiki/api.php", 'web' => "http://en.wikipedia.org/wiki/index.php", ), )
The 'name' value contains a name for this wiki that Apibot will use while referring to it, while caching data about it etc. For this reason, this field is mandatory.
The 'urls' array values are the URLs Apibot needs to know in order to contact the wiki. The 'api' url is used to exchange info with the MediaWiki API (bot) interface, and the 'web' url is used to exchange info with the MediaWiki Web (human) interface. (Apibot can work through different interfaces - potentially even with different wiki softwares.)
The wiki description may contain also other fields, for example for bot settings (see below).
Often a bot will be used on different wikis, thus needing more than one wiki description variables. Usually (but not mandatory), they are defined as values in an array, typically named
$wikis = array ( 'en' => array ( 'name' => 'en', 'urls' => array ( 'api' => "http://en.wikipedia.org/wiki/api.php", 'web' => "http://en.wikipedia.org/wiki/index.php", ), 'de' => array ( 'name' => 'en', 'urls' => array ( 'api' => "http://de.wikipedia.org/wiki/api.php", 'web' => "http://de.wikipedia.org/wiki/index.php", ), ), )
The work of Apibot can be tuned to a large degree through giving its parameters some settings. These are PHP arrays, gathered in a common settings array. None of them is mandatory - define only these you need.
$bot_settings = array ( 'environment' => array ( 'timezone' => "UTC", // Your time zone. You need it for the correct work of the bot. 'memory_limit' => "128M", // The max amount of RAM you would permit to the bot. // Should be enough for the tasks you give it. ), 'setparams' => array ( 'lax_mode' => false, // For those who enjoy tinkering and know very well what they do. ), 'paths' => array ( 'info' => dirname ( __FILE__ ) . "/data", // Cached info and identity files will be stored there. ), );
Settings values and sub-arrays can be included not only in the settings array, but also at wiki or login descriptions. Settings in wiki descriptions override these in a settings array. Settings in login descriptions override these in wiki descriptions. Thus you can conveniently have differing settings for different wikis and logins, while still having common values where it is convenient.