Manual:Chris G's botclasses

From MediaWiki.org
Jump to: navigation, search

Chris G's botclasses compose a PHP MediaWiki bot framework hosted at the toolserver. They are derived from the wikibot.classes used by ClueBot. To use this framework, it is necessary to download botclasses.php and all its dependencies (viz. http.php, lyricswiki.php, and mediawiki.php) from https://github.com/Inclumedia/Chris-G-botclasses.git Or use git clone https://github.com/Inclumedia/Chris-G-botclasses.git

Bots[edit]

HelloWorldBot.php[edit]

<?php
/*
 * HelloWorldBot.php
 * This bot edits Wikipedia:Sandbox.
/*

/* Setup my classes. */
include( 'botclasses.php' );
$wiki      = new wikipedia;
$wiki->url = "http://en.wikipedia.org/w/api.php";
$wiki->setUserAgent( 'User-Agent: FooBot (http://mediawiki.org/wiki/User:FooBot)' );
 
/* All the login stuff. */
$user = 'REMOVED';
$pass = 'REMOVED';
$wiki->login( $user, $pass );
 
/* Test edit. */
$page = 'Wikipedia:Sandbox';
$content = 'Hello, world!';
$summary = 'This is a sample bot edit.';
$wiki->edit( $page, $content, $summary );

Other bots[edit]