Help:Bots

From FORwiki

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
-
==Running your own bot==
+
{{RobotWarning}}
-
:''For what use?'' E.g. add a footer to some categorized pages,<ref>[[meta:add_text.py|add_text.py]]</ref> add some wikilinks,<ref>[[meta:replace.py|replace.py]]</ref> archive in moving old talk to subpages,<ref>[[meta:archivebot.py|archivebot.py]]</ref> edit categories,<ref>[[meta:category.py|category.py]]</ref> manage templates.<ref>[[meta:template.py|template.py]]</ref>
+
-
:::{| style="font-color:#535068; border:solid 0px #A8A8A8; background-color:#FFFFFF;font-size:75%;"
+
Two robots are available and freely useable on the English Wikisource, [[User talk:ThomasBot|ThomasBot]] and [[User talk:YannBot|YannBot]]. These bots follow [[w:regex|regex]] requests placed on their talk pages; this page explains the request syntax.
-
|[[File:Crystal Clear action run.png|40px]]
+
 
-
|<tt><references/></tt>
+
== Making a request ==
 +
Requests must be made using the {{[[:Template:Requete|Requete]]}} (French for 'request') template. The general syntax is ''<code><nowiki>{{Requete|edit summary|destination|command|parameters}}</nowiki></code>''. You can make several requests simultaneously, but the bot will do one at a time. Thus, there should only be one {{RequeteEnCours||||}} 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: {{Requete|||||}}
 +
* Bot doesn't understand: {{RequeteInvalide|||||}}
 +
* Request in progress: {{RequeteEnCours||||}}
 +
* request done: {{RequeteTerminee|||||||}}
 +
 
 +
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 [irc://browne.wikimedia.org/en.wikisource #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 summary ===
 +
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 ===
 +
The 'destination' field tells the bot which pages to edit. There are three types of destinations you can specify:
 +
* A single page: ''<nowiki>[[page name]]</nowiki>''
 +
* All pages linked from one page: ''<nowiki>links:[[page name]]</nowiki>''
 +
* All pages in a category: ''<nowiki>[[:Category:category name]]</nowiki>''
 +
 
 +
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 ===
 +
The 'command' field tells the bot what to do. Certain symbols must be escaped:
 +
{| class="prettytable"
 +
! Symbol !! Escape as
 +
|-
 +
| <nowiki>|</nowiki>
 +
| <nowiki>\|</nowiki>
 +
|-
 +
| []
 +
| \[\]
 +
|-
 +
| {}
 +
| \{\}
|}
|}
-
=== Frameworks and interfaces for bot development ===
+
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.
-
:''See '''[[API:Client Code]]'''''
+
-
MediaWiki [[API]] is for convenient access to machine-readable data.
+
-
== See also ==
+
==== DELETE ====
-
* [[meta:Bot]]
+
Removes a given string from the page: ''<code><nowiki>{{Requete|edit summary|pages|DELETE|string to delete|}}</nowiki></code>''.
 +
 
 +
==== REPLACE ====
 +
Replaces a given string: ''<code><nowiki>{{Requete|edit summary|pages|REPLACE|string to replace|string to replace with}}</nowiki></code>''.
 +
 
 +
==== REGEXP ====
 +
Replaces a given regex pattern ([http://www.amk.ca/python/howto/regex python re.sub syntax]): ''<code><nowiki>{{Requete|edit summary|pages|REGEXP|pattern|remplacement}}</nowiki></code>''.
 +
 
 +
====TEXT, TEXTE====
 +
Put the content of a page in <nowiki><div class=text></nowiki>,
 +
unless the class already exists in the page:
 +
 
 +
''<code><nowiki>{{Requete|edit summary|pages|TEXT}}</nowiki></code>''.
 +
 
 +
====NAVIGATEUR====
 +
Adds a navigation template to subpages of a given page: ''<code><nowiki>{{Requete|edit summary|page|NAVIGATEUR}}</nowiki></code>''.
 +
 
 +
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 ====
 +
Splits a page into subpages from second-level sections (<nowiki>== foo ==</nowiki>). How it names pages depends on the syntax:
 +
{| class="prettytable"
 +
|-
 +
! syntax
 +
! Naming
 +
|-
 +
| ''<code><nowiki>{{Requete|edit summary|page|SPLIT}}</nowiki></code>''
 +
| work title + name of sections
 +
|-
 +
| ''<code><nowiki>{{Requete|edit summary|page|SPLIT| }}</nowiki></code>''
 +
| work title + number (add a space as last parameter)
 +
|-
 +
| ''<code><nowiki>{{Requete|edit summary|page|SPLIT|name of divisions}}</nowiki></code>''
 +
| work title + "name of divisions" (ie, 'Chapter') + number
 +
|-
 +
| ''<code><nowiki>{{Requete|edit summary|page|SPLIT|NOPREFIX}}</nowiki></code>''
 +
| name of sections only (not subpages)
 +
|}
-
{{Admin tip|tip=<br>
+
Notes:
-
*[[Manual:User rights management]] for setting bot access.
+
* If the request has no results, it's probably because the page is split into third-level sections (<nowiki>=== foo ===</nowiki>) instead of second-level sections (<nowiki>== foo ==</nowiki>).
-
*[[:mw:robots.txt|robots.txt]] tells external web robots how to index your site.
+
* 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).
-
*[[Extension:MassEditRegex]] - to allow regular expression edits through a special page.
+
* 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.

Revision as of 10:55, 14 October 2009

Template:RobotWarning

Two robots are available and freely useable on the English Wikisource, ThomasBot and YannBot. These bots follow regex requests placed on their talk pages; this page explains the request syntax.

Contents

Making a request

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 Template:RequeteEnCours on the page at any one time, unless you make a mistake. The bot updates the template to show the status of the request:

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 summary

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

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

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

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

REPLACE

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

REGEXP

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

TEXT, TEXTE

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

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

NAVIGATEUR

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

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.
Personal tools