Changed the way to recognize IP edits from regex to MediaWiki propriety

This commit is contained in:
Frisk 2018-11-11 19:48:57 +01:00
parent 65db91fd13
commit 34a19f4311
No known key found for this signature in database
GPG key ID: 0E9A7D3C0A01586C

View file

@ -135,7 +135,7 @@ def webhook_formatter(action, STATIC, **params):
article_encoded = params["title"].replace(" ", "_").replace(')', '\)')
if STATIC["redirect"]:
params["title"] = "" + params["title"]
if re.match(r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b", params["user"]) is not None:
if STATIC["ipaction"]:
author_url = "https://{wiki}.gamepedia.com/Special:Contributions/{user}".format(wiki=settings["wiki"],
user=params["user"])
logging.debug("current user: {} with cache of IPs: {}".format(params["user"], recent_changes.map_ips.keys()))
@ -537,7 +537,7 @@ def first_pass(
if change["type"] == "edit" and "edit" not in settings["ignored"]:
logging.debug("List of categories in first_pass: {}".format(added_categories))
STATIC_VARS = {**STATIC_VARS, **{"color": settings["appearance"]["edit"]["color"],
"icon": settings["appearance"]["edit"]["icon"], "redirect": (True if "redirect" in change else False)}}
"icon": settings["appearance"]["edit"]["icon"], "redirect": (True if "redirect" in change else False), "ipaction": (True if "anon" in change else False)}}
webhook_formatter("edit", STATIC_VARS, user=change["user"], title=change["title"], desc=parsedcomment,
oldrev=change["old_revid"], pageid=change["pageid"], diff=change["revid"],
size=change["newlen"] - change["oldlen"], minor=True if "minor" in change else False, new_categories=added_categories)