Manual:Pywikibot/BotPasswords/ja
As a simpler (but less secure) alternative to OAuth , MediaWiki allows bot users to use Bot passwords to limit the permissions given to a bot and does not require registration.
When using BotPasswords each instance gets a login_name of the form <username>@<bot suffix>
and a password.
この組み合わせでは、通常のウェブ インターフェイスではなく、API にしかアクセスできません。
要件
- ボットを使用するウィキには、MediaWiki > 1.27 が必要です。
- ほとんどのインストレーションでは、クライアント ソフトウェアは
https
プロトコルを使用するように設定されているはずです。
設定
- Log in as your bot account (if it is different from your main account).
- Generate a bot password under Special:BotPasswords (or the corresponding page on another wiki):
- Fill in a 'bot name', which is the suffix which will be added to your username. For example 'replace-on-tools'.
- Grant the relevant rights. For most Pywikibot scripts High-volume (bot) access (necessary to mark bot edits as bot), Edit existing pages and Create, edit, and move pages are enough. If you also want to upload files with the bot, include Upload new files and Upload, replace, and move files. Leave the usage restrictions as-is. Click 'create'.
- You will receive a message like The new password to log in with Valhallasw@my-botpassword-name is mysupersecretbotpassword Do not close this window until you saved the password in your password file (see below)
generate_user_files.py
スクリプトの使用-
- This script can manage for you the creation of a
user-password.py
file. Simply runpython pwb.py generate_user_files
, and follow the prompts. After the choice of a wiki, and entering your username, you'll be able to enter the name/pass couple created on Special:BotPasswords at the previous step. The name is the one you've chosen, the pass is the one given by the website.
- This script can manage for you the creation of a
- または
user-password.py
ファイルを手動作成 -
- In the directory where your
user-config.py
is, create a file calleduser-password.py
, and make it unreadable for others (chmod 600 user-password.py
) - In the file user-password.py, add a line
('Valhallasw', BotPassword('my-botpassword-name', 'mysupersecretbotpassword'))
- In user-config.py, add the line
password_file = "user-password.py"
. Note that you should only have your username in that file and leave out the suffix "@my-botpassword-name".
- In the directory where your
- その設定で動作するか確認
-
python pwb.py login
を実行します。 Pywikibot は、ボットのパスワードを使用して自動的にログインするようになるはずです:
Logging in to meta:meta as Valhallasw@my-botpassword-name Logged in on meta:meta as Valhallasw.
password_file エントリの書式
The entries in user-password.py
should be tuples with 2, 3, or 4 items:
('Username', BotPassword('BotPasswordName', 'Password'))
('FamilyName', 'Username', BotPassword('BotPasswordName', 'Password'))
- Used when the entry should only be used on a specific
FamilyName
, e.g.wikipedia
orwikisource
.
- Used when the entry should only be used on a specific
('SiteCode', 'FamilyName', 'Username', BotPassword('BotName', 'Password'))
- Used when the entry should only be used on a specific
FamilyName
andSiteCode
, e.g.wikipedia
anden
.
- Used when the entry should only be used on a specific
Entries that come later override those that come before them. 例えば、パスワード ファイルが以下を含む場合:
BotPassword エントリは https://en.wikipedia.org/ に使用されます。
('Username', 'AccountPassword')
('en', 'wikipedia', 'Username', BotPassword('BotName', 'Password'))