JJMC89 added a comment.
`{{nobots}}` should not have parameters per
https://en.wikipedia.org/wiki/Template:Bots#Syntax, so it should be
`{{bots|allow=Foo}}` instead of `{{nobots|allow=Foo}}`.
If we follow that, then the code could be:
[...]
for template, params in templates:
title = template.title(with_ns=False)
if restrictions and title in restrictions:
return False
if title == 'Nobots':
return False
[...]
If we're going (or intend) to parse `{{nobots}}` parameters the same as
`{{bots}}` parameters, then the code could be:
[...]
for template, params in templates:
title = template.title(with_ns=False)
if restrictions and title in restrictions:
return False
if title not in {'Bots', 'Nobots'}:
continue
if not params:
return title == 'Bots'
(ttype, bots) = [part.strip() for part in params[0].split('=',
1)]
bots = [bot.strip() for bot in bots.split(',')]
if ttype == 'allow':
return 'all' in bots or username in bots
if ttype == 'deny':
return not ('all' in bots or username in bots)
if ttype == 'allowscript':
return ('all' in bots or pywikibot.calledModuleName() in
bots)
if ttype == 'denyscript':
return not ('all' in bots
or pywikibot.calledModuleName() in bots)
# no restricting template found
return True
I'd go for the first one. Other bots that implement this as shown at
https://en.wikipedia.org/wiki/Template:Bots#Example_implementations will not
support `{{nobots}}` with parameters. On the English Wikipedia such cases are
reported as broken.
TASK DETAIL
https://phabricator.wikimedia.org/T253709
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: JJMC89
Cc: JJMC89, Aklapper, Liuxinyu970226, russblau, pywikibot-bugs-list,
JohnsonLee01, Dijkstra, Zkhalido, Viztor, Wenyi, Tbscho, MayS, Mdupont,
Dvorapa, Altostratus, Avicennasis, mys_721tx, jayvdb, Masti, Alchimista, Rxy
_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs