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:Transwiki.py
""" Script to change links after transwiki movements of pages (from Wikipedia or another sister project, to Wiktionary). """ import os, sys import wikipedia, pagegenerators, replace def main(): oldTitle = None newTitle = None # read command line parameters for arg in wikipedia.handleArgs(): if oldTitle == None: oldTitle = arg elif newTitle == None: newTitle = arg else: # too many parameters wikipedia.output('ERROR: Too many parameters') return if not oldTitle or not newTitle: # not enough parameters wikipedia.showHelp('transwiki') return page = wikipedia.Page(wikipedia.getSite(), oldTitle) gen = pagegenerators.ReferringPageGenerator(page) gen = pagegenerators.PreloadingGenerator(gen) oldPattern = '[%s%s]%s' % (oldTitle[0].lower(), oldTitle[0].upper(), oldTitle[1:]) replacements = [ ("\[\[(%s)\]\]" % oldPattern, "[[wikt:%s|\\1]]" % newTitle), ("\[\[[%s\|(.*?)\]\]" % oldPattern, "[[wikt:%s|\\1]]" % newTitle), ] replaceBot = replace.ReplaceRobot(gen, replacements) replaceBot.run() if __name__ == "__main__": try: main() finally: wikipedia.stopme()