From b4f63e9e6634c9b5727479a5c33c156002aa8ae3 Mon Sep 17 00:00:00 2001 From: Frisk Date: Sat, 21 Mar 2020 12:50:45 +0100 Subject: [PATCH 1/6] Added #103 --- rcgcdw.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rcgcdw.py b/rcgcdw.py index 6184694..56ef3ea 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -504,7 +504,7 @@ def compact_formatter(action, change, parsed_comment, categories): content = _("[{author}]({author_url}) deactivated a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link) elif action == "suppressed": content = _("An action has been hidden by administration.") - send_to_discord({'content': content}) + send_to_discord(json.dumps({'content': content, 'allowed_mentions': {'parse': []}})) def embed_formatter(action, change, parsed_comment, categories): @@ -958,6 +958,7 @@ def embed_formatter(action, change, parsed_comment, categories): embed["fields"].append({"name": _("Changed categories"), "value": new_cat + del_cat}) data["embeds"].append(dict(embed)) data['avatar_url'] = settings["avatars"]["embed"] + data['allowed_mentions'] = {'parse': []} formatted_embed = json.dumps(data, indent=4) send_to_discord(formatted_embed) From 55ee290777662062f950413a38c71fcde996e0ca Mon Sep 17 00:00:00 2001 From: Frisk Date: Sat, 21 Mar 2020 12:54:48 +0100 Subject: [PATCH 2/6] Added #101 --- rcgcdw.py | 7 ++++--- settings.json.example | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rcgcdw.py b/rcgcdw.py index 56ef3ea..ebde623 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -559,9 +559,9 @@ def embed_formatter(action, change, parsed_comment, categories): link = "{wiki}index.php?title={article}&curid={pageid}&diff={diff}&oldid={oldrev}".format( wiki=WIKI_SCRIPT_PATH, pageid=change["pageid"], diff=change["revid"], oldrev=change["old_revid"], article=change["title"].replace(" ", "_")) - embed["title"] = "{redirect}{article} ({new}{minor}{bot} {editsize})".format(redirect="⤷ " if "redirect" in change else "", article=change["title"], editsize="+" + str( + embed["title"] = "{redirect}{article} ({new}{minor}{bot}{space}{editsize})".format(redirect="⤷ " if "redirect" in change else "", article=change["title"], editsize="+" + str( editsize) if editsize > 0 else editsize, new=_("(N!) ") if action == "new" else "", - minor=_("m") if action == "edit" and "minor" in change else "", bot=_('b') if "bot" in change else "") + minor=_("m") if action == "edit" and "minor" in change else "", bot=_('b') if "bot" in change else "", space=" " if "bot" in change or (action == "edit" and "minor" in change) or action == "new" else "") if settings["appearance"]["embed"]["show_edit_changes"]: if action == "new": changed_content = safe_read(recent_changes.safe_request( @@ -935,7 +935,8 @@ def embed_formatter(action, change, parsed_comment, categories): embed["color"] = settings["appearance"]["embed"][action]["color"] else: embed["color"] = math.floor(colornumber) - embed["timestamp"] = change["timestamp"] + if settings["appearance"]["embed"]["show_footer"]: + embed["timestamp"] = change["timestamp"] if "tags" in change and change["tags"]: tag_displayname = [] if "fields" not in embed: diff --git a/settings.json.example b/settings.json.example index 134a872..9cb379d 100644 --- a/settings.json.example +++ b/settings.json.example @@ -57,6 +57,7 @@ "mode": "embed", "embed": { "show_edit_changes": false, + "show_footer": true, "daily_overview": { "color": 16312092, "icon":"" From 4b9b75bf092f5dc5800777312b3f8ba59e183125 Mon Sep 17 00:00:00 2001 From: Frisk Date: Sat, 21 Mar 2020 13:53:48 +0100 Subject: [PATCH 3/6] Sort of fixed #97 --- rcgcdw.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rcgcdw.py b/rcgcdw.py index ebde623..8630e32 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -229,6 +229,7 @@ def compact_formatter(action, change, parsed_comment, categories): author_url = link_formatter(create_article_path("User:{user}".format( user=change["user"]))) author = change["user"] parsed_comment = "" if parsed_comment is None else " *("+parsed_comment+")*" + parsed_comment = re.sub(r"([^<]|\A)(http(s)://.*?)( |\Z)", "\\1<\\2>\\4", parsed_comment) # see #97 if action in ["edit", "new"]: edit_link = link_formatter("{wiki}index.php?title={article}&curid={pageid}&diff={diff}&oldid={oldrev}".format( wiki=WIKI_SCRIPT_PATH, pageid=change["pageid"], diff=change["revid"], oldrev=change["old_revid"], From 98873ffc6d93c0aed5dbdfd9d4f3f178cb7a16ea Mon Sep 17 00:00:00 2001 From: Frisk Date: Sat, 21 Mar 2020 15:56:10 +0100 Subject: [PATCH 4/6] Bump version --- configloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configloader.py b/configloader.py index 8f27506..9386b23 100644 --- a/configloader.py +++ b/configloader.py @@ -6,7 +6,7 @@ try: # load settings if settings["limitrefetch"] < settings["limit"] and settings["limitrefetch"] != -1: settings["limitrefetch"] = settings["limit"] if "user-agent" in settings["header"]: - settings["header"]["user-agent"] = settings["header"]["user-agent"].format(version="1.9") # set the version in the useragent + settings["header"]["user-agent"] = settings["header"]["user-agent"].format(version="1.9.1") # set the version in the useragent except FileNotFoundError: logging.critical("No config file could be found. Please make sure settings.json is in the directory.") sys.exit(1) From 80bab1c7e6d89d8620d053067bb67f778ba52afb Mon Sep 17 00:00:00 2001 From: Frisk Date: Fri, 27 Mar 2020 16:06:14 +0100 Subject: [PATCH 5/6] Added #104, changed example wiki --- rcgcdw.py | 11 +++++++---- settings.json.example | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/rcgcdw.py b/rcgcdw.py index 8630e32..c537263 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -612,7 +612,7 @@ def embed_formatter(action, change, parsed_comment, categories): img_info = next(iter(urls.values()))["imageinfo"] for num, revision in enumerate(img_info): if revision["timestamp"] == change["logparams"]["img_timestamp"]: # find the correct revision corresponding for this log entry - embed["image"]["url"] = "{rev}?{cache}".format(rev=revision["url"], cache=int(time.time()*5)) # cachebusting + image_direct_url = "{rev}?{cache}".format(rev=revision["url"], cache=int(time.time()*5)) # cachebusting additional_info_retrieved = True break except KeyError: @@ -630,7 +630,9 @@ def embed_formatter(action, change, parsed_comment, categories): undolink = "{wiki}index.php?title={filename}&action=revert&oldimage={archiveid}".format( wiki=WIKI_SCRIPT_PATH, filename=article_encoded, archiveid=revision["archivename"]) embed["fields"] = [{"name": _("Options"), "value": _("([preview]({link}) | [undo]({undolink}))").format( - link=embed["image"]["url"], undolink=undolink)}] + link=image_direct_url, undolink=undolink)}] + if settings["appearance"]["embed"]["embed_images"]: + embed["image"]["url"] = image_direct_url if action == "upload/overwrite": embed["title"] = _("Uploaded a new version of {name}").format(name=change["title"]) elif action == "upload/revert": @@ -667,8 +669,9 @@ def embed_formatter(action, change, parsed_comment, categories): parsed_comment += _("\nLicense: {}").format(license) if additional_info_retrieved: embed["fields"] = [ - {"name": _("Options"), "value": _("([preview]({link}))").format(link=embed["image"]["url"])}] - + {"name": _("Options"), "value": _("([preview]({link}))").format(link=image_direct_url)}] + if settings["appearance"]["embed"]["embed_images"]: + embed["image"]["url"] = image_direct_url elif action == "delete/delete": link = create_article_path(change["title"].replace(" ", "_")) embed["title"] = _("Deleted page {article}").format(article=change["title"]) diff --git a/settings.json.example b/settings.json.example index 9cb379d..8b7213c 100644 --- a/settings.json.example +++ b/settings.json.example @@ -1,6 +1,6 @@ { "cooldown": 60, - "wiki_url": "https://ucp-rail-test.fandom.com/pl/", + "wiki_url": "https://wreckit-woodhouse.fandom.com/", "lang": "en", "header": { "user-agent": "RcGcDw/{version}" @@ -58,6 +58,7 @@ "embed": { "show_edit_changes": false, "show_footer": true, + "embed_images": true, "daily_overview": { "color": 16312092, "icon":"" From c5f215abc7c5b0d94fada9ed428482b044bd91ee Mon Sep 17 00:00:00 2001 From: Frisk Date: Fri, 27 Mar 2020 16:47:43 +0100 Subject: [PATCH 6/6] Update copyright notices with new script name --- configbuilder.py | 2 +- misc.py | 2 +- rcgcdw.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configbuilder.py b/configbuilder.py index b496c60..e0da517 100644 --- a/configbuilder.py +++ b/configbuilder.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Recent changes Gamepedia compatible Discord webhook is a project for using a webhook as recent changes page from MediaWiki. +# Recent changes Goat compatible Discord webhook is a project for using a webhook as recent changes page from MediaWiki. # Copyright (C) 2018 Frisk # This program is free software: you can redistribute it and/or modify diff --git a/misc.py b/misc.py index 68051bf..6413e2a 100644 --- a/misc.py +++ b/misc.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Recent changes Gamepedia compatible Discord webhook is a project for using a webhook as recent changes page from MediaWiki. +# Recent changes Goat compatible Discord webhook is a project for using a webhook as recent changes page from MediaWiki. # Copyright (C) 2018 Frisk # This program is free software: you can redistribute it and/or modify diff --git a/rcgcdw.py b/rcgcdw.py index c537263..3d76e3e 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Recent changes Gamepedia compatible Discord webhook is a project for using a webhook as recent changes page from MediaWiki. +# Recent changes Goat compatible Discord webhook is a project for using a webhook as recent changes page from MediaWiki. # Copyright (C) 2018 Frisk # This program is free software: you can redistribute it and/or modify