I'm trying to implement the idea that was suggested in this edit. https://en.wikipedia.org/w/index.php?title=Wikipedia:Bots/Requests_for_approval/DYK-Tools-Bot&diff=prev&oldid=1128662960&diffmode=source
I see how I can find the existing {{DYK-Tools-Bot was here}}, with Page.templatesWithParams(). But once I've got that, how do I actually change the parameters in the wikitext?
Hi Roy,
On 12/21/22 15:37, Roy Smith wrote:
I see how I can find the existing {{DYK-Tools-Bot was here}}, with Page.templatesWithParams(). But once I've got that, how do I actually change the parameters in the wikitext?
I would recommend using mwparserfromhell directly, which makes template manipulation pretty straightforward[1]. AIUI Page.templatesWithParams() is only usable for reading template parameters.
[1] https://github.com/earwig/mwparserfromhell#usage
-- Kunal / Legoktm
Yeah, that looks like exactly what I need. Thanks.
On Dec 21, 2022, at 7:45 PM, Kunal Mehta legoktm@debian.org wrote:
Hi Roy,
On 12/21/22 15:37, Roy Smith wrote:
I see how I can find the existing {{DYK-Tools-Bot was here}}, with Page.templatesWithParams(). But once I've got that, how do I actually change the parameters in the wikitext?
I would recommend using mwparserfromhell directly, which makes template manipulation pretty straightforward[1]. AIUI Page.templatesWithParams() is only usable for reading template parameters.
[1] https://github.com/earwig/mwparserfromhell#usage
-- Kunal / Legoktm _______________________________________________ pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org