Jump to content

User:ThomasBot/Help:Bots

From Wikisource

WARNING

Some commands can change many pages. The consequences of an error are under your responsibility!

After an error, it is sometimes possible to correct mistakes using the bot, but not always!

Before using the replace and regexp commands to many pages, it is strongly advised to test them first on one page.

Once a request is launched, it can't be stopped. It is therefore useless to write on the template Request being processed (when the line is yellow), as this does not change the bot behaviour, except that it won't know where to write the results.


One robot is available and freely useable on the English Wikisource: ThomasBot. This bot follows regex requests placed on its talk pages; this page explains the request syntax.

Making a request

[edit]

Requests must be made using the {{Requete}} (French for 'request') template. The general syntax is {{Requete|edit summary|destination|command|parameters}}. You can make several requests simultaneously, but the bot will do one at a time. Thus, there should only be one Request being processed: on the page at any one time, unless you make a mistake. The bot updates the template to show the status of the request:

  • Request not yet begun: Request by  :
  • Bot doesn't understand:
    Invalid request:
  • Request in progress: Request being processed:
  • request done: Done: Waiting time: s. Runtime: s. pages were modified.

If the bot does not respond, it is probably not enabled. To find out if it is currently enabled, see whether it is in the IRC channel #en.wikisource (Wikimedia). Alternately, it may simply be busy with another request, as it is used on several wikis. If that is the case, be patient.

Syntax

[edit]

Edit summary

[edit]

The 'edit summary' field is the edit summary used by the bot. Please note your name (without a pipe '|' symbol) in this field as well. For example, "removed category (request by ThomasV)".

Destination

[edit]

The 'destination' field tells the bot which pages to edit. There are three types of destinations you can specify:

  • A single page: [[page name]]
  • All pages linked from one page: links:[[page name]]
  • All pages in a category: [[:Category:category name]]

Notes:

  • The commands NAVIGATEUR, SPLIT, and IMPORT will only work if a single page is specified.
  • The bot will ignore any page outside the articlespace.

Command

[edit]

The 'command' field tells the bot what to do. Certain symbols must be escaped:

Symbol Escape as
| \|
[] \[\]
{} \{\}

When using these symbols literally in regular expressions, they need to be double-escaped: \\[\\], \\{\\}, and \\|. In regex and replace commands, \L is replaced by the name of the link that was followed to access the page.

DELETE

[edit]

Removes a given string from the page: {{Requete|edit summary|pages|DELETE|string to delete|}}.

REPLACE

[edit]

Replaces a given string: {{Requete|edit summary|pages|REPLACE|string to replace|string to replace with}}.

REGEXP

[edit]

Replaces a given regex pattern (python re.sub syntax): {{Requete|edit summary|pages|REGEXP|pattern|remplacement}}.

TEXT, TEXTE

[edit]

Put the content of a page in <div class=text>, unless the class already exists in the page:

{{Requete|edit summary|pages|TEXT}}.

[edit]

Adds a navigation template to subpages of a given page: {{Requete|edit summary|page|NAVIGATEUR}}.

Note that after using this function, it may be necessary to make a DELETE request to eliminate redundant strings separating the title and the chapter number (for example, " - ").

SPLIT

[edit]

Splits a page into subpages from second-level sections (== foo ==). How it names pages depends on the syntax:

syntax Naming
{{Requete|edit summary|page|SPLIT}} work title + name of sections
{{Requete|edit summary|page|SPLIT| }} work title + number (add a space as last parameter)
{{Requete|edit summary|page|SPLIT|name of divisions}} work title + "name of divisions" (ie, 'Chapter') + number
{{Requete|edit summary|page|SPLIT|NOPREFIX}} name of sections only (not subpages)

Notes:

  • If the request has no results, it's probably because the page is split into third-level sections (=== foo ===) instead of second-level sections (== foo ==).
  • The last parameter (for example, "chapter") is optional. If it is omitted, the bot will use the section names to create the subpage names. If it is not omitted, the subpages are created based on it plus a number (ie, "Chapter 3"). If NOPREFIX is used, the bot creates the pages in their own name (not as subpages).
  • If a target page already exists, the bot will check whether it is the same as the content to split. If so, it skips the section; otherwise, it creates a new page with the same name followed by a number.
  • Sometimes page creation will fail, for example if the servers return an error. This will lead to redlinks on the main page; if this is the case, you can revert the changes to the main page and resubmit the SPLIT request. You should not change any of the subpages, otherwise the bot will create duplicates (see point above).
  • The bot will not create pages if the sections to split are empty, but will add a redlink to the main page.


Example uses:

  • Add chapter titles;
  • Add quality indicators: {{Requete|add quality indicators (ThomasV)|source|collect|\\{\\{PageQuality\\|(.*?)\\}\\}|\[\[Image:([0-9]*?)%.png\]\]|}}.