User:strcat

From ArchWiki
Revision as of 12:20, 5 January 2012 by Kynikos (Talk | contribs) (File -> hc)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

thestinger's cute little bot.

About this bot

Right now I'm using pywikipediabot/pywikibot, and so far just the scripts that are included (the newer pywikibot has a nicer API but doesn't include all the nice scripts) because they cover almost everything (replace.py lets you use regex).

pywikipediabot/pywikibot archwiki family file:

archwiki_family.py
import family

class Family(family.Family):
    def __init__(self):
        family.Family.__init__(self)
        self.name = 'archwiki'
        self.langs = {'en':'wiki.archlinux.org',
                      'fr':'wiki.archlinux.fr',
                      'ro':'wiki.archlinux.ro'}

        self.namespaces[1]['ro'] = u'Discuţie'
        self.namespaces[3]['ro'] = u'Discuţie Utilizator'
        self.namespaces[6]['ro'] = u'Fişier'
        self.namespaces[7]['ro'] = u'Discuţie Fişier'
        self.namespaces[9]['ro'] = u'Discuţie MediaWiki'
        self.namespaces[11]['ro'] = u'Discuţie Format'
        self.namespaces[13]['ro'] = u'Discuţie Ajutor'
        self.namespaces[15]['ro'] = u'Discuţie Categorie'

        self.namespaces[4] = {'_default':'ArchWiki',
                              'fr':'ArchwikiFR',
                              'ro':'ArchWikiRo'}
        self.namespaces[5] = {'_default':'ArchWiki talk',
                              'fr':'Discussion ArchwikiFR',
                              'ro':u'Discuţie ArchWikiRo'}

        self.category_attop = ['en']
        self.interwiki_attop = ['en']

        # Using newlines looks nicer but sometimes creates gaps
        self.category_text_separator = ''
        self.interwiki_text_separator = ''

    def protocol(self, code):
        # The ArchWiki is https only and the bot ignores the redirect
        if code == 'en':
            return "https"
        else:
            return "http"

    def scriptpath(self, code):
        return ''

    def version(self, code):
        # https://wiki.archlinux.org/index.php/Special:Version
        if code == 'fr':
            return '1.16.2'
        elif code == 'ro':
            return '1.15.5'
        else:
            return '1.17.0'

patch to fix the marker not being removed with the category_attop setting (for pywikipediabot, don't know if pywikibot has the same problem since I'm not using it for categories) [I should probably report this upstream, but I'm not sure if the ArchWiki causes the problem]:

pywikipediabot-category-attop.patch
--- pywikibot/textlib.py	2011-09-06 21:49:22.386749427 -0400
+++ pywikibot/textlib.py.new	2011-09-06 21:46:31.544743236 -0400
@@ -675,7 +675,7 @@
     s = categoryFormat(new, insite = site)
     if s:
         if site.language() in site.family.category_attop:
-            newtext = s + separator + s2
+            newtext = s + separator + s2.replace(marker, '')
         else:
             # calculate what was after the categories links on the page
             firstafter = s2.find(marker)