Jump to: navigation, search

Other languages:
català • ‎English • ‎español • ‎suomi • ‎français • ‎italiano • ‎日本語 • ‎português • ‎русский
Wikimedia Git repository has this file: scripts/ is the python program that logs the user running the pywikipedia bot on to the system using the data that can be found in user-config.pyManual:Pywikibot/

Login as a bot[edit]

Bots provide specified result and as a consequence, they should not need the attention that other changes require. By having a specific user to run the bot software, the changes created in this way will be hidden on a typical recent changes screen. Bot status is given when a community is in favour with someone running a bot.

If you want to login also with your sysop account (deleting moved categories...) you have to add

sysopnames['wikiproject']['languagecode'] = u'YourSysopUsername'

to and start with the -sysop parameter

How it knows where to login[edit]

In the file there are three components:

  1. the language: mylang
  2. the family: family - this indicates wiki name, including wikipedia or wiktionary
  3. the username: username - this can be any user but it should be a user who is registered to run as a bot.

In order to login to all the projects/languages mentioned in, the option -all can be used, and if the same password is used throughout all these projects, it can be combined with -pass so that the program doesn't ask for a password for each site.

python -all -pass

will login on all projects in, using the same password for all. For now, using -pass option is not supported. (T102477) You should use password file instead. Create file with text like '("en", "wikipedia", "User", "password")' (you can use more than one line). Then, insert in your file 'password_file = "path_to_password_file"' line. After this Pywikibot should use data from this file when he need to login.


python login -logout

Login using OAuth[edit]

Pywikibot supports login using OAuth authentication instead of password. The OAuth feature needs the site with Extension:OAuthExtension:OAuth installed and configured properly. OAuth is more secure (passwords are not sent over the internet, can be invalidated at any time, and the permissions of the bot user can be restricted) and should generally be preferred over normal login. See Manual:Pywikibot/OAuthManual:Pywikibot/OAuth on how to use it (it does not involve

If for some reason you want to log your bot in as a multi-user OAuth app (not recommended, but e.g. older MediaWiki might not support owner-only apps), you can use for that, with the option -oauth. The process contains the following steps:

  1. Create OAuth app at Special:OAuthConsumerRegistration/propose on meta if it does not exist yet, and record the consumer key and secret
  2. Run python -oauth
  3. Input OAuth consumer key
  4. Input OAuth consumer secret
  5. Authenticate user via web browser. You may need to manually copy the url from the terminal if the web browser doesn't open up automatically.
  6. Input response query string to terminal when authentication succeeds. E.g.: oauth_verifier=xxx&oauth_token=yyy
  7. Copy and paste authentication entry generated into user-config.pyManual:Pywikibot/

Note Note: -logout, -pass, -force, -pass:XXXX and -sysop are not compatible with -oauth.

Global arguments available for all bots

These options will override the configuration in settings.

Name Description Default/config name compat core
-dir:PATH Read the bot's configuration data from directory given by PATH, instead of from the default directory.
-lang:xx Set the language of the wiki you want to work on. xx should be the language code. mylang
-family:xyz Set the family of the wiki you want to work on, e.g. wikipedia, wiktionary, commons, wikitravel, …. family
-user:xyz Log in as user 'xyz' instead of the default username.
-daemonize:xyz Immediately return control to the terminal and redirect stdout and stderr to xyz (only use for bots that require no input from stdin).
-help Show a help text for the invoked script.
-log Enable the logfile. Logs will be stored in the logs subdirectory.
-log:xyz Enable the logfile, using xyz as the filename.
-nolog Disable the logfile (if it's enabled by default).
-maxlag Sets a new maxlag parameter to a number of seconds. Defer bot edits during periods of database server lag. maxlag
Enable the logfile and include extensive debugging data for component "item" (for all components if the second form is used).
Set the minimum time (in seconds) the bot will wait between saving pages. put_throttle
Make the program output more detailed messages than usual to the standard output about its current work, or progress, while it is proceeding. This may be helpful when debugging or dealing with unusual situations. not selected
Toggles the cosmetic_changes setting made in or to its inverse and overrules it. All other settings and restrictions are untouched. not selected
-simulate Disables writing to the server. Useful for testing and debugging of new code (if given, doesn't do any real changes, but only shows what would have been changed).
-<config_var>:n You may use all given numeric config variables as option and modify it with command line.
For instance, the delay config variable can be set using -delay:1 so that the cooldown period would be 1 days (as opposed to the default of 7 days).

See also[edit]