pywikibot, often called simply "bot", is the main tool the wiki uses to make mass edits. pywikibot takes commands from the user and responds by making the appropriate edits using MediaWiki's API. pywikibot is written in Python, a cross-platform programming language.
Use on the FFWiki
Intangir Bot
All automated edits on the Final Fantasy Wiki are done on . This causes the accounts to be hidden from Recent Changes unless ?hidebots=0 is appended to the URL. This is to keep Recent Changes usable rather than being spammed with tiny edits that the average user isn't affected by.
While other bot accounts, such as Wikia, exist, pywikibot edits are made with Intangir Bot. This is done for a number of reasons, including to keep all bot edits easily trackable and to not have to deal with the hassle of creating a new bot flag every time a new user needs to use a bot. If you need to use Intangir Bot, request access at Requests for Promotion. If anybody is caught misusing the bot, their edits will be reverted and the password will be changed.
If you need to make automated edits but do not know how to use pywikibot or have the password to Intangir Bot, leave a message on its userpage and one of its operators will complete the job within the next few days.
Installation
See #Scripts for information about setting up Python and using cd in the command line.
Once Python is installed you'll need pywikibot. The wiki's modified version of pywikibot can be downloaded from github. Once that is done you can simply run:
python login.py
It will then ask you for Intangir Bot's password. Once that is entered you will be logged in, and can run any other script.
If you don't want to use the customized pywikibot -- for example, you want to use pywikibot on multiple wikis, or you use Python 2.5.*, which doesn't support the latest pywikibot (therefore you'll need to run the "Compat" version), see Installation and click on your OS for further instructions.
Settings
Aside from having family files already set up, the python scripts downloadable from github also have several changes made in user-config.py. This is a list of all of the changes made for the FFWiki.
# The dictionary usernames should contain a username for each site where you
# have a bot account.
usernames['ffwiki']['en'] = u'Intangir Bot'
sysopnames['ffwiki']['en'] = u'Catuse167'
This declares the default bot account to be Intangir Bot and the admin account to be Catuse167. Note that Intangir Bot has admin rights, but this is only so it can edit protected pages; it will not make admin edits (e.g. deletion) unless sysopnames is set to u'Intangir Bot'. This should only be done if the wiki, including an admin, has a consensus to do so. Hiding mass deletions from the Recent Changes is always a bad idea. If you are an admin and want to make admin edits, you should set sysop names to u'You'. You will be prompted for a password when you try to run a script that requires admin permissions.
# How many external links should weblinkchecker.py check at the same time?
# If you have a fast connection, you might want to increase this number so
# that slow servers won't slow you down.
max_external_links = 50
report_dead_links_on_talk = True
Affects weblinkchecker.py. There's little need to change max_external_links because the wiki has comparatively few external links. The second variable causes the bot to list dead links on a talk page if they are down after running the script several times.
#Enable cosmetic_changes.py, which will run alongside all other pywikipedia scripts
cosmetic_changes = True
Causes cosmetic_changes.py to be used.
Scripts
To run anything you need to use a Python 2.7.* interpreter from your OS's command line. To bring up the command line:
- For Windows, press Ctrl+R to bring up Run, then type
cmdto bring up the Command Prompt. - For Mac OS X, open Applications/Utilities and click Terminal.
- UNIX systems other than Mac OS, such as Linux distros, have multiple terminals and it usually comes down to user preference.
One in the command line, one must enter the python command to check if you have Python; if you don't you will get an error message. If you don't have Python:
- For Windows or Mac OS X, you will need to download it from here (make sure to choose the latest 2.7.* version).
- For Linux, you can download Linux from a package manager, or compile it from the source code.
Once Python is installed you'll need to get into the directory containing all of your scripts. You do this using the cd command. Most terminals, including Windows' Command Prompt, start in your home directory (C:/Users/You, ~/home/You, etc), so if your intangirbot folder is in a "Wiki work" folder in your Desktop, you would type:
cd "Desktop/Wiki work/intangirbot"
In all OSes except Windows, you can run a python script by typing:
python <name_of_script>.py -<parameter1> -<parameter2> -<parameter3>...
Most installations of Python on Windows do not have you type "python" at the beginning of the command. So:
<name_of_script>.py -<parameter1> -<parameter2> -<parameter3>...
So, for example, to run delete.py with the parameters cat:"Articles for Speedy Deletion", pt:0, and always, you would type:
python delete.py -cat:"Articles for Speedy Deletion" -always -pt:0
Once the bot is running it will occasionally ask for user input, in which case it will pause editing. Once every page has been edited the python script will exit out and the command line will come up again. This is a screen shot of the MATE Terminal, finishing up a script, Ctrl + C'ing out of a second, and then starting a third.
The following is a list of scripts useful to the Final Fantasy Wiki, organized by how they are used. This isn't a complete list of pywikibot scripts. That can be viewed at MediaWiki; however, many of these scripts can only be used on Wikimedia or are simply irrelevant to the Final Fantasy Wiki, and most scripts are poorly documented.
Textual editing
These scripts will make mass edits to the text of the wiki. Usually for relinking, implementing a new template, and the like.
add_text.py
python add_text.py <parameter> -text:"<text to be added>" [-up] [-except:"<regex>"] -pt:0 -always
This script adds text to the bottom of a group of pages. The group of pages is determined by a parameter given in the command line when you call the script. The script has two other optional parameters:
- -up (no input) causes the script to add the text to the top of the page, instead of the bottom. Good for adding sideicons and infoboxes.
- -except takes a regex and checks if the bottom (or top, if -up is used) of the page already has the text indicated by that regex. If that's the case, the page is skipped.
- replace.py
revertbot.py
python revertbot.py
The script to run when you dun goofed. Reverts all edits the bot made until cancelled with Ctrl + C or by closing the window. You can also log in as yourself and revert edits you made, if you did something wrong. Never run this script unattended!
template.py
python template.py "<name of old template>" "<name of new template>" -pt:0 -always
A script for renaming templates, it will replace all instances of {{name of old template}} on the wiki with {{name of new template}}.
python template.py "<name of old template>" -remove -pt:0 -always
Removes the template {{name of old template}} and all its parameters from every page on the wiki.
- solve_disambiguation.py
Maintenance
These should usually be run on a regular basis, perhaps bimonthly, as they check the entire wiki for technical problems and fix them.
cosmetic_changes.py
python cosmetic_changes.py -start:! -pt:0 -always
A script that cleans up syntax and formatting in wikitext. This is useful especially because of the VisualEditor, which can create unnecessary spacing or HTML. It runs alongside all other scripts, and if it found any changes to be made, "; cosmetic changes" will be added to the edit summary.
This script can be run by itself, but because it doesn't make any changes that are visible to readers, this puts unnecessary stress on the servers, and should only be done for testing.
Once the script has made some edits successfully, press Ctrl + C to cancel execution and end your test edits.
interwiki.py
A complex script that handles interwiki language links. At its simplest you can type
python interwiki.py "<pagename>"
where <pagename> is some page that has interwiki links. It will then check those interwiki links, and the interwiki links on those pages, etc., and compile a list of all pages across all wikis that it could find that interwiki to each other. After that, any of the following cases can happen
- If ffwiki:en (the wiki you're currently reading) doesn't link to one it will add that link with the other interwiki links at the bottom of the page.
- If it finds that ffwiki:en has an interwiki link to a page that doesn't exist, it will throw an error asking you to allow it to remove it.
- If it finds that there is more than one page in a given language about a certain subject (common with disambigs) it also throws an error and asks you to fix it by hand.
Once all this is said and done, it will give you WARNING: messages regarding missing interwiki links in other languages. For example:
======Post-processing ====== No changes needed on page WARNING: ffwiki: does not link to
It will then allow you to fix these by hand.
This is all great if you just created a new page, added an interwiki to a single other language (say, ffwiki:es), and want to automatically generate interwiki links to every other language that FFWiki is written in. However, pywikibot, being primarily used for mass edits, can also edit hundreds or even thousands of pages at once.
python interwiki.py -start:! -autonomous -pt:0 -always
python interwiki.py -cat:"<category>" -autonomous -pt:0 -always
These Selection Parameters should be familiar: the former checks every single article on ffwiki:en, while the latter checks a certain category, perhaps a category about a release that just came out and doesn't have complete interwiki links yet. It only makes edits of case 1 (adding a simple interwiki) and lists all case 2 and case 3 (removing an interwiki, choosing between multiple interwikis) in a file called autonomous_problems.dat. If the bot is canceled halfway through editing with Ctrl + C, it leaves a file called interwiki.dump behind. You can pick up where you left off with
python interwiki.py -restore -autonomous -pt:0 -always
and go through the case 2 and case 3 problems from a previous run by hand with
python interwiki.py -file:autonomous_problems.dat
Finally, you can use the logfile, logs/interwiki.log, to create interwikis on other language wikis such as ffwiki:es or ffwiki:fr which point back to ffwiki:en. After running you can
python interwiki.py -warnfile:logs/interwiki.log -autonomous -pt:0 -always
while logged into another wiki. This generates links from ffwiki:<some language> to ffwiki:en if links from ffwiki:en to ffwiki:<some language> exist already and were noted when the script was run originally. However, it might not be advisable to run this script unless you were given permission to do so by the admins of that wiki (which can be difficult, because of the language barrier.
There are many, many other features usable by interwiki.py, most of which could not be documented here. See MediaWiki for a complete documentation
selflink.py
python selflink.py -start:!
Goes through the wiki and finds pages that link to themselves. Will ask the user what to do with them. Will take very long to run, because while it checks dozens of pages a minute, it has to cover the entire wiki.
table2wiki.py
python table2wiki.py "<page name>" -pt:0
python table2wiki.py -start:! -pt:0
Turns all of the tables on the pages searched from HTML into wikitext. Should never be run with -always because there are legitimate reasons to use HTML tables on the wiki, and the script is somewhat buggy. This means the user will need to check each table by hand before the edit is completed.
redirect.py
python redirect.py both -pt:0
A simple script that manages redirects. It will fix double or triple redirects and delete broken redirects (if you have an admin account) or ask you what to do with them (if you don't).
Categories
One script that manages categories.
category.py
This single script manages categories, and has many different functions. A full documentation can be viewed at MediaWiki, but a summary of the most common functions used on the FFWiki follows.
python category.py add <parameter> -pt:0 -always
Gets a list of all the pages that fits the parameter passed to it, then asks you for a category name, and adds every page in the list to that category.
python category.py remove -pt:0 -always
Asks you for a category name, and then removes all the pages in it from it.
python category.py move -from:"[category name]" -to:"[category name]" -pt:0 -always
Moves all pages from the first category into the second category. If you have admin access, deletes the old category. Otherwise, make sure to use {{delete}} to mark it for deletion so an admin can delete it.
Notifications
Similar to maintenance scripts, these scripts should be run on a regular basis. However, they do not fix the problems they find, only tagging them for a human editor to find and clean up.
lonelypages.py
python lonelypages.py
Puts {{cleanup|Needs to be linked to}} on all pages that are not linked to by the wiki.
weblinkchecker.py
python weblinkchecker.py -start:!
Creates a file, deadlinks-ffwiki-end.dat on in your deadlinks/ directory that lists all pages with external links that return 404s or other error messages. Because it has to check thousands of pages, this script takes very long to run.
python weblinkchecker.py -repeat
Opens deadlinks/deadlinks-ffwiki-end.dat and checks all of the pages in it, updating it if any links have been fixed. If a week has passed since this script has run and the external links still return 404, it puts a warning message on the talk pages telling other editors to fix the broken links.
Administration
These scripts require sysop access, and should not be run unless you actually are a sysop and making the edits on your account (NOT Intangir Bot), or have been given permission in a discussion to do so (which is frowned upon, because if you make an accidental deletion and the edits are hidden from the Recent Changes, nobody will notice).
delete.py
python delete.py <parameter> -summary:"<summary>" -pt:0 -always
Deletes all of the pages that fulfill a certain parameter using sysop access.
Mostly useful with -file, for example when given a list of abandoned walkthroughs or unused files. -cat:"Articles for Speedy Deletion" purges the Articles for Speedy Deletion, but this can delete images that are still linked to on pages, plus pages that transclude {{delete}} templates, and so this is bad practice. You should also make sure to give a summary, so when another user checks the deletion log he can actually know why you deleted dozens of pages.
python delete.py undelete <parameter> -summary:"<summary>"-pt:0 -always
This command, almost always invoked using the -file parameter, recreates pages that were deleted. Just like revertbot.py, but for deletions.
protect.py
python protect.py <parameter> -edit:"<protection level>" -move:"<protection level>" -summary:"<summary>" -pt:0 -always
Protects all of the pages that fulfill a certain parameter using sysop access. The protection levels are sysop, autoconfirmed, and none. -edit affects the ability to edit the text of that page, while -move affects the ability to rename it. The loosest protection for editing is none (except for MediaWiki pages, which are always designer-level and cannot be affected by this script), and the loosest possible protection for moving is autoconfirmed.
Best used to fight vandalism: if a returning sockpuppeteer attacks the same category of pages over and over, they can simply be raised to autoconfirmed-level until the vandal gets bored and leaves. Then it can be reset to none.
Parameters
Parameters, also known as arguments or options, are the modifiers that allow the user to tell pywikibot what pages to edit, what edit summary to leave, and other minor details that vary from task to task. For example, consider the following command:
python add_text.py -catr:"Final Fantasy Wikians" -text:"{{RailModule|title=Facts|content=This user is a great editor!}}" -up -except:"{{RailModule|Thanks for editing the Final Fantasy Wiki!" -ns:2 -summary:"Thanks for editing!" -pt:0 -always
This is a somewhat complex example, so let's break this down step by step and see what each bit of text does:
python: Tells the terminal to process the rest of the command using the interpreter stored in /usr/bin/python. (Not used on Windows)add_text.py: Run the script add_text.py in the directory that the terminal's currently running in.-catr:"Final Fantasy Wikians": Work in Final Fantasy Wikians and its subcategories.-text:"{{RailModule|title=Facts|content=Thanks for editing the Final Fantasy Wiki!}}": Add a template named RailModule to the user's userpage thanking them for a good job editing.-up: Prepend the content in -text rather than appending it (which is the default setting for add_text.py).-except:"{{RailModule|Thanks for editing the Final Fantasy Wiki!": A bit of RegEx here: if the page already has the code{{RailModuleorThanks for editing the Final Fantasy Wiki!somewhere in it, skip it.-ns:2: Only work in the User: namespace.-summary:"Thanks for editing!": Leaves "Thanks for editing!" as an edit summary.-pt:0: Don't wait between making edits. By default this value is 10 (seconds).-always: Don't wait for the user to press "y" between making edits.
Note that if you need to use " inside a parameter, or | inside a RegEx, you can use the escape sequences \" or \|. This causes Python to ignore the fact that there's a " or | and continue working. Other useful escape sequences are \n (newline), \t (tab) and \\ (backslash).
The following is a list of all parameters used by multiple scripts. Some scripts have their own parameters, or even "commands", which do not start with a dash (for example, category.py).
Selection Parameters
These parameters tell the bot what pages it needs to edit.
-cat: Work on pages in a category and only that category. The subcategory pages themselves are edited, but not content inside subcategory pages. For example, -cat:"Final Fantasy Wikians" would act on Category:Sockpuppets but not User:Balthier's buddy.-cat:<categoryname>|<fromtitle>starts at "fromtitle", alphabetically in the category.-catr: Work on pages in a category and its subcategories. The "r" stands for "recursive", because these "subcategories" include the category's subcategories, subsubcategories, subsubsubcategories, etc. Therefore, it's dangerous to use this on a high-level category like Category:Images. If you want to hit every page on the wiki, use -start:!. fromtitle works with catr.-subcats: Work in a category's subcategories. This parameter is not recursive, and works with fromtitle.-subcatsr: Like -subcats but recursive.-uncat,-uncatcat,-uncatfile: Work on articles, categories, or files that are not categorized. Usually used to flag uncatted files that an inexperienced user uploaded with{{delete}}.-file: Work on all the pages in a given text file. [[Link syntax]] can delimit page names, and so can newlines.-search: Work on all the pages containing the string passed to -search:"", according to Special:Search.-links: Work on all pages that are linked to by a certain article. For example, -links:"Help:Pywikibot" works on User:Intangir Bot, Category:Bots, User:Wikia, etc.-ref: Work on all pages that link to a certain article. Probably the most useful of all selection parameters because it facilitates relinking. To see what pages link to a certain article, check Special:WhatLinksHere.-transcludes: Work on all pages that transclude some template. Main purpose is to update syntax of a template. Can also work with other namespaces, for example -transcludes:"Walkthrough:somewalkthroughtemplate".-filelinks: Work on all pages that have a certain file.-new,-newimages: Work on some number of the latest articles or files. Good if a vandal is on an article creation spree.-start: Work through articlespace alphabetically starting at the page passed to it. Primarily useful with start:! which works through the entire wiki. Non-Latin characters are alphabetized after the Latin alphabet. You can also use -start:Namespace:! which edits that namespace instead. Does not work with -ns.-prefixindex: Work on all subpages of a page.-titleregex: Work on all pages that fit a certain RegEx.-unusedfiles: Work on all files that aren't used anywhere.-usercontribs: Work on all pages edited by a certain user. Do not run unattended; Ctrl + C to end execution when you've gone through enough pages, or it'll just keep working. Particularly important to note considering some users now have almost 100,000 edits made to the Wiki.-withoutinterwiki: Work on all pages without interwikis.-random,-randomredirect: Work on however many random pages, or only pages that have some other page redirecting to them, the user specifies.-redirectonly: Just like -start, but works on redirects (not their targets).
Other Parameters
-always: Does not ask the user between each edit. If you're unsure whether a command will work, do not run this; otherwise, you usually should, so you do not have to press "y" hundreds of times just to finish a single job.-help: Prints the script's documentation.-ns: Limit your edits to only pages in a certain namespace. You can find a list of namespace IDs by openingintangirbot/families/ffwiki_family.pyin a text editor. You can also include multiple namespaces: for example, -ns:0,2,4 works in articles, User pages, and files. Does not work with -start. By default, work in every namespace.-pt: Short for putthrottle. Determines the number of seconds between edits. By default, 10. Should usually be set to 0.-summary: Gives an edit summary.-verbose: Causes the log of edits stored in intangirbot/logs to be more detailed. Useful if buggy.