Manual:Wikibot
|
|
WikiBot is deprecated. If you are creating a new PHP bot, use Peachy (currently being re-written) instead. |
|
Release status: experimental |
|
|---|---|
| Implementation | Bot |
| Description | Configurable bot framework |
| Author(s) | Cobi, Tisane |
| Last Version | 1.0.0 |
| MediaWiki | 1.16+ |
| Language | PHP |
| License | GPL |
| Download | Subversion [Help] |
- Not to be confused with Manual:IRC RC Bot
Wikibot is a PHP-based MediaWiki bot framework. It is based upon w:User:ClueBot/Source, but is designed to be more configurable and flexible. Make sure that the appropriate subpage of the bot's userpage, e.g. User:MyBot/Run, exists, or some bots may not work.
[edit] Configuration
The bot can be configured using the file wikibot.config.php. For instance, if you want to configure a bot username of TestBot, a bot password of password, and to have it edit testwiki.org, you might put the following configuration settings in wikibot.config.php:
$wikibotSetting['user']['TestBot']['Testwiki'] = 'TestBot'; # Username $wikibotSetting['pass']['TestBot']['Testwiki'] = 'password'; # Password $wikibotSetting['apiurl']['*']['Testwiki'] = 'http://testwiki.org/w/api.php'; $wikibotSetting['queryurl']['*']['Testwiki'] = 'http://testwiki.org/w/query.php'; $wikibotSetting['indexurl']['*']['Testwiki'] = 'http://testwiki.org/w/index.php';
- The first bracket contains the name of the configuration setting.
- The second bracket contains the name of the bot or the wildcard "*" to apply the setting to all bots.
- The third bracket contains the wiki name or the wildcard "*" to apply the setting to all wikis.
If there is any conflict between a wildcarded setting and a more specific setting, the more specific setting will prevail. For example, suppose you have the following:
$wikibotSetting['user']['*']['*'] = 'AwesomeBot'; $wikibotSetting['user']['TestBot']['Testwiki'] = 'TestBot';
In this example, the TestBot setting would override the less specific AwesomeBot setting for purposes of commands such as this:
$user = getWikibotSetting( 'user', 'TestBot', 'Testwiki' );
[edit] Sample bot
Here is a sample bot that uses this framework to edit the page "Sandbox" on testwiki.org:
<?php # This bot logs in to testwiki.org and edits the sandbox to say "Hello world!" error_reporting( E_ALL | E_STRICT ); include 'wikibot.classes.php'; /* The wikipedia classes. */ $bot = 'TestBot'; $wiki = 'Testwiki'; $wpapi = new wikipediaapi ( '', '', '', $bot, $wiki, true ); $wpq = new wikipediaquery ( '', '', '', $bot, $wiki, true ); $wpi = new wikipediaindex ( '', '', '', $bot, $wiki, true ); $user = getWikibotSetting( 'user', $bot, $wiki ); $pass = getWikibotSetting( 'pass', $bot, $wiki ); if ( $wpapi->login( $user, $pass ) != 'true' ) { echo "Login failure"; die(); } sleep( 1 ); var_dump( $wpapi->edit( 'Sandbox', 'Hello world!', 'This is a test', false, false, null, null, false ) );
[edit] See also
- w:User:ClueBot/Source — The ClueBot source, upon which this framework is based
- Manual:Wikibot/RPEDIRCBot
- Manual:Wikibot/UploadBot