More actions
Archive and examples of past summaries at User talk:Botgo50/weekly summaries.
Signup at User:Botgo50/Signup!
Code[[edit] | [edit source]]
# update_links.py # version 1.0.0 # written by User:Bongolium500 for use on User:Botgo50 at tardis.fandom.com import pywikibot from pywikibot import Timestamp from pywikibot import pagegenerators from datetime import date from datetime import timedelta today = date.today() site = pywikibot.Site() edits = len([edit for edit in site.recentchanges(reverse=True, start=Timestamp.fromtimestampformat((today - timedelta(days=7)).strftime('%Y%m%d')), changetype="edit")]) newPages = len([page for page in site.recentchanges(reverse=True, start=Timestamp.fromtimestampformat((today - timedelta(days=7)).strftime('%Y%m%d')), changetype="new")]) stats = f"There have been {edits + newPages} edits in the last week, including {newPages} new pages." print("Stats generated") newForums = [page for page in site.recentchanges(reverse=True, start=Timestamp.fromtimestampformat((today - timedelta(days=7)).strftime('%Y%m%d')), namespaces="Forum", changetype="new", redirect=False) if "/" not in page["title"]] newForumsList = "" for page in newForums: categories = [category for category in pywikibot.Page(site, page["title"]).categories()] categories += "The Cloisters|Uncategorised" newForumsList += f"* [[{page['title']}]] by [[User:{page['user']}]] in [[Forum:{categories[0].title(with_ns=False)}]]\n" print("New forums list generated") closedForums = [page["title"] for page in site.recentchanges(reverse=True, start=Timestamp.fromtimestampformat((today - timedelta(days=7)).strftime('%Y%m%d')), namespaces="Forum", changetype="edit", top_only=True, redirect=False) if "/" not in page["title"] and ("Archive" in [template.title(with_ns=False) for template in pywikibot.Page(site, page["title"]).itertemplates()] or "Closingpostpending" in [template.title(with_ns=False) for template in pywikibot.Page(site, page["title"]).itertemplates()])] closedForumsList = "" for page in closedForums: extra = "" if "Closingpostpending" in [template.title(with_ns=False) for template in pywikibot.Page(site, page).itertemplates()]: extra = " (closing post pending)" closedForumsList += f"* [[{page}]]{extra}\n" print("Closed forums list generated") editedTalks = [page["title"] for page in site.recentchanges(reverse=True, start=Timestamp.fromtimestampformat((today - timedelta(days=7)).strftime('%Y%m%d')), namespaces="Talk|Tardis talk|File talk|MediaWiki talk|Template talk|Help talk|Category talk|Forum talk|Howling talk|Theory talk|Transmat talk|Thread talk|Property talk|Form talk|Concept talk|smw/schema talk|Rule talk|GeoJson talk|Blog talk|Module talk|Gadget talk|Gadget definition talk|Map talk", changetype="edit", top_only=True, redirect=False) if "/Archive" not in page["title"]] editedTalksList = "" for page in editedTalks: editedTalksList += f"* [[{page}]]\n" print("Edited talks list generated") message = f''' == Tardis weekly summary - {today.strftime('%Y-%m-%d')} == Here is your automated weekly summary for {today.strftime('%Y-%m-%d')}, showing changes since {(today - timedelta(days=7)).strftime('%Y-%m-%d')}: {stats} === New forums threads === {newForumsList} === Closed forum threads === <small>May include false positives.</small> {closedForumsList} === Talk page activity === <small>May include false positives.</small> <div style="{{{{Column-count|3}}}}"> {editedTalksList}</div> [[User:Botgo50/Signup|Signup]]! - ~~~~ ''' print(message) archivePage = pywikibot.Page(site, 'User talk: Botgo50/weekly summaries') print(f"Handling {archivePage.title()}") text = archivePage.get() text += message archivePage.put(text, f"Weekly summary for {today.strftime('%Y-%m-%d')}") for talk in pagegenerators.LinkedPageGenerator(pywikibot.Page(site, 'User:Botgo50/Signup')): if talk.namespace() == pywikibot.site._namespace.Namespace(3): print(f"Handling {talk.title()}") text = talk.get() text += message talk.put(text, f"Weekly summary for {today.strftime('%Y-%m-%d')}")