User:Wesley/Bot guide/Examples

From JoCopedia
< User:Wesley‎ | Bot guide
Revision as of 06:25, 8 May 2008 by Wesley (talk | contribs) (Separate out examples)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This page lists examples of things you can do with your robot.

Removing {{SongNav}} from song pages

This is a one-liner using the built-in replace.py

python replace.py -cat:Songs -regex "{{SongNav}}\n*" ""

Moving files from Template:DATE_ to TDiJC

Apologies ahead of time for the complete mess in this section. As you'll soon be able to tell, it's a complete hackjob that will probably only ever suit this specific purpose.

First, go to Special:AllPages and choose the pages in namespace Template. Copy all the titles starting with DATE into a text file. Make them all into wikilinks, one on each line. For example DATE April 1 becomes [[Template:DATE April 1]]. Save the file as filelist.txt

Very inelegant hack coming up

Make a copy of movepages.py and call it movepages2.py. Change the following lines:

Line 119
-                newPageTitle = (u'%s:%s' % (namesp, newPageTitle))
+                newPageTitle = (u'TDiJC:%s' % newPageTitle)
Line 199
-        self.regexAll = False
+        self.regexAll = True
+        self.regex = re.compile("DATE ")
+        self.replacePattern = ""

THIS CODE ONLY WORKS FOR THIS PARTICULAR MOVE FROM Template:DATE_ to TDiJC:

Use the following command

python movepages2.py -file:filelist.txt

Change links in a page to point to TDiJC: pages instead of Template:DATE_ pages

python replace.py -page:This_Day_in_JoCo "[[Template:DATE_" "[[TDiJC:"

I should have realized, though, that it would have been easier to just copy the text into a text editor, did a Search and Replace, and then paste the text back in.