mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
A few important bugfixed to prevent crashes from hidden actions
This commit is contained in:
parent
3b37bd5b48
commit
9f2c72fad9
11
rcgcdw.py
11
rcgcdw.py
|
@ -158,6 +158,7 @@ def link_formatter(link):
|
||||||
return "<"+re.sub(r"([ \)])", "\\\\\\1", link)+">"
|
return "<"+re.sub(r"([ \)])", "\\\\\\1", link)+">"
|
||||||
|
|
||||||
def compact_formatter(action, change, parsed_comment, categories):
|
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_url = link_formatter("https://{wiki}.gamepedia.com/User:{user}".format(wiki=settings["wiki"], user=change["user"]))
|
||||||
author = change["user"]
|
author = change["user"]
|
||||||
parsed_comment = "" if parsed_comment is None else " *("+parsed_comment+")*"
|
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":
|
elif action == "suppressed":
|
||||||
link = "<https://{wiki}.gamepedia.com/>".format(wiki=settings["wiki"])
|
link = "<https://{wiki}.gamepedia.com/>".format(wiki=settings["wiki"])
|
||||||
content = _("An action has been hidden by administration.")
|
content = _("An action has been hidden by administration.")
|
||||||
print(content)
|
|
||||||
send_to_discord({'content': content})
|
send_to_discord({'content': content})
|
||||||
|
|
||||||
def embed_formatter(action, change, parsed_comment, categories):
|
def embed_formatter(action, change, parsed_comment, categories):
|
||||||
|
@ -437,6 +437,7 @@ def embed_formatter(action, change, parsed_comment, categories):
|
||||||
colornumber = None
|
colornumber = None
|
||||||
if parsed_comment is None:
|
if parsed_comment is None:
|
||||||
parsed_comment = _("No description provided")
|
parsed_comment = _("No description provided")
|
||||||
|
if action != "suppressed":
|
||||||
if "anon" in change:
|
if "anon" in change:
|
||||||
author_url = "https://{wiki}.gamepedia.com/Special:Contributions/{user}".format(wiki=settings["wiki"],
|
author_url = "https://{wiki}.gamepedia.com/Special:Contributions/{user}".format(wiki=settings["wiki"],
|
||||||
user=change["user"])
|
user=change["user"])
|
||||||
|
@ -463,6 +464,8 @@ def embed_formatter(action, change, parsed_comment, categories):
|
||||||
else:
|
else:
|
||||||
author_url = "https://{wiki}.gamepedia.com/User:{user}".format(wiki=settings["wiki"],
|
author_url = "https://{wiki}.gamepedia.com/User:{user}".format(wiki=settings["wiki"],
|
||||||
user=change["user"].replace(" ", "_"))
|
user=change["user"].replace(" ", "_"))
|
||||||
|
embed["author"]["name"] = change["user"]
|
||||||
|
embed["author"]["url"] = author_url
|
||||||
if action in ("edit", "new"): # edit or new page
|
if action in ("edit", "new"): # edit or new page
|
||||||
editsize = change["newlen"] - change["oldlen"]
|
editsize = change["newlen"] - change["oldlen"]
|
||||||
if editsize > 0:
|
if editsize > 0:
|
||||||
|
@ -783,10 +786,9 @@ def embed_formatter(action, change, parsed_comment, categories):
|
||||||
elif action == "suppressed":
|
elif action == "suppressed":
|
||||||
link = "https://{wiki}.gamepedia.com/".format(wiki=settings["wiki"])
|
link = "https://{wiki}.gamepedia.com/".format(wiki=settings["wiki"])
|
||||||
embed["title"] = _("Action has been hidden by administration.")
|
embed["title"] = _("Action has been hidden by administration.")
|
||||||
|
embed["author"]["name"] = _("Unknown")
|
||||||
else:
|
else:
|
||||||
logging.warning("No entry for {event} with params: {params}".format(event=action, params=change))
|
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["author"]["icon_url"] = settings["appearance"]["embed"][action]["icon"]
|
||||||
embed["url"] = link
|
embed["url"] = link
|
||||||
embed["description"] = parsed_comment
|
embed["description"] = parsed_comment
|
||||||
|
@ -851,7 +853,8 @@ def essential_info(change, changed_categories):
|
||||||
"""Prepares essential information for both embed and compact message format."""
|
"""Prepares essential information for both embed and compact message format."""
|
||||||
logging.debug(change)
|
logging.debug(change)
|
||||||
if ("actionhidden" in change or "suppressed" in change) and "suppressed" not in settings["ignored"]: # if event is hidden using suppression
|
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:
|
if "commenthidden" not in change:
|
||||||
LinkParser.feed(change["parsedcomment"])
|
LinkParser.feed(change["parsedcomment"])
|
||||||
parsed_comment = LinkParser.new_string
|
parsed_comment = LinkParser.new_string
|
||||||
|
|
Loading…
Reference in a new issue