This is the code for the Usage Bot on Wikimedia Commons and on the OpenStreetMap Wiki. It is based on the pywikibot framework.
To run the bot on a random Linux box, you will probably want a
suitable Python virtual environment. Run ./mkvenv venv to create a
virtual environment called venv based on requirements.txt.
You'll need a suitable user-config.py. This will need to override a
few settings from Pywikibot's config.py. You'll probably want to set:
usernames['commons']['commons']to the bot's user name on Commonsusernames['osm']['en']to the bot's user name on the OSM Wikiauthenticate['commons.wikimedia.org']to the bot's OAuth tokens (see Manual:Pywikibot/OAuth/Wikimedia)password_fileto the name of a file containing a bot password for the OSM Wikiuser_agent_descriptionto something identifying who is running the bot.
The settings relating to Commons or the OSM Wiki are only required for those wikis that the bot will be updating.
Any OAuth consumer or bot password that you create for the bot should have these grants:
- Basic rights (
basic) - High-volume editing (
highvolume) - Create, edit, and move pages (
createeditmovepage)
The usage-bot script does all the work of the bot. It takes all the
usual command-line arguments for a Pywikibot script. It also has
options that choose which source to use. These are defined in
usage_bot/__init__.py.
The main version of the bot runs on Wikimedia Toolforge. To run the bot there once you have a tool account:
- Check out the bot code under the tool account in a directory called
usage-bot. - Provide a suitable
user-config.pyin that directory. - Run
toolforge-jobs load usage-bot/jobs.yamlto install the cron jobs.