Welcome to the ScoutWiki Network

Bot configuration/dategene.py

From ScoutWiki Network
Revision as of 10:52, 1 August 2016 by Egel (talk | contribs) (4 revisions imported: moved from scoutmedia)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You should change your month names in two places. Script creates language links to Finnish PartioWiki. You don't need other language links, because bots can find others. I.e. If you modify this script from French to Dutch, interwiki.py (in pywikipedia framework) will found, that if scoutpedia.nl has link to date page in PartioWiki, it should have link to Scoutopedia also and create it.

#!/usr/bin/python
# -*- coding: utf-8  -*-

__version__='$Id: dategene.py,v 1.0 2006/04/4 19:26:01 wikipedian Exp $'

import wikipedia
import login

msg = {
         'en':u'Robot: Stub marks',
         #'fi':u'Bot: P\u00e4iv\u00e4m\u00e4\u00e4r\u00e4 sivu luotu', #datepage created
	 'fr':u'Bot: cr\u00e9ation de la page de date'
       }

comment = wikipedia.translate(wikipedia.getSite(), msg)
wikipedia.setAction(comment)

s=wikipedia.getSite()
#This one creates actual date pages [[1st of january]], what only shows the template
#login.LoginManager('KonttiBot', False, s)
for kk in ['janvier',u'f\u00e9vrier','mars','avril','mai','juin','juillet',u'ao\u00fbt','septembre','octobre','novembre',u'd\u00e9cembre'] :
	for pa in range(31) :
		pp=pa+1
		p=wikipedia.Page(s,str(pp)+' '+kk)
		st=u"Les \u00e9v\u00e8nements doivent \u00eatre ajout\u00e9s au mod\u00e8le correspondant \u00e0 la date, et non \u00e0 cette page, \u00e0 moins qu'il n'y ait d\u00e9j\u00e0 5 \u00e9v\u00e8nements sur le mod\u00e9le. Si tel est le cas, veuillez lister les 5 \u00e9v\u00e8nements les plus importants sur le mod\u00e8le, et les autres sur cette page.\n" #default text, saying that include your event to the template, not actual page. Unless there is allready 5 different events in template.
                #Choose the five biggest one, and list the less important one in the datepage.
		#Appel d'un futur modèle de date avec paramètres, destiné à remplacer {{modèle date}} qui appelle un modèle pour chaque date.
		st+=u'{{date|mois='+kk+'|jour='+str(pp)+'}}\n'
		st+=u'\n'
		st+=u"<!--Le mod\u00e8le ci-dessus n'est pas encore utilis\u00e9.\n"
		st+=u'Ajoutez les \u00e9v\u00e8nements au mod\u00e8le ci-dessous.-->\n'
		st+='\n'
		st+=u'----\n'
		st+=u'{{mod\u00e8le date}}\n'
		st+=u'\n'
		st+=u'{{navigation dates|hier='+str(pp-1)+' '+kk+'|demain='+str(pp+1)+' '+kk+'}}\n'
		st+=u'\n'
		st+=u'[[Cat\u00e9gorie:'+kk+']]\n'
                if kk=='janvier':
                   kkfin='tammikuu'
                if kk==u'f\u00e9vrier':
                   kkfin='helmikuu'
                if kk=='mars':
                   kkfin='maaliskuu'
                if kk=='avril':
                   kkfin='huhtikuu'
                if kk=='mai':
                   kkfin='toukokuu'
                if kk=='juin':
                   kkfin=u'kes\u00e4kuu'
                if kk=='juillet':
                   kkfin=u'hein\u00e4kuu'
                if kk==u'ao\u00fbt':
                   kkfin='elokuu'
                if kk=='septembre':
                   kkfin='syyskuu'
                if kk=='octobre':
                   kkfin='lokakuu'
                if kk=='novembre':
                   kkfin='marraskuu'
                if kk==u'd\u00e9cembre':
                   kkfin='joulukuu'
                st+=u'[[fi:'+str(pp)+'. '+kkfin+'ta]]\n'
		#st+=u'[[Luokka:P\u00e4iv\u00e4t]]\n'
		st+=u'\n'
		p.put(st)

wikipedia.stopme()