Difference between revisions of "Core object"

From Apibot
Jump to: navigation, search
m (+ see also section)
m (small omission)
 
(5 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
Nearly every script that uses Apibot will probably start with creating this object.
 
Nearly every script that uses Apibot will probably start with creating this object.
 +
 +
Before version 0.40.19 it was known as the Mains object.
  
 
==== Creation ====
 
==== Creation ====
Line 18: Line 20:
 
* <code>$infostore</code> - the object that stores in files and retrieves different info (wiki etc)
 
* <code>$infostore</code> - the object that stores in files and retrieves different info (wiki etc)
 
* <code>$settings</code> - the object that keeps and manages the bot global settings
 
* <code>$settings</code> - the object that keeps and manages the bot global settings
 +
* <code>$hooks</code> - the object that keeps and manages the Apibot internal calls hooks
 
* <code>$log</code> - the object that provides the bot logging facilities
 
* <code>$log</code> - the object that provides the bot logging facilities
 
* <code>$backends</code> - an array with objects that implement the Apibot backends
 
* <code>$backends</code> - an array with objects that implement the Apibot backends
 +
* <code>$account</code> -
  
 
==== Public methods ====
 
==== Public methods ====
  
* <code>login()</code> - logs the bot in the wiki, and (re-)creates the object properties
+
* <code>log ( $message, $loglevel = LL_INFO, $logpreface = "" )</code> - writes a message to the bot log
* <code>logout()</code> - unlogs the bot from the wiki
+
 
 +
* <code>version()</code> - returns the Apibot version (eg. 0.40.20)
 +
 
 +
* <code>backend ( $name )</code> - returns the [[Backend object]] with this name, or NULL if no such object exists
 +
* <code>available_backends_names()</code> - returns an array with the names of the available backends (both operable and non-operable)
 +
* <code>active_backends_names()</code> - returns an array with the names of the active (can be used on this type of wiki, but might be non-operable for some reason on this specific wiki) backends
 +
* <code>operable_backends_names()</code> - returns an array with the names of the operable (able to work on this wiki, maybe not for all possible tasks) backends
  
 
== See also ==
 
== See also ==
  
 
* [[Main Page]]
 
* [[Main Page]]

Latest revision as of 23:47, 22 June 2015

This object is the Apibot core. It provides all the functionality the bot interfaces and their objects give access to. It is required for creating nearly every Apibot interfaces or data object.

Nearly every script that uses Apibot will probably start with creating this object.

Before version 0.40.19 it was known as the Mains object.

Creation

Requires two parameters:

Public properties

Except for the $info property, best do not access the others - unless you know really well what you are doing.

  • $info - the object that exports methods providing info about the wiki, bot account etc. A very useful one.
  • $browser - the object that provides the HTTP(S) level exchange
  • $infostore - the object that stores in files and retrieves different info (wiki etc)
  • $settings - the object that keeps and manages the bot global settings
  • $hooks - the object that keeps and manages the Apibot internal calls hooks
  • $log - the object that provides the bot logging facilities
  • $backends - an array with objects that implement the Apibot backends
  • $account -

Public methods

  • log ( $message, $loglevel = LL_INFO, $logpreface = "" ) - writes a message to the bot log
  • version() - returns the Apibot version (eg. 0.40.20)
  • backend ( $name ) - returns the Backend object with this name, or NULL if no such object exists
  • available_backends_names() - returns an array with the names of the available backends (both operable and non-operable)
  • active_backends_names() - returns an array with the names of the active (can be used on this type of wiki, but might be non-operable for some reason on this specific wiki) backends
  • operable_backends_names() - returns an array with the names of the operable (able to work on this wiki, maybe not for all possible tasks) backends

See also