User:JJMC89 bot III/tasks/CFDW

This task processes WP:CFD closes that are listed at WP:CFD/W and WP:CFD/W/L.

Process

 * The working page must have full (sysop) edit protection.
 * The bot can only recategorize when a page is categorized using category syntax.
 * 1) The bot iterates over each section of the page using the section header to determine the mode.
 * 2) Within a section the bot iterates over each line if wikitext.
 * 3) * Each line consists of three parts: prefix, wikilinks/templates, and suffix. Everything else is ignored.
 * 4) ** All wikilinks on the line
 * 5) *** They must be to a CfD page or a category. The bot will not process the rest of the section if any other wikilink is found.
 * 6) *** If a CfD link does not contain a section, the bot will attempt figure it out based on the linked CfD page.
 * 7) ** c, cl, and lc can be used to link categories. All other templates are ignored.
 * 8) ** The prefix is the plain text at the beginning of the line.
 * 9) *** The prefix on a line with a CfD link applies to all lines until the next CfD link.
 * 10) *** If the prefix contains "NO BOT" (case sensitive), the bot will not queue it. (These should be placed on WP:CFD/W/M instead.)
 * 11) ** The suffix is the plain text at the end of the line.
 * 12) *** The suffix on a line with a CfD link applies to all lines until the next CfD link unless that line has a suffix.
 * 13) If a CfD link was found and there is at least one category link is on the line, the bot will queue the request.
 * 14) After queueing the entire page, the bot will remove any conflicting requests and requests involving disambiguation categories from the queue and then check and process the remaining requests.

Empty mode

 * The bot removes the category from all pages and deletes the empty category.
 * Checks:
 * There must be one category on the line.

Merge mode

 * The bot merges the category to one or more target categories and deletes the empty category.
 * If the prefix contains "REDIRECT" (case sensitive) and there is a single merge target, then the bot will redirect the category to the target using category redirect instead of deleting it and add old CfD to the talk page.
 * Checks:
 * The current category cannot be a merge target.
 * There must be one or more merge targets on the line.
 * All merge targets must exist and not be a redirect.

Move mode

 * The bot moves the category to a target category without leaving a redirect and removes the template.
 * If the prefix contains "REDIRECT" (case sensitive), then the bot will leave a redirect.
 * Checks:
 * The current category cannot be the move target.
 * There must be one move target on the line.
 * If the current category is a redirect, then the target must exist.
 * The target must not be a redirect.

Retain mode

 * The bot removes the template and adds old CfD to the talk page.
 * If the suffix does not contain the discussion action and result for, the bot will attempt figure them out based on the linked CfD page.
 * On the working page, the action/result must be one of the following.
 * no consensus (for|to) action
 * not action
 * keep (The action is assumed to be delete.)
 * Checks:
 * There must be one category on the line.
 * There must be an action and result (on the line or bot detected).