Manual:Pywikibot/protect.py

protect.py is a script that helps you protect pages en masse. It is a simple script that gives you great power over the protected status of almost every part of your wiki. However, since wikis are generally thought of as "encyclopedias anyone can edit", some thought must be giving to the reasons why you want to use this script. Within some wiki communities, particularly Wikipedia itself, misuse of this script could well result in the revocation of your sysop rights.

When to use
Before using this script, you need to thoroughly understand your wiki's policies about page protection. If your wiki hasn't yet discussed the whys and wherefores of page protection, it's a good idea to have that discussion and to write up some kind of policy. Your community should understand what you're doing with the bot. Misuse of this bot — that is, using it to protect all pages on a wiki — is very easy to do with this bot, but would generally be seen as an abuse of administrative powers in most wiki communities.

Typical reasonable usages are:
 * protecting a whole category of templates, because changing those templates would have a significant impact upon the wiki
 * protecting help or policy pages from general editing, because you don't want the "rules" of your wiki being subject to vandalism
 * preventing pages from having their names changed — that is, "move locking" pages — but still allowing them to be freely edited

Syntax
The script is invoked by typing:

Command line parameters:

-page:      Protect specified page -cat:       Protect all pages in the given category. -nosubcats: Don't protect pages in the subcategories. -links:     Protect all pages linked from a given page. -file:      Protect all pages listed in a text file. -ref:       Protect all pages referring from a given page. -images:    Protect all images used on a given page. -always:    Don't prompt to protect pages, just do it. -summary:   Supply a custom edit summary. -unprotect:  Actually unprotect pages instead of protecting -edit:PROTECTION_LEVEL Set edit protection level to PROTECTION_LEVEL -move:PROTECTION_LEVEL Set move protection level to PROTECTION_LEVEL


 * 1) Without support ##
 * 2) -create:PROTECTION_LEVEL Set move protection level to PROTECTION_LEVEL ##

Values for PROTECTION_LEVEL are: sysop, autoconfirmed, none. If an operation parameter (edit, move or create) is not specified, default protection level is 'sysop' (or 'none' if -unprotect).

For example, we used to extract the top of Special:MostLinkedTemplates in a file, and then to treat it like: python protect.py -file:articles_list.txt -always -summary:"Special:MostLinkedTemplates protection" -edit:sysop -move:sysop

Custom summaries advisable
If you fail to use the  parameter, an automated summary will be inserted for you. But that summary won't tell your community why you've taken the action. Because protecting pages is generally considered antithetical to the spirt of wiki editing, it's usually important to leave behind a summary that explains why you've taken this unusual action. Remember, when your users attempt to edit or move the page, they'll get a message which includes your bot's edit summary. In most cases, this summary should be as explicit as possible about the reason why your users can't do what they want to do.

If you've put up a full block — that is, sysop-only editing — you'll probably also want to include a link to a page where users can leave feedback on how to improve the locked article. Often, this is the talk page, but on wikis that don't have the talk page functionality enabled, it might be a good idea to drop in a link to a forum or other feedback page.

Limitations
This script has no ability to affect the protection level of anything in the MediaWiki or Special namespaces. MediaWiki pages are always "sysop-only" pages.