Planning the future of Botwiki! - Help us bring Botwiki up to date, contribute to our strategy discussion, add bot scripts, and contribute manuals, guides, and tutorials! Almost anything related to bots, particularly those used to edit mediawiki, is welcome.
UNABLE TO EDIT? - We've experienced attacks by spambots lately and now require you to confirm your e-mail before you can edit (go to your preferences, enter an e-mail address, and request a confirmation e-mail, then go to your e-mail and click on the confirmation link). We also require new accounts to make a few edits and wait a few minutes before before you can create a page; however, if this is a problem contact us in #botwiki and we can manually confirm your account. Sorry for the inconvenience.
Python:Portalebot.py
#!/usr/bin/python # -*- coding: utf-8 -*- """ Script to merge two different {{Portale|Par1}}\n{{Portale|Par2}} into {{Portale|Par1|Par2}} when needed. Used on it.wikipedia. """ # # (C) Filnik, 2007-2008 # # Distributed under the terms of the MIT license. # import wikipedia, pagegenerators import re, string def main(): arg = wikipedia.handleArgs() site = wikipedia.getSite() page = wikipedia.Page(site, 'Template:Portale') pages_to_check = pagegenerators.ReferringPageGenerator(page, False, True, True)#[wikipedia.Page(site, 'Atomo')] for i in pages_to_check: wikipedia.output('Loading %s...' % i.title()) try: text = i.get() except Exception, e: print e continue result = re.findall("\{\{([Tt]emplate:|)[Pp]ortale\|(.*?)\}\}", text) res = list() for l in result: if l not in res: res.append(l) continue result = res try: projectname = result[0][1] except: wikipedia.output(u"Template Portale non trovato, probabilmente e' incluso in qualche template..") continue if '|' in projectname and len(result) == 1: wikipedia.output(u"Il template e' gia' stato sistemato...") elif len(result) == 1: wikipedia.output(u'Ho trovato solo {{Portale|%s}}...' % string.capitalize(projectname)) else: wikipedia.output(u'Template Portale trovato %s volte!' % len(result)) stringa = '' newtext = text for z in range(0,len(result)): s = 0 if z == s: for p in result: if p == result[-1]: stringa = stringa + p[1] else: stringa = stringa + p[1] + '|' newtext = re.sub(r"\{\{([Tt]emplate:|)[Pp]ortale\|.*?\}\}", r"{{Portale|%s}}" % stringa, newtext, 1) else: for q in result: newtext = re.sub(r"\n?\{\{([Tt]emplate:|)[Pp]ortale\|%s\}\}" % q[1].replace('|', '\|'), "", newtext, 1) wikipedia.output(u'\n\t>>> MODIFICO! <<<') wikipedia.showDiff(text, newtext) i.put(newtext, 'Bot: Sistemo il template {{Portale}}') if __name__ == "__main__": try: main() finally: wikipedia.stopme()