Skip to content

Commit 76a16c2

Browse files
author
peter
committed
make mgp specific changes
1 parent a5ef4a4 commit 76a16c2

5 files changed

Lines changed: 35 additions & 9 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
.DS_Store
12
throttle.ctrl
23
pywikibot.lwp
3-
user-*.py
44
*.bak
55
*.pyc
66
*.pyo
@@ -19,6 +19,7 @@ logs*
1919
.idea
2020
pywikibot.egg-info/
2121
build
22+
env/
2223
dist
2324
docs/_build/
2425
/scripts/userscripts/*

pywikibot/bot.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ class is mainly used for bots which work with Wikibase or together
272272
:mod:`pywikibot.userinterfaces` subpackage.
273273
"""
274274

275+
default_tags = "Automation tool" # type: str
276+
"""
277+
Default tag in an edit
278+
"""
275279

276280
def set_interface(module_name: str) -> None:
277281
"""Configures any bots to use the given interface module.
@@ -886,6 +890,9 @@ def handle_args(args: Optional[Iterable[str]] = None,
886890
option, _, value = arg.partition(':')
887891
if do_help_val is not False and option == '-help':
888892
do_help_val = value or True
893+
elif option == '-tags':
894+
global default_tags
895+
default_tags = value
889896
elif option == '-dir':
890897
pass
891898
elif option == '-site':
@@ -1471,7 +1478,7 @@ def _save_page(self, page: 'pywikibot.page.BasePage',
14711478
ignore_server_errors = kwargs.pop('ignore_server_errors', False)
14721479

14731480
try:
1474-
func(*args, **kwargs)
1481+
func(*args, **kwargs, tags=default_tags)
14751482
self.counter['write'] += 1
14761483
except PageSaveRelatedError as e:
14771484
if not ignore_save_related_errors:

user-config.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
mylang = 'mgp'
2+
family_files['mgp'] = 'https://mzh.moegirl.org.cn/api.php'
3+
family = 'mgp'
4+
# Your username here
5+
usernames['mgp']['*'] = 'Lihaohong'
6+
password_file = "user-password.py"
7+
8+
# Slow down the robot such that it never requests a second page within
9+
# 'minthrottle' seconds. This can be lengthened if the server is slow,
10+
# but never more than 'maxthrottle' seconds. However - if you are running
11+
# more than one bot in parallel the times are lengthened.
12+
#
13+
# 'maxlag' is used to control the rate of server access (see below).
14+
# Set minthrottle to non-zero to use a throttle on read access.
15+
minthrottle = 3
16+
maxthrottle = 20
17+
18+
# Slow down the robot such that it never makes a second page edit within
19+
# 'put_throttle' seconds.
20+
put_throttle = 20 # type: Union[int, float]
21+
22+
# Sometimes you want to know when a delay is inserted. If a delay is larger
23+
# than 'noisysleep' seconds, it is logged on the screen.
24+
noisysleep = 3.0

user-config.py.sample

Lines changed: 0 additions & 7 deletions
This file was deleted.

user-password.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
('mgp', 'mgp', 'Lihaohong', BotPassword('PetraMagna', ''))

0 commit comments

Comments
 (0)