Info object

From Apibot
Revision as of 20:02, 22 April 2013 by Grigor Gatchev (talk | contribs) (some start (will continue it later))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A MediaWiki installation is able to supply an enormous wealth of info that can be useful for bot tasks. Apibot is able to request this info and supply it to the programs that use it. To decrease the wiki online traffic, the requested info is cached and reused according to specified settings. All this is done by the Info object, which is part of the Apibot Mains object.

This class exports over 500 functions that return wiki and user info, as well as some useful conversions and tasks that rely on this info - more than any other part of Apibot. If the bot doesn't know the information returned by the function you called, it will try to auto-fetch and possibly cache it.

Types of info

Apibot divides the information from the wiki into several types:

  • general - common things about the wiki; matches the General subtype of the MediaWiki Meta Siteinfo.
  • siteinfo - all other MediaWiki Meta Siteinfo
  • userinfo - the MediaWiki Meta Userinfo
  • allmessages - the MediaWiki Meta Allmessages
  • paraminfo - the MediaWiki Paraminfo

Info classes

The Info class is actually the last descendant in a class hierarchy:

  • Info_Fetcher - fetches the info; also, exports functions that return the general info
  • Base_Info - extends Info_Fetcher; exports functions that return the siteinfo, userinfo, allmessages and paraminfo
  • Extended_Info - extends Base_Info; exports functions that are convenient shortcuts for some frequently used specific function calls, and functions that provide useful stuff relying on the wiki info
  • Info - extends Extended_Info; by default implements no new functions - it is a place for the bot user's custom functions, should s/he implement some. The Info object in the Apibot Mains object is of this class.

All of these classes are implemented in PHP files with matching names, situated in the directory common/info.