A few important bugfixed to prevent crashes from hidden actions

This commit is contained in:
Frisk 2019-04-19 01:49:22 +02:00
parent 3b37bd5b48
commit 9f2c72fad9
No known key found for this signature in database
GPG key ID: 0E9A7D3C0A01586C

View file

@ -158,6 +158,7 @@ def link_formatter(link):
return "<"+re.sub(r"([ \)])", "\\\\\\1", link)+">"
def compact_formatter(action, change, parsed_comment, categories):
if action != "suppressed":
author_url = link_formatter("https://{wiki}.gamepedia.com/User:{user}".format(wiki=settings["wiki"], user=change["user"]))
author = change["user"]
parsed_comment = "" if parsed_comment is None else " *("+parsed_comment+")*"
@ -428,7 +429,6 @@ def compact_formatter(action, change, parsed_comment, categories):
elif action == "suppressed":
link = "<https://{wiki}.gamepedia.com/>".format(wiki=settings["wiki"])
content = _("An action has been hidden by administration.")
print(content)
send_to_discord({'content': content})
def embed_formatter(action, change, parsed_comment, categories):
@ -437,6 +437,7 @@ def embed_formatter(action, change, parsed_comment, categories):
colornumber = None
if parsed_comment is None:
parsed_comment = _("No description provided")
if action != "suppressed":
if "anon" in change:
author_url = "https://{wiki}.gamepedia.com/Special:Contributions/{user}".format(wiki=settings["wiki"],
user=change["user"])
@ -463,6 +464,8 @@ def embed_formatter(action, change, parsed_comment, categories):
else:
author_url = "https://{wiki}.gamepedia.com/User:{user}".format(wiki=settings["wiki"],
user=change["user"].replace(" ", "_"))
embed["author"]["name"] = change["user"]
embed["author"]["url"] = author_url
if action in ("edit", "new"): # edit or new page
editsize = change["newlen"] - change["oldlen"]
if editsize > 0:
@ -783,10 +786,9 @@ def embed_formatter(action, change, parsed_comment, categories):
elif action == "suppressed":
link = "https://{wiki}.gamepedia.com/".format(wiki=settings["wiki"])
embed["title"] = _("Action has been hidden by administration.")
embed["author"]["name"] = _("Unknown")
else:
logging.warning("No entry for {event} with params: {params}".format(event=action, params=change))
embed["author"]["name"] = change["user"]
embed["author"]["url"] = author_url
embed["author"]["icon_url"] = settings["appearance"]["embed"][action]["icon"]
embed["url"] = link
embed["description"] = parsed_comment
@ -851,7 +853,8 @@ def essential_info(change, changed_categories):
"""Prepares essential information for both embed and compact message format."""
logging.debug(change)
if ("actionhidden" in change or "suppressed" in change) and "suppressed" not in settings["ignored"]: # if event is hidden using suppression
appearance_mode("supressed", change, "", [])
appearance_mode("suppressed", change, "", changed_categories)
return
if "commenthidden" not in change:
LinkParser.feed(change["parsedcomment"])
parsed_comment = LinkParser.new_string