Touch scripts are very simple and useful way to update the display of a file that has been updated.
An easy example of this would be:
🔄 Touch all pages linking "Morning Light std.png"
When to use: Update page cache without content changes
python pwb.py touch -lang:deadlock -filelinks:"Morning Light std.png"
touch
- Executes the touch command to perform a null edit, effectively updating the display of pages that link to the specified file
-lang:deadlock
- Specifies the language of the wiki as "teamfortress". (name of the wiki)
-filelinks:"Morning Light std.png"
- Targets the pages that link to the file "Morning Light std.png"
🔄 Touch all pages in category "Pages with script errors"
Sometimes after module change pages are stuck in script error even that they are already fixed. Most of the time touch will unstuck this pages.
python pwb.py touch -lang:deadlock -cat:"Pages with script errors"
The most common script used by bot editors is the replace script.
An easy examples of this would be:
-
Simplyfing call
-
General fix "Invalid resolve redirect input"
-
Changing |image= on Infobox League
-
Migrates Flags to new Format
python pwb.py replace -lang:deadlock -transcludes:Team_achievements_table -ns:0 "\{\{[Tt]eam[_ ]achievements[_ ]table\|team\s*=.*?\}\}" "{{Team_achievements_table}}" -summary:"Remove redundant team parameter"
replace
- This is the main command for performing a search-and-replace operation
-lang:deadlock
- Specifies the language of the wiki as "deadlock". (name of the wiki)
-transcludes:Team_achievements_table
- Limits the operation to pages that include the Team_achievements_table template
-ns:0
- Limits the operation to pages in the Main space.
First Set of Quotations
- This is the search pattern, a regular expression that matches any instance of Team_achievements_table or team_achievements_table (case-insensitive) with a team parameter.
- \s* ensures to catch arguments with and without space "team =" and "team="
- The non-greedy quantifier .*? ensures it matches as few characters as possible.
- "[_ ]" ensures that the search takes into account both the search for a template with a space or with _
Second Set of Quotations
- The replacement string. The command replaces the matched text with {{Template:Team achievements table}}
-summary: "Remove redundant team parameter"
- Adds an edit summary explaining the change
In summary, this command will find any instance of the Team_achievements_table template with a "team" parameter in main space and remove the "team" parameter, simplifying the template call.
python pwb.py replace -lang:deadlock -intersect -cat:"Invalid_resolve_redirect_input" -regex -transcludes:"Infobox league" -summary:"Blame Slothy. Invalid resolve redirect input in organizer" "\|organizer(\d*)\s*=\s*\[([^\[\] ]*) ([^\[\]]+)\](?!.*\[)" "|organizer\1=\3|organizer\1-link=\2" -always
replace
- This is the main command for performing a search-and-replace operation.
-lang:deadlock
- Specifies the language of the wiki as "deadlock". (name of the wiki)
-intersect
- This will ensure that both search patterns are used. "-cat:" and "-transcludes:"
-cat:"Invalid_resolve_redirect_input"
- Limits the operation to pages in the "Invalid_resolve_redirect_input" category.
-regex
- Indicates that the search pattern is a regular expression.
-transcludes:"Infobox league"
- Limits the operation to pages that include the "Infobox league" template.
First Set of Quotations
- This is the search pattern, a regular expression that matches the "organizer" fields formatted as:
- |organizerX = [name link]
- The pattern captures:
- - organizer(\d*) which matches the "organizer" field followed by an optional digit (X).
- - \s*=\s*[([^[] ]) ([^[]]+)] which matches the assignment of a name and link, ensuring that:
- - ([^[] ]) captures the link (name) without spaces or brackets.
- - ([^[]]+) captures the name (display text) which can include spaces but not brackets.
- - (?!.*[) ensures that there are no additional brackets following the match.
Second Set of Quotations
- The replacement string. The command replaces the matched text with:
- |organizer\1=\3|organizer\1-link=\2
- This reformats the matched text into two separate fields: "organizerX" and "organizerX-link".
-summary:"Blame Slothy. Invalid resolve redirect input in organizer"
- Adds an edit summary explaining the change.
-always
- Don't prompt you for each replacement and automatically start with replacement. This is optional if you sure your script will work perfectly without checking.
🖼️ Image Migration
Update image formats:
python pwb.py replace -lang:deadlock -regex "\{\{\s*[Ff]lag\/(.*?)\s*\}\}" "{{Flag|\1}}" -search:"insource:flag" -summary:"Migrate Flags to new Format" -always
replace
- This is the main command for performing a search-and-replace operation.
-lang:deadlock
- Specifies the language of the wiki as "deadlock". (name of the wiki)
-regex
- Indicates that the search pattern is a regular expression.
-search:"insource:flag"
- Limits the operation to pages that includes flag in it
First Set of Quotations
- This is the search pattern, a regular expression that matches the flag parameter formatted as:
- {{flag/xx}}
Second Set of Quotations
- The replacement string. The command replaces the matched text with:
- {{Template:Flag}}
-summary:"Migrate Flags to new Format"
- Adds an edit summary explaining the change.
-always
- Don't prompt you for each replacement and automatically start with replacement. This is optional if you sure your script will work perfectly without checking.
python pwb.py replace -lang:apexlegends -regex -transcludes:Infobox_team -ns:0 "\|image\s*=\s*APEX Legends GS Challenger\.png" "|image=Apex Legends Global Series Challenger lightmode.png\n|imagedark=Apex Legends Global Series Challenger darkmode.png" -summary:"Update image parameters for APEX Legends GS Challenger" -always
replace
- This is the main command for performing a search-and-replace operation.
-lang:apexlegends
- Specifies the language of the wiki as "apexlegends". (name of the wiki)
-regex
- Indicates that the search pattern is a regular expression.
-transcludes:Infobox_team
- Limits the operation to pages that include the "Infobox team" template.
-ns:0
- Limits the operation to pages in the Main space.
First Set of Quotations
- This is the search pattern, a regular expression that matches the image parameter formatted as:
- |image = APEX Legends GS Challenger.png
- The pattern captures:
- - |image\s*=\s*APEX Legends GS Challenger.png which matches the specific image filename, allowing for optional spaces around the equals sign.
Second Set of Quotations
- The replacement string. The command replaces the matched text with:
- |image=Apex Legends Global Series Challenger lightmode.png\n|imagedark=Apex Legends Global Series Challenger darkmode.png
- This reformats the matched text by updating the image parameter to include both lightmode and darkmode images.
-summary:"Update image parameters for APEX Legends GS Challenger"
- Adds an edit summary explaining the change.
-always
- Don't prompt you for each replacement and automatically start with replacement. This is optional if you sure your script will work perfectly without checking.