Difference between revisions of "NetHackWiki:WikiBot"

From NetHackWiki
Jump to navigation Jump to search
 
(NetHackWiki Setup: :type deafult ->default)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Bots on WikiHack ==
+
== 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.   
 
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 WikiHack 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.
+
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 ==
 
== Bot Setup ==
WikiHack uses [[MediaWiki]], the same software that runs [http://wikipedia.com/ wikipedia]. Therefore the [http://meta.wikimedia.org/wiki/Interwiki_bot/Getting_started pywikipedia] bot can be used on wikiHack. 'pywikipedia' is written in the [http://en.wikipedia.org/wiki/Python_programming_language Python] scripting language. If you are not familiar with Python, [http://diveintopython.org/ Dive Into Python] provides a quick introduction along with links to [http://www.activestate.com/Products/ActivePython/ ActiveState] where you can download a free turn-key install package for most platforms.
+
NetHackWiki uses [[mw:MediaWiki|MediaWiki]], the same software that runs [http://wikipedia.com/ wikipedia]. Therefore the [http://meta.wikimedia.org/wiki/Interwiki_bot/Getting_started pywikipedia] bot can be used on NetHackWiki. 'pywikipedia' is written in the [http://en.wikipedia.org/wiki/Python_programming_language Python] scripting language. If you are not familiar with Python, [http://diveintopython.org/ Dive Into Python] provides a quick introduction along with links to [http://www.activestate.com/Products/ActivePython/ ActiveState] where you can download a free turn-key install package for most platforms.
  
=== WikiHack Setup ===
+
=== NetHackWiki Setup ===
 
# Create the bot account.
 
# Create the bot account.
 
## Use <YourName>Bot as the username.
 
## Use <YourName>Bot as the username.
 
## Write down the password.
 
## Write down the password.
# Ensure the display skin is set to Monobook (deafult skin).
+
# Ensure the display skin is set to Monobook (default skin).
 
# Log out you bot account.
 
# Log out you bot account.
  
 
=== Downloading pywikipedia ===
 
=== 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 wikiHack.
+
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.
  
 
# Download and install Python. [http://www.activestate.com/Products/ActivePython/ ActiveState] has a good package
 
# Download and install Python. [http://www.activestate.com/Products/ActivePython/ ActiveState] has a good package
Line 46: Line 46:
  
 
=== Configuring pywikipedia ===
 
=== Configuring pywikipedia ===
Because wikiHack is not wikipedia, the bot needs some additional code to work properly. Wikipedia has information on workarounds for [http://meta.wikimedia.org/wiki/Pywikipedia_bot_on_non-Wikimedia_projects non-wikipedia wikis]. Basically we'll need to add a 'families' definition for wikiHack before attempting to login.
+
Because NetHackWiki is not Wikipedia, the bot needs some additional code to work properly. Wikipedia has information on workarounds for [http://meta.wikimedia.org/wiki/Pywikipedia_bot_on_non-Wikimedia_projects non-wikipedia wikis]. Basically we'll need to add a 'families' definition for NetHackWiki before attempting to login.
  
 
# Check if '''<bot root>\families\wikihack_family.py''' exists.
 
# Check if '''<bot root>\families\wikihack_family.py''' exists.
Line 59: Line 59:
  
 
=== pywikipedia: Upload ===
 
=== pywikipedia: Upload ===
* Run command line '''python upload.py -log -keep <filename> "<description>"'''  
+
* Run command line '''python upload.py -log -keep <filename> "<description>"'''
  
 
== user-config.py ==
 
== user-config.py ==
Line 81: Line 81:
 
         self.name = 'wikihack'          # family name, same as filename
 
         self.name = 'wikihack'          # family name, same as filename
 
         self.langs = {
 
         self.langs = {
             'en': 'nethack.wikia.com',  # wikiHack hostname
+
             'en': 'nethackwiki.com',  # NetHackWiki hostname
 
         }
 
         }
  
Line 92: Line 92:
 
         # Project namespace. All languages use the same project namespace name.
 
         # Project namespace. All languages use the same project namespace name.
 
         self.namespaces[4] = {
 
         self.namespaces[4] = {
             '_default': u'Wikihack',  
+
             '_default': u'NetHackWiki',  
 
         }                               
 
         }                               
  
 
         # Project talk namespace.
 
         # Project talk namespace.
 
         self.namespaces[5] = {
 
         self.namespaces[5] = {
             '_default': u'Wikihack talk',
+
             '_default': u'NetHackWiki talk',
 
         }
 
         }
  
Line 116: Line 116:
 
     # hostname. The same for all languages
 
     # hostname. The same for all languages
 
     def hostname(self, code):
 
     def hostname(self, code):
         return 'nethack.wikia.com'
+
         return 'nethackwiki.com'
 
</pre>
 
</pre>
 +
[[Category:NetHackWiki]]

Latest revision as of 02:26, 18 May 2015

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'