Merge remote-tracking branch 'origin/testing' into testing

This commit is contained in:
Frisk 2019-06-11 19:39:32 +02:00
commit 0b5df0177e
No known key found for this signature in database
GPG key ID: 0E9A7D3C0A01586C
8 changed files with 858 additions and 814 deletions

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -113,6 +113,16 @@ def send_to_discord(data):
time.sleep(2.0) time.sleep(2.0)
pass pass
def pull_comment(comment_id):
comment = None
try:
comment = recent_changes.handle_mw_errors(recent_changes.safe_request("https://{}.gamepedia.com/api.php?action=comment&do=getRaw&comment_id={}&format=json".format(settings["wiki"], comment_id)).json())
except MWError:
pass
return comment
def compact_formatter(action, change, parsed_comment, categories): def compact_formatter(action, change, parsed_comment, categories):
if action != "suppressed": 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"]))
@ -508,12 +518,16 @@ def embed_formatter(action, change, parsed_comment, categories):
if action == "upload/overwrite": if action == "upload/overwrite":
if additional_info_retrieved: if additional_info_retrieved:
article_encoded = change["title"].replace(" ", "_").replace(')', '\)') article_encoded = change["title"].replace(" ", "_").replace(')', '\)')
img_timestamp = [x for x in img_info[1]["timestamp"] if x.isdigit()] try:
undolink = "https://{wiki}.gamepedia.com/index.php?title={filename}&action=revert&oldimage={timestamp}%21{filenamewon}".format( img_timestamp = [x for x in img_info[1]["timestamp"] if x.isdigit()]
wiki=settings["wiki"], filename=article_encoded, timestamp="".join(img_timestamp), except IndexError:
filenamewon=article_encoded.split(":", 1)[1]) logger.exception("Could not analize the information about the image (does it have only one version when expected more in overwrite?) which resulted in no Options field: {}".format(img_info))
embed["fields"] = [{"name": _("Options"), "value": _("([preview]({link}) | [undo]({undolink}))").format( else:
link=embed["image"]["url"], undolink=undolink)}] undolink = "https://{wiki}.gamepedia.com/index.php?title={filename}&action=revert&oldimage={timestamp}%21{filenamewon}".format(
wiki=settings["wiki"], filename=article_encoded, timestamp="".join(img_timestamp),
filenamewon=article_encoded.split(":", 1)[1])
embed["fields"] = [{"name": _("Options"), "value": _("([preview]({link}) | [undo]({undolink}))").format(
link=embed["image"]["url"], undolink=undolink)}]
embed["title"] = _("Uploaded a new version of {name}").format(name=change["title"]) embed["title"] = _("Uploaded a new version of {name}").format(name=change["title"])
else: else:
embed["title"] = _("Uploaded {name}").format(name=change["title"]) embed["title"] = _("Uploaded {name}").format(name=change["title"])
@ -609,18 +623,30 @@ def embed_formatter(action, change, parsed_comment, categories):
user = change["title"].split(':')[1] user = change["title"].split(':')[1]
embed["title"] = _("Unblocked {blocked_user}").format(blocked_user=user) embed["title"] = _("Unblocked {blocked_user}").format(blocked_user=user)
elif action == "curseprofile/comment-created": elif action == "curseprofile/comment-created":
if settings["appearance"]["embed"]["show_edit_changes"]:
comment_content = pull_comment(change["logparams"]["4:comment_id"])
if comment_content is not None and comment_content["text"]:
embed["fields"] = [{"name": _("Comment content"), "value": comment_content["text"]}]
link = "https://{wiki}.gamepedia.com/Special:CommentPermalink/{commentid}".format(wiki=settings["wiki"], link = "https://{wiki}.gamepedia.com/Special:CommentPermalink/{commentid}".format(wiki=settings["wiki"],
commentid=change["logparams"]["4:comment_id"]) commentid=change["logparams"]["4:comment_id"])
embed["title"] = _("Left a comment on {target}'s profile").format(target=change["title"].split(':')[1]) if change["title"].split(':')[1] != \ embed["title"] = _("Left a comment on {target}'s profile").format(target=change["title"].split(':')[1]) if change["title"].split(':')[1] != \
change["user"] else _( change["user"] else _(
"Left a comment on their own profile") "Left a comment on their own profile")
elif action == "curseprofile/comment-replied": elif action == "curseprofile/comment-replied":
if settings["appearance"]["embed"]["show_edit_changes"]:
comment_content = pull_comment(change["logparams"]["4:comment_id"])
if comment_content is not None and comment_content["text"]:
embed["fields"] = [{"name": _("Comment content"), "value": comment_content["text"]}]
link = "https://{wiki}.gamepedia.com/Special:CommentPermalink/{commentid}".format(wiki=settings["wiki"], link = "https://{wiki}.gamepedia.com/Special:CommentPermalink/{commentid}".format(wiki=settings["wiki"],
commentid=change["logparams"]["4:comment_id"]) commentid=change["logparams"]["4:comment_id"])
embed["title"] = _("Replied to a comment on {target}'s profile").format(target=change["title"].split(':')[1]) if change["title"].split(':')[1] != \ embed["title"] = _("Replied to a comment on {target}'s profile").format(target=change["title"].split(':')[1]) if change["title"].split(':')[1] != \
change["user"] else _( change["user"] else _(
"Replied to a comment on their own profile") "Replied to a comment on their own profile")
elif action == "curseprofile/comment-edited": elif action == "curseprofile/comment-edited":
if settings["appearance"]["embed"]["show_edit_changes"]:
comment_content = pull_comment(change["logparams"]["4:comment_id"])
if comment_content is not None and comment_content["text"]:
embed["fields"] = [{"name": _("Comment content"), "value": comment_content["text"]}]
link = "https://{wiki}.gamepedia.com/Special:CommentPermalink/{commentid}".format(wiki=settings["wiki"], link = "https://{wiki}.gamepedia.com/Special:CommentPermalink/{commentid}".format(wiki=settings["wiki"],
commentid=change["logparams"]["4:comment_id"]) commentid=change["logparams"]["4:comment_id"])
embed["title"] = _("Edited a comment on {target}'s profile").format(target=change["title"].split(':')[1]) if change["title"].split(':')[1] != \ embed["title"] = _("Edited a comment on {target}'s profile").format(target=change["title"].split(':')[1]) if change["title"].split(':')[1] != \