Jump to content

User:ClueBot II/ClueBot Script

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by NaomiAmethyst (talk | contribs) at 02:09, 24 August 2007. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

ClueBot Script is a trivial scripting language designed specifically for very basic Wikipedia bot tasks.

Syntax

The syntax is very similar to that of PHP. Each statement must end in a semicolon (";"). Conditionals are grouped in parenthesis ("()"). Groups of statements are grouped in braces ("{}"). Variables are prefixed with a percent sign ("%").

Statements

if

Syntax

if conditional statement

Description

Executes statement if conditional is satisfied.

while

Syntax

while conditional statement

Description

Execute statement until conditional is no longer satisfied.

foreach

Syntax

foreach %list %delimiter %value statement

Description

For each item in the list in %list delimited by the delimiter in %delimiter, set %value to the value of the current item and execute statement.

set

Syntax

set %variable conditional/value

Description

Sets %variable to the value of conditional/value.

unset

Syntax

unset %variable

Description

Unsets %variable.

varappend

Syntax

varappend %variable %data

Description

Append the data in %data to the end of %variable.

varprepend

Syntax

varprepend %variable %data

Description

Prepend the data in %data to the end of %variable.

pagereplace

Syntax

pagereplaceTemplate:Fn %page %search %replace

Description

Replaces all instances of the value of %search with the value of %replace on the page name stored in %page.

pagepregreplace

Syntax

pagepregreplaceTemplate:Fn %page %search %replace

Description

Replaces all instances of the regular expression stored in %search with the value of %replace on the page name stored in %page.

pageprepend

Syntax

pageprependTemplate:Fn %page %data

Description

Prepends the data stored in %data to the end of the page name stored in %page.

pageappend

Syntax

pageappendTemplate:Fn %page %data

Description

Appends the data stored in %data to the end of the page name stored in %page.

pageset

Syntax

pagesetTemplate:Fn %page %data

Description

Sets the content of the page name stored in %page to the data stored in %data.

pageget

Syntax

pageget %page %data

Description

Retrieves the page name stored in %page into the variable %data.

Example

set %page "User:ClueBot II/Sandbox"; 
set %data "{{db-user}}"; 
set %reason "And now we mark it for deletion. (bot)";
pageset %page %data %reason;

Footnotes

  • Template:Fnb This command has an optional parameter %editsummary which can be used to set an edit summary. Otherwise, one is automatically generated.