diff --git a/locale/ja/LC_MESSAGES/discord.mo b/locale/ja/LC_MESSAGES/discord.mo new file mode 100644 index 0000000..7ddb7a5 Binary files /dev/null and b/locale/ja/LC_MESSAGES/discord.mo differ diff --git a/locale/ja/LC_MESSAGES/discord.po b/locale/ja/LC_MESSAGES/discord.po new file mode 100644 index 0000000..4620bfd --- /dev/null +++ b/locale/ja/LC_MESSAGES/discord.po @@ -0,0 +1,37 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the RcGcDb package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: RcGcDb\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-08-13 21:09+0200\n" +"PO-Revision-Date: 2020-08-15 18:03+0000\n" +"Last-Translator: 7yultukuri7 \n" +"Language-Team: Japanese \n" +"Language: ja\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 4.1.1\n" + +#: src/discord.py:25 +msgid "wiki deleted" +msgstr "ウィキを削除しました" + +#: src/discord.py:25 src/discord.py:26 +msgid "wiki inaccessible" +msgstr "ウィキにアクセスできません" + +#: src/discord.py:27 +msgid "unknown error" +msgstr "不明なエラー" + +#: src/discord.py:28 +#, python-brace-format +msgid "This recent changes webhook has been removed for `{reason}`!" +msgstr "最近の変更を表示するためのwebhookは `{reason}`により削除されました!" diff --git a/locale/pl/LC_MESSAGES/discord.mo b/locale/pl/LC_MESSAGES/discord.mo index 21dd026..7ad05f3 100644 Binary files a/locale/pl/LC_MESSAGES/discord.mo and b/locale/pl/LC_MESSAGES/discord.mo differ diff --git a/locale/pl/LC_MESSAGES/discord.po b/locale/pl/LC_MESSAGES/discord.po index b3f2133..9bcfb88 100644 --- a/locale/pl/LC_MESSAGES/discord.po +++ b/locale/pl/LC_MESSAGES/discord.po @@ -18,7 +18,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "|| n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 4.1.1\n" +"X-Generator: Weblate 4.2.1\n" #: src/discord.py:25 msgid "wiki deleted" diff --git a/locale/ru/LC_MESSAGES/discord.mo b/locale/ru/LC_MESSAGES/discord.mo new file mode 100644 index 0000000..c5669d0 Binary files /dev/null and b/locale/ru/LC_MESSAGES/discord.mo differ diff --git a/locale/ru/LC_MESSAGES/discord.po b/locale/ru/LC_MESSAGES/discord.po new file mode 100644 index 0000000..ed9b4f4 --- /dev/null +++ b/locale/ru/LC_MESSAGES/discord.po @@ -0,0 +1,38 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the RcGcDb package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: RcGcDb\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-08-13 21:09+0200\n" +"PO-Revision-Date: 2020-10-19 14:45+0000\n" +"Last-Translator: Philo04 \n" +"Language-Team: Russian \n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 4.2.1\n" + +#: src/discord.py:25 +msgid "wiki deleted" +msgstr "вики удалена" + +#: src/discord.py:25 src/discord.py:26 +msgid "wiki inaccessible" +msgstr "вики недоступна" + +#: src/discord.py:27 +msgid "unknown error" +msgstr "неизвестная ошибка" + +#: src/discord.py:28 +#, python-brace-format +msgid "This recent changes webhook has been removed for `{reason}`!" +msgstr "Этот вебхук свежих правок был удалён по следующей причине: `{reason}`!" diff --git a/locale/th/LC_MESSAGES/discord.mo b/locale/th/LC_MESSAGES/discord.mo new file mode 100644 index 0000000..99b8b12 Binary files /dev/null and b/locale/th/LC_MESSAGES/discord.mo differ diff --git a/locale/th/LC_MESSAGES/discord.po b/locale/th/LC_MESSAGES/discord.po new file mode 100644 index 0000000..feebe0f --- /dev/null +++ b/locale/th/LC_MESSAGES/discord.po @@ -0,0 +1,34 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the RcGcDb package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: RcGcDb\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-08-13 21:09+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: th\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/discord.py:25 +msgid "wiki deleted" +msgstr "" + +#: src/discord.py:25 src/discord.py:26 +msgid "wiki inaccessible" +msgstr "" + +#: src/discord.py:27 +msgid "unknown error" +msgstr "" + +#: src/discord.py:28 +#, python-brace-format +msgid "This recent changes webhook has been removed for `{reason}`!" +msgstr "" diff --git a/locale/zh-hans/LC_MESSAGES/discord.mo b/locale/zh-hans/LC_MESSAGES/discord.mo new file mode 100644 index 0000000..0149c71 Binary files /dev/null and b/locale/zh-hans/LC_MESSAGES/discord.mo differ diff --git a/locale/zh-hans/LC_MESSAGES/discord.po b/locale/zh-hans/LC_MESSAGES/discord.po new file mode 100644 index 0000000..f276857 --- /dev/null +++ b/locale/zh-hans/LC_MESSAGES/discord.po @@ -0,0 +1,37 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the RcGcDb package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: RcGcDb\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-08-13 21:09+0200\n" +"PO-Revision-Date: 2020-08-21 04:13+0000\n" +"Last-Translator: Dianliang233 \n" +"Language-Team: Chinese (Simplified) \n" +"Language: zh-hans\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 4.1.1\n" + +#: src/discord.py:25 +msgid "wiki deleted" +msgstr "wiki 已删除" + +#: src/discord.py:25 src/discord.py:26 +msgid "wiki inaccessible" +msgstr "wiki 无法访问" + +#: src/discord.py:27 +msgid "unknown error" +msgstr "未知错误" + +#: src/discord.py:28 +#, python-brace-format +msgid "This recent changes webhook has been removed for `{reason}`!" +msgstr "此最近更改 webhook 已因为 `{reason}` 而被移除!" diff --git a/locale/zh-hant/LC_MESSAGES/discord.mo b/locale/zh-hant/LC_MESSAGES/discord.mo index e98013d..58c2071 100644 Binary files a/locale/zh-hant/LC_MESSAGES/discord.mo and b/locale/zh-hant/LC_MESSAGES/discord.mo differ diff --git a/locale/zh-hant/LC_MESSAGES/discord.po b/locale/zh-hant/LC_MESSAGES/discord.po index c50ff9e..d9ed211 100644 --- a/locale/zh-hant/LC_MESSAGES/discord.po +++ b/locale/zh-hant/LC_MESSAGES/discord.po @@ -8,11 +8,11 @@ msgstr "" "Project-Id-Version: RcGcDb\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-08-11 23:23+0200\n" -"PO-Revision-Date: 2020-08-13 13:54+0000\n" -"Last-Translator: Leo-768 \n" +"PO-Revision-Date: 2020-08-17 17:13+0000\n" +"Last-Translator: Winston Sung \n" "Language-Team: Chinese (Traditional) \n" -"Language: zh_Hant\n" +"wiki-bot/rcgcdb/zh-hant/>\n" +"Language: zh-hant\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -25,7 +25,7 @@ msgstr "wiki 已刪除" #: src/discord.py:25 src/discord.py:26 msgid "wiki inaccessible" -msgstr "wiki 無法訪問" +msgstr "wiki 無法存取" #: src/discord.py:27 msgid "unknown error" @@ -34,4 +34,4 @@ msgstr "未知錯誤" #: src/discord.py:28 #, python-brace-format msgid "This recent changes webhook has been removed for `{reason}`!" -msgstr "此最近跟改 webhook 因為 `{reason}` 而被移除!" +msgstr "此近期變更 webhook 因為 `{reason}` 而被移除!" diff --git a/src/formatters/discussions.py b/src/formatters/discussions.py index c23914c..99b3220 100644 --- a/src/formatters/discussions.py +++ b/src/formatters/discussions.py @@ -47,7 +47,7 @@ async def feeds_compact_formatter(post_type, post, message_target, wiki, article message = "📩 "+_("[{author}]({author_url}) created a [reply](<{url}wiki/Message_Wall:{user_wall}?threadId={threadId}#{replyId}>) to [{title}](<{url}wiki/Message_Wall:{user_wall}?threadId={threadId}>) on [{user}'s Message Wall](<{url}wiki/Message_Wall:{user_wall}>)").format(author=author, author_url=author_url, url=wiki, title=post["_embedded"]["thread"][0]["title"], user=user_wall, user_wall=quote_plus(user_wall.replace(" ", "_")), threadId=post["threadId"], replyId=post["id"]) elif post_type == "ARTICLE_COMMENT": if article_page is None: - article_page = {"title": _("unknown"), "fullUrl": "{wiki}wiki/{article}".format(wiki=wiki, article=_("unknown").replace(" ", "_"))} # No page known + article_page = {"title": _("unknown"), "fullUrl": wiki} # No page known if not post["isReply"]: message = "🗒️ "+_("[{author}]({author_url}) created a [comment](<{url}?commentId={commentId}>) on [{article}](<{url}>)").format(author=author, author_url=author_url, url=article_page["fullUrl"], article=article_page["title"], commentId=post["threadId"]) else: @@ -137,7 +137,7 @@ async def feeds_embed_formatter(post_type, post, message_target, wiki, article_p embed["title"] = _("Replied to \"{title}\" on {user}'s Message Wall").format(title=post["_embedded"]["thread"][0]["title"], user=user_wall) elif post_type == "ARTICLE_COMMENT": if article_page is None: - article_page = {"title": _("unknown"), "fullUrl": "{wiki}wiki/{article}".format(wiki=wiki, article=_("unknown").replace(" ", "_"))} # No page known + article_page = {"title": _("unknown"), "fullUrl": wiki} # No page known if not post["isReply"]: embed.event_type = "discussion/comment/post" embed["url"] = "{url}?commentId={commentId}".format(url=article_page["fullUrl"], commentId=post["threadId"]) diff --git a/src/formatters/rc.py b/src/formatters/rc.py index 68df79c..81b6176 100644 --- a/src/formatters/rc.py +++ b/src/formatters/rc.py @@ -326,6 +326,35 @@ async def compact_formatter(action, change, parsed_comment, categories, recent_c content = "⚙️ "+_( "[{author}]({author_url}) changed wiki settings ({reason})".format(author=author, author_url=author_url, reason=parsed_comment)) + elif action == "managewiki/delete": + content = "🗑️ "+_("[{author}]({author_url}) deleted a wiki *{wiki_name}* ({comment})").format(author=author, author_url=author_url, + wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment) + elif action == "managewiki/lock": + content = "🔒 "+_("[{author}]({author_url}) locked a wiki *{wiki_name}* ({comment})").format( + author=author, author_url=author_url, wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment) + elif action == "managewiki/namespaces": + content = "📦 "+_("[{author}]({author_url}) modified a namespace *{namespace_name}* on *{wiki_name}* ({comment})").format( + author=author, author_url=author_url, namespace_name=change["logparams"].get("namespace", _("Unknown")), + wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment) + elif action == "managewiki/namespaces-delete": + content = "🗑️ " + _( + "[{author}]({author_url}) deleted a namespace *{namespace_name}* on *{wiki_name}* ({comment})").format( + author=author, author_url=author_url, + namespace_name=change["logparams"].get("namespace", _("Unknown")), + wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment) + elif action == "managewiki/rights": + content = "🏅 " + _("[{author}]({author_url}) modified user group *{group_name}* ({comment})").format( + author=author, author_url=author_url, group_name=change["title"][32:], comment=parsed_comment + ) + elif action == "managewiki/undelete": + content = "🏅 " + _("[{author}]({author_url}) restored a wiki *{wiki_name}* ({comment})").format( + author=author, author_url=author_url, wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment + ) + elif action == "managewiki/unlock": + content = "🏅 " + _("[{author}]({author_url}) unlocked a wiki *{wiki_name}* ({comment})").format( + author=author, author_url=author_url, wiki_name=change["logparams"].get("wiki", _("Unknown")), + comment=parsed_comment + ) elif action == "suppressed": content = "👁️ "+_("An action has been hidden by administration.") else: @@ -711,10 +740,34 @@ async def embed_formatter(action, change, parsed_comment, categories, recent_cha link = create_article_path("Special:Tags", WIKI_ARTICLE_PATH) embed["title"] = _("Deactivated a tag \"{tag}\"").format(tag=change["logparams"]["tag"]) elif action == "managewiki/settings": # Miraheze's ManageWiki extension https://github.com/miraheze/ManageWiki - link = create_article_path("") + link = create_article_path("", WIKI_ARTICLE_PATH) embed["title"] = _("Changed wiki settings") if change["logparams"].get("changes", ""): embed.add_field("Setting", change["logparams"].get("changes")) + elif action == "managewiki/delete": + embed["title"] = _("Deleted a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", _("Unknown"))) + link = create_article_path("", WIKI_ARTICLE_PATH) + elif action == "managewiki/lock": + embed["title"] = _("Locked a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", _("Unknown"))) + link = create_article_path("", WIKI_ARTICLE_PATH) + elif action == "managewiki/namespaces": + embed["title"] = _("Modified a \"{namespace_name}\" namespace").format(namespace_name=change["logparams"].get("namespace", _("Unknown"))) + link = create_article_path("", WIKI_ARTICLE_PATH) + embed.add_field(_('Wiki'), change["logparams"].get("wiki", _("Unknown"))) + elif action == "managewiki/namespaces-delete": + embed["title"] = _("Deleted a \"{namespace_name}\" namespace").format( + namespace_name=change["logparams"].get("namespace", _("Unknown"))) + link = create_article_path("", WIKI_ARTICLE_PATH) + embed.add_field(_('Wiki'), change["logparams"].get("wiki", _("Unknown"))) + elif action == "managewiki/rights": + embed["title"] = _("Modified \"{usergroup_name}\" usergroup").format(usergroup_name=change["title"][32:]) + link = create_article_path("", WIKI_ARTICLE_PATH) + elif action == "managewiki/undelete": + embed["title"] = _("Restored a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", _("Unknown"))) + link = create_article_path("", WIKI_ARTICLE_PATH) + elif action == "managewiki/unlock": + embed["title"] = _("Unlocked a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", _("Unknown"))) + link = create_article_path("", WIKI_ARTICLE_PATH) elif action == "suppressed": link = create_article_path("", WIKI_ARTICLE_PATH) embed["title"] = _("Action has been hidden by administration.") diff --git a/src/wiki.py b/src/wiki.py index ee7eaec..1e5c7c7 100644 --- a/src/wiki.py +++ b/src/wiki.py @@ -17,7 +17,20 @@ from bs4 import BeautifulSoup logger = logging.getLogger("rcgcdb.wiki") -supported_logs = ["protect/protect", "protect/modify", "protect/unprotect", "upload/overwrite", "upload/upload", "delete/delete", "delete/delete_redir", "delete/restore", "delete/revision", "delete/event", "import/upload", "import/interwiki", "merge/merge", "move/move", "move/move_redir", "protect/move_prot", "block/block", "block/unblock", "block/reblock", "rights/rights", "rights/autopromote", "abusefilter/modify", "abusefilter/create", "interwiki/iw_add", "interwiki/iw_edit", "interwiki/iw_delete", "curseprofile/comment-created", "curseprofile/comment-edited", "curseprofile/comment-deleted", "curseprofile/comment-purged", "curseprofile/profile-edited", "curseprofile/comment-replied", "contentmodel/change", "sprite/sprite", "sprite/sheet", "sprite/slice", "managetags/create", "managetags/delete", "managetags/activate", "managetags/deactivate", "tag/update", "cargo/createtable", "cargo/deletetable", "cargo/recreatetable", "cargo/replacetable", "upload/revert", "managewiki/settings"] +supported_logs = {"protect/protect", "protect/modify", "protect/unprotect", "upload/overwrite", "upload/upload", + "delete/delete", "delete/delete_redir", "delete/restore", "delete/revision", "delete/event", + "import/upload", "import/interwiki", "merge/merge", "move/move", "move/move_redir", + "protect/move_prot", "block/block", "block/unblock", "block/reblock", "rights/rights", + "rights/autopromote", "abusefilter/modify", "abusefilter/create", "interwiki/iw_add", + "interwiki/iw_edit", "interwiki/iw_delete", "curseprofile/comment-created", + "curseprofile/comment-edited", "curseprofile/comment-deleted", "curseprofile/comment-purged", + "curseprofile/profile-edited", "curseprofile/comment-replied", "contentmodel/change", "sprite/sprite", + "sprite/sheet", "sprite/slice", "managetags/create", "managetags/delete", "managetags/activate", + "managetags/deactivate", "tag/update", "cargo/createtable", "cargo/deletetable", + "cargo/recreatetable", "cargo/replacetable", "upload/revert", "newusers/create", + "newusers/autocreate", "newusers/create2", "newusers/byemail", "newusers/newusers", + "managewiki/settings", "managewiki/delete", "managewiki/lock", "managewiki/unlock", + "managewiki/namespaces", "managewiki/namespaces-delete", "managewiki/rights", "managewiki/undelete"} @dataclass @@ -232,6 +245,7 @@ async def essential_feeds(change: dict, comment_pages: dict, db_wiki: sqlite3.Ro identification_string = change["_embedded"]["thread"][0]["containerType"] comment_page = None if identification_string == "ARTICLE_COMMENT" and comment_pages is not None: - comment_page = comment_pages[change["forumId"]] - comment_page["fullUrl"] = "/".join(db_wiki["wiki"].split("/", 3)[:3]) + comment_page["relativeUrl"] + comment_page = comment_pages.get(change["forumId"], None) + if comment_page is not None: + comment_page["fullUrl"] = "/".join(db_wiki["wiki"].split("/", 3)[:3]) + comment_page["relativeUrl"] await appearance_mode(identification_string, change, target, db_wiki["wiki"], article_page=comment_page)