RationalWiki:Bots

{{shortcut|RW:BOT}}
'''Bots''' (short for "robots") are (usually small) computer programs/scripts created to perform repetitive tasks or to ease routine maintenance of a website.

On wikis ''Bot'' is a class of user which is usually such a program, although some users have Bot alteregos or [[RW:Ninja|make themselves technically bots]] so that repetitive tasks won't clog up [[Special:RecentChanges]]. 

A current list of RW's bots [[Special:ListUsers/bot|can be found here]] (there are {{NUMBERINGROUP:Bot}}). Any of these which are generally applicable ''should'' have usage instructions on their user page.

==Active bots==

===[[User:Edit filter|Edit filter]]===
Blocks people who trigger certain [[RationalWiki:Edit filter|edit filters]].

===[[User:Inferno Bot|Inferno Bot]]===
The fifth incarnation of a talkpage archival bot. Configurable with a template. See userpage for instructions.

==Old bots==
{{collapse}}
===[[User:Archiver|Archiver]]===
Approximately the fourth incarnation of a talk page archiving bot. Works the same as the others.

==={{u|Archivist}}===
Archives talkpages. See userpage for full instructions and details -- including how to run it, if {{u|FuzzyCatPotato}} ever disappears.

==={{u|CaptureBot4}}===
Captures links as an image and/or on archive.is.

To capture it as an image and archive.is:

:<nowiki><capture>http://example.com</capture></nowiki> will produce: <capture>http://example.com</capture>. After a while the bot will find the red <sup>img</sup> link and upload a file there.

For only archive.is:

:<nowiki>{{a|http://example.com|Example site}}</nowiki> will produce: {{a|http://example.com|Example site}}

Full instructions on user page.

==={{u|MummificationBot}}===
Archives old discussions, like Pibot did for many years. It should work the same as pibot, and pages that previously used pibot should™ work.

Basic instructions; copy/paste this at the top of a talkpage:

 <nowiki>{{Talkpage/Pibot
|algo = old(30d)
|archive = {{subst:NAMESPACE}}:{{subst:PAGENAME}}/Archive%(counter)d
}}</nowiki>

Full instructions on user page.

==={{u|RedirectBot}}===
Fixes double redirects and removes broken redirects.

==={{u|WigoBot}}===
Archives old WIGO entries.
{{collapse end}}

==How to make your own==
You can talk to the API at [http://rationalwiki.org/w/api.php http://rationalwiki.org/w/api.php]. See the [https://www.mediawiki.org/wiki/API MediaWiki help pages].

===Pywikibot===
It's probably easiest to use a framework like [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot Pywikibot]. You want to use the new "core" version, not the old "compat".

===Getting started===

Follow the [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/Installation installation instructions] to install Pywikibot & dependencies (note: some systems also have packages for Pywikibot: [https://aur.archlinux.org/packages/python2-pywikibot-git/] [http://www.freshports.org/www/py-pywikibot/]).

Now create the <code>rationalwiki</code> family; this will tell Pywikibot how to interact with the RationalWiki API:

 python3.4 generate_family_file.py http://rationalwiki.org/wiki/Main_Page rationalwiki

will give you a family file in <code>pywikibot/families/rationalwiki_family.py</code>. The default will do fine for most cases.

You'll need to edit the <code>user-config.py</code>:
 mylang = 'en'
 family = 'rationalwiki'
 usernames['rationalwiki']['en'] = 'MummificationBot'
Finally, test your setup with <code>python pwb.py login</code>, which should prompt for the login password for your bot, and then output <code>Logged in on somewiki:lang as bot username.</code> The password should be remembered.

===Multiple accounts===
Pywikibot only supports a single account name; for separate accounts you could use something along the lines of this in your <code>user-config.py</code>:

 import os, sys
 
 mylang = 'en'
 family = 'rationalwiki'
 user = os.getenv('RW_USER')

 valid = {
     'MummificationBot': 'store password here if you want',
     'RedirectBot': 'store password here if you want',
 }
 
 if user not in valid.keys():
     print('No such user; valid users: {}'.format(valid.keys()))
     sys.exit(1)
 
 print(user)
 usernames['rationalwiki']['en'] = user
 
 del user
 del valid

Now just set the <code>RW_USER</code> environment variable before running the script:

 RW_USER=MummificationBot python pwb.py login

An alternative is using separate Pywikibot directories (this is the [https://en.wikibooks.org/wiki/Pywikibot/Development#Multiple_accounts documented way], but a bit silly).

[[Category:User rights]]
[[Category:RationalWiki bots| ]]
[[Category:Help]]
{{Helpnav}}
{{Help:Index/indexer|keyword=Robot}}{{Help:Index/indexer|keyword=Bot}}{{Help:Index/indexer|keyword=Automation}}{{Help:Index/indexer|keyword=Python}}{{Help:Index/indexer|keyword=Stubbot}}{{Help:Index/indexer|keyword=Personal bot}}

Categories: User rights, RationalWiki bots, Help