Build a bot

Evil_Robots
Photo credit: Terminator 3 producers.

AndrewForson wrote:

Perhaps a kind person would publish a pointer to some build-your-own-bot code?


This guide will explain how to make a basic reprogrammable python bot similar to DysklyerBot, which has made over a million edits.

Basic bot with Python

Prerequisites:

  • A brain, eyes, and fingers.
  • The ability to read and count to ten.
  • A machine running Linux, preferably Ubuntu.
  • The ability to install Python.
  •  Knowledge of how to access the command line.

Start with creating an account on the wiki that needs your super helpful automated edits. Take note of the username and password.

Find the command line of your machine, you will be doing everything on the command line, therefore no GUI interface is needed. You can thus simply use a cloud machine if you don’t have linux on your local computer. It is possible to install this bot on Windows, but that is not detailed in this guide.

From this point the instructions are basically following the Pywikibot Installation Manual.

  • Install or upgrade Python to be version 2.7.4 or higher, or version 3.4 or higher.
  • Run $ pip install requests to install the pip package called “requests”
  • Download http://tools.wmflabs.org/pywikibot/core.tar.gz (this can be done with the “wget” command, e.g. $ wget http://tools.wmflabs.org/pywikibot/core.tar.gz
  • Unzip the package with $ tar -xzf core.tar.gz
  • Change directory with $ cd core/
  • Type $ python pwb.py generate_user_files and follow the instructions that the program generates.
  • Don’t set a bot password unless you have bot permissions.

 

You should now have a working bot, capable of editing any wiki at immense speeds.

This is a list of scripts which are included in your new bot, you can use them as instructed, for example:

$ python pwb.py cosmetic_changes.py -ns:0 -start:! -pt:31 -maxlag:10

Will make standard cosmetic changes to the markup of all mainspace pages on the wiki, starting alphabetically, making one edit every 31 seconds so as not to show up on the botwatch monitor. Or;

$ python pwb.py add_text -ns:0 -start:! -text:"Crizur crusing" -pt:0 -maxlag:5

To add the text “Crizur crusing” to every article on the wiki as fast as possible. Or;

$ python pwb.py add_text -ns:2 -start:! -regex "admin" "sysop" -pt:10 -maxlag:5

To change all mentions of “admin” to “sysop” in the talk namespace, making one edit every ten seconds.

The bot does not need a bot password, will work without a bot flag, and does not need any special user groups.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.