From f9af6642829787e3706e8533dabe915dfe4fd43c Mon Sep 17 00:00:00 2001 From: Frisk Date: Wed, 27 Jun 2018 16:45:46 +0200 Subject: [PATCH 1/6] Hotfix --- rcgcdw.py | 3 +-- settings.json.example | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/rcgcdw.py b/rcgcdw.py index e0635f7..840635a 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -356,11 +356,10 @@ def first_pass(change): #I've decided to split the embed formatter and change ha combination = "{logtype}/{logaction}".format(logtype=logtype, logaction=logaction) logging.debug("combination is {}".format(combination)) try: - settings["appearance"][combination] + STATIC_VARS = {**STATIC_VARS ,**{"color": settings["appearance"][combination]["color"], "icon": settings["appearance"][combination]["icon"]}} except KeyError: STATIC_VARS = {**STATIC_VARS ,**{"color": "", "icon": ""}} logging.error("No value in the settings has been given for {}".format(combination)) - STATIC_VARS = {**STATIC_VARS ,**{"color": settings["appearance"][combination]["color"], "icon": settings["appearance"][combination]["icon"]}} if logtype=="protect" and logaction=="protect": webhook_formatter(2, STATIC_VARS, user=change["user"], title=change["title"], desc=parsedcomment, settings=change["logparams"]["description"]) elif logtype=="protect" and logaction=="modify": diff --git a/settings.json.example b/settings.json.example index f4d6f20..2a6724f 100644 --- a/settings.json.example +++ b/settings.json.example @@ -117,6 +117,10 @@ "icon":"", "color":null }, + "abusefilter/modify":{ + "icon":"", + "color":null + }, "interwiki/iw_add":{ "icon":"", "color":null From e3ffeb5e134e07d5490ef8310312abfb65cea222 Mon Sep 17 00:00:00 2001 From: Frisk Date: Sat, 30 Jun 2018 00:03:34 +0200 Subject: [PATCH 2/6] Fixed translations --- locale/de/LC_MESSAGES/rcgcdw.mo | Bin 6860 -> 6858 bytes locale/de/LC_MESSAGES/rcgcdw.po | 4 ++-- locale/pl/LC_MESSAGES/rcgcdw.mo | Bin 6890 -> 6890 bytes locale/pl/LC_MESSAGES/rcgcdw.po | 4 ++-- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/de/LC_MESSAGES/rcgcdw.mo b/locale/de/LC_MESSAGES/rcgcdw.mo index 7aba118484a3221341f36bdfda45e63d80666277..0fc7338af7db3143ee11457ce7ebda42b6e54834 100644 GIT binary patch delta 312 zcmXZWt&0Lt6vp9$`2DRY%SpWbS8P+Y*tbCKAPq>m7^aCz=?`i3HKY2o5lhBdp;Z)40YA z9_+Qmgk9CVTznvNTr8txA$XmJUI z?>`|D4uW&wCJr?=_CC1j^?V+9ek_BpU_Qx5p@_UXBFDJN+@eSR!2r#Q$RUPU#5;7c zhfRFKGQOjY3hTJQ8{A_JFRLOa*unJPeN`ekrRdW*!!cfAj6TlL!WACjH?m81SVE02 z474#_?BM~nvfM_Ee2Y4Un9g@Gedxh8MJ^~}8V&qV&-$B@{F;T_wK}(63i@C=8a^hU Mj-RWmwezR_0|t#Hw*UYD diff --git a/locale/de/LC_MESSAGES/rcgcdw.po b/locale/de/LC_MESSAGES/rcgcdw.po index 6d1cae1..c6195db 100644 --- a/locale/de/LC_MESSAGES/rcgcdw.po +++ b/locale/de/LC_MESSAGES/rcgcdw.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2018-06-25 18:01+0200\n" -"PO-Revision-Date: 2018-06-25 18:02+0200\n" +"PO-Revision-Date: 2018-06-30 00:01+0200\n" "Last-Translator: MarkusRost\n" "Language-Team: \n" "Language: de\n" @@ -78,7 +78,7 @@ msgstr "Verschob {article} nach {target}" #: rcgcdw.py:154 msgid "Moved {article} to {title} over redirect" -msgstr "Verschob {article} nach {target} und überschrieb eine Weiterleitung\"" +msgstr "Verschob {article} nach {title} und überschrieb eine Weiterleitung" #: rcgcdw.py:157 msgid "Moved protection settings from {article} to {title}" diff --git a/locale/pl/LC_MESSAGES/rcgcdw.mo b/locale/pl/LC_MESSAGES/rcgcdw.mo index 5f532f21189e198505864250d41bfa04fd9bb7c0..c6323bfb28ddb70be2b13de689f076417d305332 100644 GIT binary patch delta 33 ocmaE5`pR^Jya1cIf}w?#@n%&4XI75tywcpH)S}wW1)^1~0J#\n" "Language-Team: \n" "Language: pl\n" @@ -226,7 +226,7 @@ msgstr "Zaimportowano interwiki" #: rcgcdw.py:254 msgid "Edited abuse filter number {number}" -msgstr "Edytowano filtr nadużyć numer (number)" +msgstr "Edytowano filtr nadużyć numer {number}" #: rcgcdw.py:257 msgid "Merged revision histories of {article} into {dest}" From 20182ecb81b07b479ea8c9e760bfa8e27808fe43 Mon Sep 17 00:00:00 2001 From: Frisk Date: Sun, 1 Jul 2018 20:15:48 +0200 Subject: [PATCH 3/6] Fixed a thing --- rcgcdw.py | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/rcgcdw.py b/rcgcdw.py index 840635a..83cb302 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -102,43 +102,50 @@ def webhook_formatter(action, STATIC, **params): link = "https://{wiki}.gamepedia.com/index.php?title={article}&curid={pageid}&diff={diff}&oldid={oldrev}".format(wiki=settings["wiki"], pageid=params["pageid"], diff=params["diff"], oldrev=params["oldrev"], article=article_encoded) embed["title"] = "{article} ({new}{minor}{editsize})".format(article=params["title"], editsize="+"+str(editsize) if editsize>0 else editsize, new= _("(N!) ") if action == 37 else "", minor=_("m ") if action == 1 and params["minor"] else "") elif action == 5: #sending files + license = None urls = safe_read(recent_changes.safe_request("https://{wiki}.gamepedia.com/api.php?action=query&format=json&prop=imageinfo&list=&meta=&titles={filename}&iiprop=timestamp%7Curl&iilimit=2".format(wiki=settings["wiki"], filename=params["title"])), "query", "pages") undolink = "" link ="https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + additional_info_retrieved = False if urls is not None: - img_info = next(iter(urls.values()))["imageinfo"] - embed["image"]["url"] = img_info[0]["url"] + if "-1" not in urls: #oage removed before we asked for it + img_info = next(iter(urls.values()))["imageinfo"] + embed["image"]["url"] = img_info[0]["url"] + additional_info_retrieved = True else: - return + pass if params["overwrite"]: - img_timestamp = [x for x in img_info[1]["timestamp"] if x.isdigit()] - 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[5:]) + if additional_info_retrieved: + img_timestamp = [x for x in img_info[1]["timestamp"] if x.isdigit()] + 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[5:]) + 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=params["title"]) - embed["fields"] = [{"name": _("Options"), "value": _("([preview]({link}) | [undo]({undolink}))").format(link=embed["image"]["url"], undolink=undolink)}] else: embed["title"] = _("Uploaded {name}").format(name=params["title"]) article_content = safe_read(recent_changes.safe_request("https://{wiki}.gamepedia.com/api.php?action=query&format=json&prop=revisions&titles={article}&rvprop=content".format(wiki=settings["wiki"], article=quote_plus(params["title"], safe=''))), "query", "pages") if article_content is None: logging.warning("Something went wrong when getting license for the image") return 0 - content = list(article_content.values())[0]['revisions'][0]['*'] - try: - matches = re.search(re.compile(settings["license_regex"], re.IGNORECASE), content) - if matches is not None: - license = matches.group("license") - else: - if re.search(re.compile(settings["license_regex_detect"], re.IGNORECASE), content) is None: - license = _("**No license!**") + if "-1" not in article_content: + content = list(article_content.values())[0]['revisions'][0]['*'] + try: + matches = re.search(re.compile(settings["license_regex"], re.IGNORECASE), content) + if matches is not None: + license = matches.group("license") else: - license = "?" - except IndexError: - logging.error("Given regex for the license detection is incorrect. It does not have a capturing group called \"license\" specified. Please fix license_regex value in the config!") - license = "?" - except re.error: - logging.error("Given regex for the license detection is incorrect. Please fix license_regex or license_regex_detect values in the config!") - license = "?" - embed["fields"] = [{"name": _("Options"), "value": _("([preview]({link}))").format(link=embed["image"]["url"])}] - params["desc"] = _("{desc}\nLicense: {license}").format(desc=params["desc"], license=license) + if re.search(re.compile(settings["license_regex_detect"], re.IGNORECASE), content) is None: + license = _("**No license!**") + else: + license = "?" + except IndexError: + logging.error("Given regex for the license detection is incorrect. It does not have a capturing group called \"license\" specified. Please fix license_regex value in the config!") + license = "?" + except re.error: + logging.error("Given regex for the license detection is incorrect. Please fix license_regex or license_regex_detect values in the config!") + license = "?" + if additional_info_retrieved: + embed["fields"] = [{"name": _("Options"), "value": _("([preview]({link}))").format(link=embed["image"]["url"])}] + params["desc"] = _("{desc}\nLicense: {license}").format(desc=params["desc"], license=license if license is not None else "?") elif action == 6: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Deleted page {article}").format(article=params["title"]) From a45bbe1022948015a5738d255103eaa73a97fb2e Mon Sep 17 00:00:00 2001 From: Frisk Date: Sun, 1 Jul 2018 23:11:05 +0200 Subject: [PATCH 4/6] Fixes --- rcgcdw.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/rcgcdw.py b/rcgcdw.py index 83cb302..57eb255 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -231,24 +231,24 @@ def webhook_formatter(action, STATIC, **params): reason = "| {desc}".format(desc=params["desc"]) if params["desc"]!=_("No description provided") else "" params["desc"] = _("Groups changed from {old_groups} to {new_groups} {reason}").format(old_groups=params["old_groups"], new_groups=params["new_groups"], reason=reason) elif action == 2: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Protected {target}").format(target=params["title"]) params["desc"] = params["settings"] + " | " + params["desc"] elif action == 3: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Changed protection level for {article}").format(article=params["title"]) params["desc"] = params["settings"] + " | " + params["desc"] elif action == 4: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Removed protection from {article}").format(article=params["title"]) elif action == 9: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Changed visibility of revision(s) on page {article} ").format(article=params["title"]) elif action == 11: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Imported {article} with {count} revision(s)").format(article=params["title"], count=params["amount"]) elif action == 8: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Restored {article}").format(article=params["title"]) elif action == 10: link = "https://{wiki}.gamepedia.com/Special:RecentChanges".format(wiki=settings["wiki"]) @@ -260,7 +260,7 @@ def webhook_formatter(action, STATIC, **params): link = "https://{wiki}.gamepedia.com/Special:RecentChanges".format(wiki=settings["wiki"]) embed["title"] = _("Edited abuse filter number {number}").format(number=params["filternr"]) elif action == 13: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Merged revision histories of {article} into {dest}").format(article=params["title"], dest=params["destination"]) elif action == 22: link = "https://{wiki}.gamepedia.com/Special:Interwiki".format(wiki=settings["wiki"]) @@ -275,31 +275,31 @@ def webhook_formatter(action, STATIC, **params): embed["title"] = _("Deleted an entry in interwiki table") params["desc"] =_("Prefix: {prefix} | {desc}").format(desc=params["desc"], prefix=params["prefix"]) elif action == 30: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Changed the content model of the page {article}").format(article=params["title"]) params["desc"] = _("Model changed from {old} to {new}: {reason}").format(old=params["oldmodel"], new=params["newmodel"], reason=params["desc"]) elif action == 31: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Edited the sprite for {article}").format(article=params["title"]) elif action == 32: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Created the sprite sheet for {article}").format(article=params["title"]) elif action == 33: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=params["title"].replace(" ", "_")) embed["title"] = _("Edited the slice for {article}").format(article=params["title"]) elif action == 34: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/Special:Tags" embed["title"] = _("Created a tag \"{tag}\"").format(tag=params["additional"]["tag"]) recent_changes.update_tags() elif action == 35: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/Special:Tags" embed["title"] = _("Deleted a tag \"{tag}\"").format(tag=params["additional"]["tag"]) recent_changes.update_tags() elif action == 36: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/Special:Tags" embed["title"] = _("Activated a tag \"{tag}\"").format(tag=params["additional"]["tag"]) elif action == 38: - link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) + link = "https://{wiki}.gamepedia.com/Special:Tags" embed["title"] = _("Deactivated a tag \"{tag}\"").format(tag=params["additional"]["tag"]) else: logging.warning("No entry for {event} with params: {params}".format(event=action, params=params)) From 7a7f62c1fc0b5d206597990583079e7a620df79e Mon Sep 17 00:00:00 2001 From: Frisk Date: Tue, 3 Jul 2018 21:00:34 +0200 Subject: [PATCH 5/6] Fixed pl translation --- locale/pl/LC_MESSAGES/rcgcdw.mo | Bin 6890 -> 6892 bytes locale/pl/LC_MESSAGES/rcgcdw.po | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/pl/LC_MESSAGES/rcgcdw.mo b/locale/pl/LC_MESSAGES/rcgcdw.mo index c6323bfb28ddb70be2b13de689f076417d305332..f47d70a6c8666dd32a77386eb3827ce1c4699be3 100644 GIT binary patch delta 400 zcmXZXF-t;G6u|LAJfHFki4gN;!$YJ{P{epoFrm%GEl?s_6r?2*$`C<#li<`4G#9uu z3eU;S&k*4lG)k_{{Z9&)`@8qtbI(0@>HfNtnBkX1Bpnwy#2d_F7d8HdVO-!Teq#~C zBqyr$`8~H%J@QJ&)#1yXa z9Bq>Iyp9&$p@BWr`~mLa2-EnAM>s=zlP~*r^YDtme_@PqV3Vak&!aZxp@|o$g{!!O xm#7ccks;Si+V~SX_`coGgMMgiS*2Xz%qbSit{0r_=S}mW-F)oa2UqbI;}5r&ERO&H delta 398 zcmXZXze_?<6u|LAyl3$W2@#)K!$U+NH0ae+(cC0(6KoJCp+aa(91O%kaB{NQmY_L$ zi(7w#h-1(g+2|k8_oQ&SpZnw7bI$$se!RD^G4Mnr847AMpT3n8YWH;|%Fd7P0oG@QQ=~#2DtnCQ5&vL2c{;16W2)T)`cz up%$zoLmEulcn2MP-tIsAp7~-~xvZOa&I-kI*H0au28`Rg&W+!UOpHGiqbpJX diff --git a/locale/pl/LC_MESSAGES/rcgcdw.po b/locale/pl/LC_MESSAGES/rcgcdw.po index 34ae2fe..2b7135a 100644 --- a/locale/pl/LC_MESSAGES/rcgcdw.po +++ b/locale/pl/LC_MESSAGES/rcgcdw.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: RcGcDw\n" "POT-Creation-Date: 2018-06-25 18:01+0200\n" -"PO-Revision-Date: 2018-06-27 18:32+0200\n" +"PO-Revision-Date: 2018-07-03 20:56+0200\n" "Last-Translator: Frisk \n" "Language-Team: \n" "Language: pl\n" @@ -190,7 +190,7 @@ msgstr "Nie podano opisu zmian" #: rcgcdw.py:225 msgid "Groups changed from {old_groups} to {new_groups} {reason}" -msgstr "Grupy zmienione z {old_groups} do {new_groups} {desc}" +msgstr "Grupy zmienione z {old_groups} do {new_groups} {reason}" #: rcgcdw.py:228 msgid "Protected {target}" From daf780e626330a8c5bd526c9d0aa7f50ca89c72c Mon Sep 17 00:00:00 2001 From: Frisk Date: Tue, 3 Jul 2018 21:18:43 +0200 Subject: [PATCH 6/6] Fixed link that caused 400 on Discords side --- rcgcdw.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rcgcdw.py b/rcgcdw.py index 57eb255..2f1479a 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -220,7 +220,7 @@ def webhook_formatter(action, STATIC, **params): #link = "https://{wiki}.gamepedia.com/UserProfile:{target}".format(wiki=settings["wiki"], target=params["target"].replace(" ", "_").replace(')', '\)')) embed["title"] = _("Deleted a comment on {target}'s profile").format(target=params["target"]) elif action == 20: - link = "https://{wiki}.gamepedia.com/"+params["user"].replace(" ", "_").replace(')', '\)') + link = "https://{wiki}.gamepedia.com/".format(wiki=settings["wiki"])+params["user"].replace(" ", "_").replace(')', '\)') embed["title"] = _("Changed group membership for {target}").format(target=params["user"]) if params["old_groups"].count(' ') < params["new_groups"].count(' '): embed["thumbnail"]["url"] = "https://i.imgur.com/WnGhF5g.gif"