Pywikibot: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 32: | Line 32: | ||
</pre> | </pre> | ||
This is where you will put your custom family file. | This is where you will put your custom family file. Here's what the custom family file looks like: | ||
<pre> | |||
from pywikibot import family | |||
class Family(family.Family): | |||
def __init__(self): | |||
family.Family.__init__(self) | |||
self.name = 'charlesreid1' | |||
self.langs = { | |||
'en': 'charlesreid1.com', | |||
} | |||
</pre> | |||
Copy and paste this into <code>pwb/pywikibot/families/charlesreid1_family.py</code> (where pwb is the name of the directory where you checked out the git repository). | |||
Now you should be able to log into the wiki as your bot: | |||
<pre> | |||
$ python pwb.py login | |||
Password for user Bleep bloop on charlesreid1:en (no characters will be shown): | |||
</pre> | |||
Revision as of 02:56, 16 April 2017
Setting this up is confusing as hell, mainly because the documentation sucks.
Code for pywikibot on Github: https://github.com/wikimedia/pywikibot-core/
Start by checking it out:
$ git clone https://github.com/wikimedia/pywikibot-core/ pwb $ cd pwb
Install all the pip stuff that you may need:
$ pip install -r requirements.txt
Update git submodules:
$ git submodule update --init
Add a custom family file to the big directory of family files:
$ ls pywikibot/families ... wikivoyage_family.py wiktionary_family.py wowwiki_family.py
This is where you will put your custom family file. Here's what the custom family file looks like:
from pywikibot import family
class Family(family.Family):
def __init__(self):
family.Family.__init__(self)
self.name = 'charlesreid1'
self.langs = {
'en': 'charlesreid1.com',
}
Copy and paste this into pwb/pywikibot/families/charlesreid1_family.py (where pwb is the name of the directory where you checked out the git repository).
Now you should be able to log into the wiki as your bot:
$ python pwb.py login Password for user Bleep bloop on charlesreid1:en (no characters will be shown):