https://github.com/ketho/wowpediadoc
API documenter for Warcraft Wiki
https://github.com/ketho/wowpediadoc
lua world-of-warcraft
Last synced: 6 months ago
JSON representation
API documenter for Warcraft Wiki
- Host: GitHub
- URL: https://github.com/ketho/wowpediadoc
- Owner: Ketho
- License: mit
- Created: 2020-04-11T16:33:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-21T19:42:19.000Z (6 months ago)
- Last Synced: 2025-04-30T06:44:41.020Z (6 months ago)
- Topics: lua, world-of-warcraft
- Language: Lua
- Homepage: https://warcraft.wiki.gg/wiki/World_of_Warcraft_API
- Size: 3.69 MB
- Stars: 11
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README-pywikibot.md
- License: LICENSE
Awesome Lists containing this project
README
## Pywikibot
[Pywikibot](https://github.com/wikimedia/pywikibot) is useful for automating tasks on wikis like editing pages.
## Resources
- https://warcraft.wiki.gg/wiki/Warcraft_Wiki:Wiki_bots
- https://help.fandom.com/wiki/Bots
- https://en.wikipedia.org/wiki/Help:Creating_a_bot
## Creating a bot account
Create a new user account (e.g. [KethoBot](https://warcraft.wiki.gg/wiki/Special:Contributions/KethoBot)) and request the admins to give it the [bot role](https://warcraft.wiki.gg/wiki/Special:ListUsers?group=bot). Note that you need a certain amount of trust to request a bot account. You can still set up pywikibot but will not be able to edit and create pages without logging in.
### Bot passwords
Pywikibot requires a bot password which can be set in `user-password.py`
- https://warcraft.wiki.gg/wiki/Special:BotPassword
- https://www.mediawiki.org/wiki/Manual:Pywikibot/BotPasswords
There you will also be able to set grants (user rights) for it, like editing and creating pages.
## Setup
Create a virtual environment and install pywikibot.
```sh
sudo apt install python3-venv
python3 -m venv .venv
source .venv/bin/activate
pip install requests wikitextparser
pip install pywikibot
```
## Configuration
I put `user-config.py` and `user-password.py` in the root of the repository and gitignored them but there probably is a more proper way to do this.
### `user-config.py`
```py
family = 'warcraftwiki'
mylang = 'en'
usernames['warcraftwiki']['en'] = 'KethoBot'
password_file = "user-password.py"
```
### `user-password.py`
```py
('KethoBot', BotPassword('Hatsune', ''))
```
### `warcraftwiki_family.py`
I copied this file to `.venv/lib/python3.12/site-packages/pywikibot/families`
```py
from pywikibot import family
class Family(family.FandomFamily):
name = 'warcraftwiki'
domain = 'warcraft.wiki.gg'
codes = {'en'}
```
## Usage
Test if it works by printing a page, for example [API_UnitLevel](https://warcraft.wiki.gg/wiki/API_UnitLevel)
```sh
python 'Pywikibot/hello-read.py'
```
```py
import pywikibot
site = pywikibot.Site("en", "warcraftwiki")
page = pywikibot.Page(site, "API_UnitName")
print(page.text)
```
```
{{wowapi|t=a|system=Unit}}
Returns the level of the unit.
level = UnitLevel(unit)
==Arguments==
:;unit:{{apitype|string}} : [[UnitId]] - For example "player" or "target"
==Returns==
:;level:{{apitype|number}} - The unit level. Returns -1 for boss units or hostile units 10 levels above the player (Level ??).
```
Login and try editing a page, for example https://warcraft.wiki.gg/wiki/Warcraft_Wiki:Sandbox/6
```sh
pwb login
python 'Pywikibot/hello-save.py'
```
```py
import pywikibot
site = pywikibot.Site("en", "warcraftwiki")
page = pywikibot.Page(site, "Warcraft_Wiki:Sandbox/6")
page.text = "hello pywikibot"
page.save(summary = "Some test")
```