Settings

From Apibot
Revision as of 01:45, 10 November 2014 by Grigor Gatchev (talk | contribs) (Mains -> Core)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Apibot can be extensively configured at startup through its settings - a PHP array with the structure described below. This array is typically defined in a file called settings.php, included by your bot script.

Settings can also be defined in the Apibot wiki and login structures. Settings in a wiki description structure have higher priority than the common settings. Settings in a login structure have higher priority than settings in a wiki description structure. This way, you can override some settings for the wikis and/or accounts who need this.

Global settings

# The bot PHP environment settings
'environment' => array (
  'timezone' => "UTC",      // the bot PC timezone (any supported by PHP)
  'memory_limit' => "512M", // don't use more memory (in format supported by PHP)
),

# Exchange parameters handling
'setparams' => array (
  'lax_mode' => false,  // true - will set any parameters, false - will check the wiki-supplied or deduced paramdesc
),

# Miscellaneous paths
'paths' => array (
  'info' => dirname ( __FILE__ ) . "/data",  // the fetched wiki and account info will be cached here
),

Settings for the Core modules

# Settings for the Browser module
'browser' => array (
  'agent'        => "Mozilla/5.0 (Apibot Browser)",  // User-Agent
  'http_version' => "HTTP/1.1",  // Report this version
  'http_user'    => NULL,  // HTTP (not MediaWiki!) authentication user (if any)
  'http_pass'    => NULL,  // HTTP authentication password
  'conn_timeout' => 120,   // Connection timeout
  'max_get_len'  => 2048,  // If a GET string will exceed this length, use POST instead
  'content_type' => array (  // Use these types. (Currently all GETs are considered text, and all POSTs binary.)
    'text'   => "application/x-www-form-urlencoded",
    'binary' => "multipart/form-data",
  ),
  'mime_boundary'   => "Apibot-Browser-$1", // for multipart/form-data ($1 is replaced by a random string)
  'use_compression' => true,  // Compress transfered data where possible
  'speed_limits'    => array (  // Transfer speed (average) limits
    'total' => PHP_INT_MAX,  // Both upload and download
    'DL'    => PHP_INT_MAX,  // Download only
    'UL'    => PHP_INT_MAX,  // Upload only
  ),
  'dump_level'      => 0,  // Dump to stdout transferred data: 0 - none, 1 - all data
),

# Settings for the Exchanger modules (API and Web)
'exchanger' => array (
  'settings' => array (  // The modules settings
    'api' => array (  // The API exchanger settings
      'max_retries' => 5, // may be overridden in the wiki description (see logins.php)
      'retry_wait' => 1,  // may be overridden in the wiki description (see logins.php)
    ),
    'web' => array (  // The Web exchanger settings
    ),
    'dump_level' => 0,  // Dump to stdout exchanged data: 0 - none, 1 - all data
  ),
  'defaults' => array (  // The modules default parameters
    'api' => array (     // ... for the API module
      'format'  => "php", // from v0.40.5 supports also and uses as default "json"
      'maxlag'  => 5,
      'smaxage' => NULL,
      'maxage'  => NULL,
    ),
  ),
),

# Settings for the Identity module
'identity' => array (
  'always_login'   => false,  // true - always login, false - use cookies where available
  'login_attempts' => 5,   // try to login up to that many times before giving up
),

# Settings for the Info module
'info' => array (  // how often to re-fetch the inof
  'general' => array (  // general info settings
    'fetch' => "always",  // always, never, if_unknown, if_older_than ('days'), on_newversion, on_newrevision
    'save'  => true,  // whether to cache it or not for later usage
  ),
  'site' => array (  // siteinfo settings
    'fetch' => "on_newrevision",
    'save'  => true,
  ),
  'param' => array (  // paraminfo settings
    'fetch' => "on_newrevision",
    'save'  => true,
  ),
  'user' => array (  // userinfo settings
    'fetch' => "on_newrevision",
    'save'  => true,
  ),
  'allmessages' => array (  // allmessages info settings
    'fetch' => "on_newrevision",
    'save'  => true,
  ),
  'globaluser' => array (  // globaluser info settings
    'fetch' => "on_newrevision",
    'save'  => true,
  ),
),

# Settings for the Log module
'log' => array (
  'loglevel' => LL_DEBUG,  // LL_PANIC, LL_ERROR, LL_WARNING, LL_INFO, LL_DEBUG - log from least to most
  'logfile'  => "test.log",  // log filename
  'echo_log' => true,   // echo log to the stdout too?
  'html_log' => false,  // log messages as HTML?
  'levelprefs' => array (  // mark the loglines with these characters according to the line loglevel
    LL_PANIC   => '!',
    LL_ERROR   => '#',
    LL_WARNING => '=',
    LL_INFO    => '+',
    LL_DEBUG   => '-'
  ),
),

