Page MenuHomePhabricator

Implement a site generator to retrieve the abuse log
Closed, ResolvedPublicFeature

Description

Feature summary:

Implement a site generator to retrieve the abuse log. This can be implemented like

def abuselog(self, user, prop, total):
    gen = ListGenerator(listaction='abuselog',
                        site=self,
                        afluser=user,
                        aflprop=prop,
                        afllimit=total)
    return gen

See https://www.mediawiki.org/wiki/API:Abuselog

Event Timeline

import requests
from jinja2 import Template

url = "https://www.mediawiki.org/w/api.php"

params = {

"action": "query",
"list": "abuselog",
"format": "json",
"origin": "*",
"afllimit": "10",
"afldir": "newer",
"afluser": "ExampleUser",
"afltitle": "API",
"aflprop": "ids|user|action|result|timestamp|title"

}

response = requests.get(url, params=params)
data = response.json()

logs = data['query']['abuselog']

template_html = """
<!DOCTYPE html>
<html>
<head><title>Filtered Abuse Log</title></head>
<body>
<h1>Filtered Abuse Log Entries</h1>
<ul>
{% for log in logs %}

<li><strong>ID:</strong> {{ log.id }} |
    <strong>User:</strong> {{ log.user }} |
    <strong>Action:</strong> {{ log.action }} |
    <strong>Result:</strong> {{ log.result }} |
    <strong>Timestamp:</strong> {{ log.timestamp }} |
    <strong>Title:</strong> {{ log.title }}</li>

{% endfor %}
</ul>
</body>
</html>
"""

template = Template(template_html)
output_html = template.render(logs=logs)

with open("abuselog_filtered.html", "w", encoding="utf-8") as f:

f.write(output_html)

print("Filtered Abuse log page generated!")

Change #1228309 had a related patch set uploaded (by Louperivois; author: Louperivois):

[pywikibot/core@master] Implement site generator for AbuseLog and User.last_activity method

https://gerrit.wikimedia.org/r/1228309

Change #1228309 merged by jenkins-bot:

[pywikibot/core@master] Implement site generator for AbuseLog and User.last_activity method

https://gerrit.wikimedia.org/r/1228309

Xqt assigned this task to Louperivois.