From Support Wiki
Jump to navigation Jump to search

PyWikiBot, or PWB, is one of the common bots available to users. This article will serve as a comprehensive guide for how to set up and run PyWikiBot on wikis for Windows-based operating systems.

First-time setup

  1. Download Python on your computer. You should probably get the latest version, but any 3.x version later than 3.7 will work (so at least 3.8). From the download links, using one labelled as an "installer" will make things easier. After it's downloaded, install Python by running that file.
  2. Download PyWikiBot and extract the contents somewhere (I put mine in C:\Users\username\PWB, but anywhere is fine as long as you can use cd to get to it, as in step 3.1). This folder will be referred to as your main PyWikiBot folder.
  3. Open a command prompt at the install location. Make sure this is done AFTER installing Python.
  4. Type python -m pip install requests and press enter.
  5. Type python -m pip install mwparserfromhell and press enter.
  6. Type python and follow the instructions.
  7. Type python and follow the instructions. Note: You may do this step many times if you edit many wikis.

Now we'll pause for a sec and make a bot password.

Creating a bot password

  1. Go to Special:BotPasswords on any wiki. Type a name for this password into the box (recommended to use "PWB") and hit Create. Here you will see a list of permissions. Most bots will only need "High-volume editing", "Edit existing pages", and "Create, edit, and move pages". Check these and others if you need them, and hit the Create button at the bottom of the page. The password here is only used for logging into your bot via external programs—when logging in through the browser, use its normal password.

Configuring your bot password

Open in your favorite text editor and paste your bot info in. It'll look something like this:

("RheingoldRiver", BotPassword("PWBBot", "REDACTED"))

Note, you may eventually have more than one account here, a "you" account if you want the changes showing up in recent changes, and a "bot" account if you don't. In that case, you might have something like this:

("RiverIsABot", BotPassword("PWB", "REDACTED"))
("RheingoldRiver", BotPassword("PWB", "REDACTED"))

Logging in

After saving all the files in the previous steps, you should be ready to log your bot in for the first time. Return to command prompt and cd to your main PyWikiBot folder and type in python login. If everything was done correctly, you should successfully log in and be ready to start running scripts.

Possible issues and solutions
  • "can't open file No such file or directory." - You cd-ed to the wrong place in command prompt. Check your path.
  • "Login failed (Aborted)" followed by a password prompt - Your file is either incorrect or improperly formatted. Refer to the examples and check your password. If you closed the browser window that showed your password, you may need to return to Special:Botpasswords and reset it if you didn't record it elsewhere.

Using Pywikibot

Open command prompt (you may need to do so in administrator mode) and cd to your main PyWikiBot directory. You can run a script by typing py scriptname followed by any relevant arguments for that script, which can be seen by typing py scriptname -help.

An example script command, py redirect double -always will resolve all double redirects on a wiki, not asking for confirmation each time.

To view all the scripts available, find the "scripts" folder in your main PyWikiBot folder.

Using PyWikiBot on multiple wikis and languages

During the setup, we set one wiki and language code as your defaults. Whenever you run scripts, PyWikiBot will attempt to use these unless you tell it otherwise.

To add a new wiki, create a new family file for the new wiki. If the wiki is in the same family but a different language than one of your existing families, you can add it to that family file instead.

When using scripts, add the wiki family, language, and username as command line arguments if any of them differ from the default. For example, say our default wiki is Ark in English using the account MrBot5, our command of py redirect double would automatically use all of these. But say I want to run the same script on Astroneer in Spanish using the account SenorBot5. Assuming I already set up an astroneer family file, updated my to include this family file and account name, and added SenorBot5's password to, my command would be py redirect double -family:astroneer -lang:es -user:SenorBot5. But if I want to just do Astroneer in English (my default), using MrBot5 (also my default), then I can just do py redirect double -family:astroneer.

Additional help

If you got stuck at some point during this guide and are trying to edit a wiki, please ask in the Discord server!


How do I make PWB not pause for 10s between pages?

Add -pt:0 as an argument to your command. It can go in any order. pt stands for "put_throttle." You can also add put_throttle=0 in your file.

I can't delete pages. What's going on?

There's a couple things that could be going on.
  • Make sure your account actually has sysop privileges.
  • Make sure you gave your bot password delete permissions.
  • Are you using sysopname for this wiki in your user_config? Remember, you can have as many usernames as you want for a wiki, but only one sysopname! (The variable is still called "sysopnames" with an S at the end, though.

I was moving some pages and the console suddenly just exploded into an error message. What happened?

You hit the rate limit. Normal bots have a higher rate limit than normal users, but they still have one, and it's pretty low for moving pages. If you have an admin account, set that up as a sysop account and use it to move pages without rate limit.

See also