Settings for the Actions modules

These are the settings for the Actions modules - the "second tier" in the Apibot structure.

(The first tier are the API modules, who overlay the direct API communication only with checks on the parameters validity. The second tier are the Actions modules, who add default values for the parameters and tokens support / auto-set. The third tier is the Tasks, who utilize different backends, API and Web. When it comes to queries, there is a "second and a half" intermediate tier, called Queries, who parses data into an uniform elements array.)

The settings can be defined in several levels:

  • array ( modulename => array ( type => array ( backend => array (...) ) ) )
  • array ( modulename => array ( type => array (...) ) ) (lower priority)
  • array ( type => array (...) ) (lowest priority)

The modulenames are the names of the Action modules (who match the API modules). The types are 'defaults' (default params) and 'settings' (default settings). The backends are 'api' and 'web' (data in them is specific for this backend only).

'actions' => array (
  'block' => array (
    'defaults' => array (
      'anononly'  => true,
      'nocreate'  => true,
      'autoblock' => true,
      'noemail'   => true,
      'expiry'    => "never",
      'reason'    => NULL,
    ),
  ),
  'delete' => array (
    'defaults' => array (
      'watch'  => NULL,
      'reason' => NULL,
    ),
  ),
  'edit' => array (
    'defaults' => array (
      'text'         => NULL,
      'prependtext'  => NULL,
      'appendtext'   => NULL,
      'section'      => NULL,
      'sectiontitle' => NULL,
      'undo'         => NULL,
      'undoafter'    => NULL,
      'is_minor'     => true,
      'is_bot'       => true,
      'add_md5'      => true,
      'recreate'     => NULL,
      'createonly'   => NULL,
      'nocreate'     => NULL,
      'redirect'     => false,
      'watchlist'    => NULL,
      'summary'      => NULL,
    ),
  ),
  'emailuser' => array (
    'defaults' => array (
      'user'    => NULL,
      'text'    => NULL,
      'subject' => NULL,
      'ccme'    => false,
    ),
  ),
  'expandtemplates' => array (
    'defaults' => array (
      'text'  => NULL,
      'title' => NULL,
    ),
  ),
  'help' => array (
  ),
  'import' => array (
    'defaults' => array (
      'interwikisource' => NULL,
      'templates'       => false,
      'fullhistory'     => NULL,
      'namespace'       => NULL,
      'summary'         => NULL,
    ),
  ),
  'login' => array (
  ),
  'logout' => array (
  ),
  'move' => array (
    'defaults' => array (
      'movetalk'     => true,
      'movesubpages' => true,
      'noredirect'   => NULL,
      'watch'        => NULL,
      'reason'       => NULL,
    ),
  ),
  'paraminfo' => array (
  ),
  'parse' => array (
    'defaults' => array (
      'text'    => NULL,
      'title'   => NULL,
      'prop'    => NULL,
      'pst'     => NULL,
      'uselang' => NULL,
    ),
  ),
  'patrol' => array (
  ),
  'protect' => array (
    'defaults' => array (
      'protections' => array (
        'edit'  => "sysop",
        'move'  => "sysop",
      ),
      'expiry'  => array (  // for the protections above, for each level
        "never",  // edit
        "never",  // move
      ),
      'cascade' => true,
      'reason'  => NULL,
    ),
  ),
  'purge' => array (
  ),
  'query' => array (
    'defaults' => array (
      'redirect'      => NULL,
      'indexpageids'  => false,
      'export'        => false,
      'exportnowrap'  => false,
      'converttitles' => false,
      'iwurl'         => false,
    ),
  ),
  'rollback' => array (
    'defaults' => array (
      'title'   => NULL,
      'user'    => NULL,
      'summary' => NULL,
      'markbot' => true,
    ),
  ),
  'unblock' => array (
    'defaults' => array (
      'reason' => NULL,
    ),
  ),
  'undelete' => array (
    'defaults' => array (
      'title'  => NULL,
      'reason' => NULL,
    ),
  ),
  'upload' => array (
    'defaults' => array (
      'comment' => NULL,
      'text'           => NULL,
      'watch'          => NULL,
      'ignorewarnings' => false,
    ),
  ),
  'userrights' => array (
    'defaults' => array (
      'add'    => NULL,
      'remove' => NULL,
      'reason' => NULL,
    ),
  ),
  'watch' => array (
    'defaults' => array (
      'unwatch' => NULL,
    ),
  ),
),

# Settings for the general tasks modules.
'tasks' => array (
  'backends' => array ( "api", "web" ),  // which backends to use and in what order
  'fetch_editable' => array (
    'fetch_objects' => true,  // default - true
  ),
  'fetch_title' => array (
  ),
),