NetHackWiki:WikiBot

From NetHackWiki
Jump to: navigation, search

Bots on NetHackWiki

A wikiBot is a set of small programs (scripts) that automate wiki editing tasks. You should use a bot if you have a large number of edits that you need to perform. The bot takes care of repetitive and mundane tasks so you don't have to. Writing bot scripts requires good programming skills, but operating a bot is relativly easy.

On NetHackWiki anyone can run a bot. However, you must notify us on the [Community Forum] before doing so. It's considered good manners to run the bot from its own user account, usually <yourname>Bot.

Bot Setup

NetHackWiki uses MediaWiki, the same software that runs wikipedia. Therefore the pywikipedia bot can be used on NetHackWiki. 'pywikipedia' is written in the Python scripting language. If you are not familiar with Python, Dive Into Python provides a quick introduction along with links to ActiveState where you can download a free turn-key install package for most platforms.

NetHackWiki Setup

  1. Create the bot account.
    1. Use <YourName>Bot as the username.
    2. Write down the password.
  2. Ensure the display skin is set to Monobook (default skin).
  3. Log out you bot account.

Downloading pywikipedia

The pywikipedia bot does not have a turn-key install. It has to be downloaded and configured. The best way to get the latest release is via CVS. Once you have acquired the bot you'll need to configure it before it will run on NetHackWiki.

  1. Download and install Python. ActiveState has a good package
  2. Download and install CVS. TortoiseCVS is a good package for MS Windows.
    1. Read TortoiseCVS User's Guide - Chapter 2. Checking out a Module
    2. Checkout pywikipedia. Refer to CVS Connection Parameters below.
    3. or paste into CVSROOT field :pserver:anonymous@pywikipediabot.cvs.sourceforge.net:/cvsroot/pywikipediabot
CVS Connection Parameters
Protocol pserver
Server pywikipediabot.cvs.sourceforge.net
CVS Root (Repository Folder) /cvsroot/pywikipediabot
User anonymous
Password (leave empty, anonymous doesn't have any passwords)
CVS Module pywikipedia

Configuring pywikipedia

Because NetHackWiki is not Wikipedia, the bot needs some additional code to work properly. Wikipedia has information on workarounds for non-wikipedia wikis. Basically we'll need to add a 'families' definition for NetHackWiki before attempting to login.

  1. Check if <bot root>\families\wikihack_family.py exists.
    1. If it does not, add wikihack_family.py (see below) to the families directory.
  2. Create <bot root>\user-config.py (see below)

Logging in pywikipedia

We start by giving the bot login access to the wiki. This is a one time procedure. Once logged in the bot will store the username and password in a cookie for future use. To cache a different user/pass combination delete the XX-login.data file that is created in the login-data subdirectory.

  1. Run command line python login.py -pass:XXXX

pywikipedia: Upload

  • Run command line python upload.py -log -keep <filename> "<description>"

user-config.py

mylang = 'en'
family = 'wikihack'
usernames['wikihack']['en'] = 'ExampleBot'

wikihack_family.py

# -*- coding: utf-8  -*-
import family
    
# The wikiHack family - a wiki about the game NetHack.
# v1.0 - July 30, 2006. Bernard Martis 

class Family(family.Family):
    def __init__(self):
        family.Family.__init__(self)
        self.name = 'wikihack'          # family name, same as filename
        self.langs = {
            'en': 'nethackwiki.com',  # NetHackWiki hostname
        }

        self.mainpages = {
            'en': u'Main Page'
        }
        
        # namespace not specified will be set to MediaWiki defaults
        
        # Project namespace. All languages use the same project namespace name.
        self.namespaces[4] = {
            '_default': u'NetHackWiki', 
        }                               

        # Project talk namespace.
        self.namespaces[5] = {
            '_default': u'NetHackWiki talk',
        }

        # A few selected big languages for things that we do not want to loop over
        # all languages. This is only needed by the titletranslate.py module, so
        # if you carefully avoid the options, you could get away without these
        # for another wiki family.
        self.biglangs = ['en']

    # MediaWiki version used. Current as of Sun, 30-Jul, 06
    def version(self, code):
        return "1.5"                  

    # The path of index.php
    def path(self, code):
        return '/index.php'             

    # hostname. The same for all languages
    def hostname(self, code):
        return 'nethackwiki.com'