JavaMediawikiBot (JMB) is a bot designed to interface with MediaWiki (MW). It communicates with MediaWiki through the web API. JMB also optionally parses MW pages into its various core components.
To set up JavaMediawikiBot for an IDE, run
./gradlew eclipse or
Making a Wiki Family
A wiki family is a group of wikis that a bot knows about, and hence can edit. It also stores wiki specific information.
To make a new wiki family, simply run
This can be done via your IDE (console required), or through the command line:
./gradlew run -Pmain=WikiBot.MediawikiData.FamilyGenerator -q
Making a Bot
To create a Mediawiki bot, create a Java class. It will need to extend either one of these two classes:
- Extending this class gives access to a plethora of methods for interfacing with Mediawiki.
- Extending this class gives access to GenericBot's methods, plus a GUI for better control of the bot's edit flow. Please note, the bot's main method will have to instantiate itself for the GUI to appear. See
InterwikiBot.javafor an example.
When extending a class, the constructor must include either:
super(String family, String homeWikiLanguage)
super(File family, String homeWikiLanguage)
family specifies a wiki family file. A bot may then access the wikis in the family file. A String
family refers to a default included wiki family, and must be "Scratch", "DwarfFortress", or "Wikipedia". A File
family must point to a local wiki family file.
homeWikiLanguage specifies the default wiki of a bot.
Coding the bot.
JavaMediawikiBot offers two ways to accomplish what you want.
GenericBot methods are abstractions of the Mediawiki API, and are mostly for querying data.
APIcommand classes are also abstractions to the Mediawiki API, and are meant to be used as Objects. For example:
APIcommand command = new AppendText(loc, "\n[[de:Scratch Katze]]", "This page needs an interwiki. ^.^ "); proposeEdit(command); // Propose command for later review, requires GUI. APIcommand(command); // Push the command now.
Half of the API commands are recommended used raw, half are not. This can be checked in the command's class documentation. If not recommended used raw, use GenericBot methods instead.
One example bot is included in the project, and it is called
To contribute, make an issue or a pull request! In each Pull Request, make sure to include the situations under which your code was tested.
Useful bot methods and bot settings may be found in various places.
- For bot methods.
- For GUI methods.
- For logging + networking methods.