User:Odessaukrain/pythonbot

From Meta, a Wikimedia project coordination wiki

Configuration for Wikipedia[edit]

Open a text file. (Notepad.txt is a text file editor)

Save the text file as user-config.py, in the pywikipedia/families folder, with all of the other .py files.

Add the following lines to user-config.py:

Code Explanation
mylang = 'xx'

xx is the code for the language code you are working on, "en" is English.[1]

usernames['wikipedia']['en'] = u'ExampleBot'[2]

Your user-config.py file needs to specify the bot's username.

In this example, the user is working on English Wikipedia, and has created a bot account with the username "ExampleBot".

(Optional)

usernames['wikipedia']['de'] = u'BeispielBot'
usernames['wikipedia']['en'] = u'ExampleBot'
usernames['wiktionary']['de'] = u'BeispielBot'

(Optional)

If you are working on more than one wikipedia project, you can also add several other usernames.

Now save user-config.py again.

Configuration for other MediaWiki wikis[edit]

Open a text file. (Notepad.txt is a text file editor)

Save the text file as user-config.py, in the pywikipedia/families folder, with all of the other .py files.

Add the following three required lines to user-config.py:

Code Explanation
mylang = 'xx'

xx is the code for the language code you are working on, "en" is English.[1]

family = 'sitename'

"Sitename" is the name of the site you're working on.

Currently, this can be wiktionary, wikibooks, wikiquote, as well as some non-Wikimedia projects like wikitravel (the full list is found in the pywikipedia/families folder).

usernames['memoryalpha']['en'] = u'ExampleBot'

Your user-config.py file needs to specify the bot's username.

For example, if you want to work on the English Memory Alpha, and you have created a bot account with username "ExampleBot".

(For Wikimedia Commons only)

mylang='commons'
family='commons'
usernames['commons']['commons']='UserBot'

(For Wikimedia Commons only)

If you work on Wikimedia Commons, specify commons both as language and as family.

Now save user-config.py again.

If your wiki is not listed in the families folder, create your own families .py file, see Pywikipedia bot on non-Wikimedia projects.

  1. a b If you want to work with more than one language, choose the most common one, as you can override configured value in command line by -lang parameter.
  2. The 'u' in front of the username stands for Unicode. The 'u' is important if your username contains non-ASCII characters. If you are using ASCII characters only, you can remove the 'u' (if you have troubles loging in with your bot, otherwise you can leave the 'u' as is).