User:Wesley/Bot guide

From JoCopedia
Jump to navigation Jump to search

This page describes how to use PyWikipediaBot to run a robot on JoCopedia. Find the full instructions on the PyWikipediaBot page on Meta.


You'll need for Python to be running on the computer you wish to run your robot from. This is not a problem if you're running Mac OS X or Linux: just open up Terminal and get going.

If you're using Windows, you're more-or-less on your own. Having said that, you can try running an Ubuntu LiveCD and do all your botting from there. Otherwise, consider downloading a free VMware appliance of Ubuntu and the free VMware player so that you can run Ubuntu in a little window from inside Windows.

Preparing for use[edit]

Download a copy of PyWikipediaBot and unzip it. Next, you'll need to create two files.

Family file[edit]

Before you can use PyWikipediaBot with JoCopedia, we have to teach PyWikipediaBot to talk to the JoCopedia servers. We teach that by using a family file.

Copy the following code into a text editor. (If you're using Ubuntu, use the Applications → Accessories → Text Editor. If you're using Mac OS X, use Textedit, but be sure to change your format to plain text!) Save this file as in the "families" subfolder inside the "pywikipedia" folder.

# -*- coding: utf-8  -*-
import config, family, urllib

class Family(family.Family):
    def __init__(self):
        family.Family.__init__(self) = 'jocopedia'

        self.langs = {
            'en': '',

        self.namespaces[4] = {
            '_default': [u'JoCopedia', self.namespaces[4]['_default']],
        self.namespaces[5] = {
            '_default': [u'JoCopedia talk', self.namespaces[5]['_default']],

        self.namespaces[100] = {'en': u'WikiProject',}
        self.namespaces[101] = {'en': u'WikiProject talk',}
        self.namespaces[102] = {'en': u'TDiJC'}
        self.namespaces[103] = {'en': u'TDiJC talk'}
        self.namespaces[104] = {'en': u'SotD'}
        self.namespaces[105] = {'en': u'SotD talk'}

    def scriptpath(self, code):
        """The prefix used to locate scripts on this wiki.

        This is the value displayed when you enter {{SCRIPTPATH}} on a
        wiki page (often displayed at [[Help:Variables]] if the wiki has
        copied the master help page correctly).

        The default value is the one used on Wikimedia Foundation wikis,
        but needs to be overridden in the family file for any wiki that
        uses a different value.

        return '/wiki'

    # Which version of MediaWiki is used?
    def version(self, code):
        # Replace with the actual version being run on your wiki
        return '1.12.0rc1'

User configuration file[edit]

Next, we actually configure PyWikipediaBot to be your specific bot. In this section, we configure to bot to talk to JoCopedia with the name you gave your bot.

Haven't given your bot a name yet? Sign up for an account on JoCopedia now! Usually, it's a good idea to name your bot in a way that people instantly know the bot's owner. My name is Wesley, so I named my bot WesBot. Other names, like WesleyBot and WesleyCleanupBot would work too. Names like BunnyBot are probably not the best idea.

Copy the following code into a text editor. Change WesBot to the account name you just signed up for. Then, save the file as "" in the "pywikipedia" folder.

mylang = 'en'
family = 'jocopedia'
usernames['jocopedia']['en'] = u'WesBot'

Logging in[edit]

Now that you've set up your bot, it's time to test it by logging in. Open up Terminal and use the cd command to get to the pywikipedia folder. If you unzipped the "pywikipedia" folder to your desktop, the command should be something like this:

cd Desktop/pywikipedia

Once you're there, log in by typing this:


If everything is working, then you will be asked for your password, and then a message will inform you that you're "probably logged in". Don't worry: if you see that message, then you are definitely logged in and can start using your new bot! If something doesn't work out, though, check your steps, then leave a message on Wesley's talk page and he'll try to sort things out for you.

Getting started[edit]

Usually, you will only mostly need the built-in scripts to make your bot do things. For some examples, see User:Wesley/Bot guide/Examples. The list of scripts you can use is available at Meta.

To run a script (say,, type this:

python stuff

To find out how to use a script, use the link to Meta above, or type this:

python -help

That works for all the scripts listed at Meta.


Examples are available at User:Wesley/Bot guide/Examples.