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

This commit is contained in:
Frisk 2020-10-24 21:03:59 +02:00
commit e0d0350007
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC
15 changed files with 226 additions and 13 deletions

Binary file not shown.

View file

@ -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 <EMAIL@ADDRESS>, 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 <rfxs9263@yahoo.co.jp>\n"
"Language-Team: Japanese <https://weblate.frisk.space/projects/wiki-bot/"
"rcgcdb/ja/>\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}`により削除されました!"

Binary file not shown.

View file

@ -18,7 +18,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
"|| n%100>=20) ? 1 : 2;\n" "|| n%100>=20) ? 1 : 2;\n"
"X-Generator: Weblate 4.1.1\n" "X-Generator: Weblate 4.2.1\n"
#: src/discord.py:25 #: src/discord.py:25
msgid "wiki deleted" msgid "wiki deleted"

Binary file not shown.

View file

@ -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 <EMAIL@ADDRESS>, 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 <philipp2012lopu@mail.ru>\n"
"Language-Team: Russian <https://weblate.frisk.space/projects/wiki-bot/rcgcdb/"
"ru/>\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}`!"

Binary file not shown.

View file

@ -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 <EMAIL@ADDRESS>, 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 ""

Binary file not shown.

View file

@ -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 <EMAIL@ADDRESS>, 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 <dianliang233@gmail.com>\n"
"Language-Team: Chinese (Simplified) <https://weblate.frisk.space/projects/"
"wiki-bot/rcgcdb/zh-hans/>\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}` 而被移除!"

View file

@ -8,11 +8,11 @@ msgstr ""
"Project-Id-Version: RcGcDb\n" "Project-Id-Version: RcGcDb\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-11 23:23+0200\n" "POT-Creation-Date: 2020-08-11 23:23+0200\n"
"PO-Revision-Date: 2020-08-13 13:54+0000\n" "PO-Revision-Date: 2020-08-17 17:13+0000\n"
"Last-Translator: Leo-768 <leo768leo768@gmail.com>\n" "Last-Translator: Winston Sung <winston21.sung@gmail.com>\n"
"Language-Team: Chinese (Traditional) <https://weblate.frisk.space/projects/" "Language-Team: Chinese (Traditional) <https://weblate.frisk.space/projects/"
"wiki-bot/rcgcdb/zh_Hant/>\n" "wiki-bot/rcgcdb/zh-hant/>\n"
"Language: zh_Hant\n" "Language: zh-hant\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
@ -25,7 +25,7 @@ msgstr "wiki 已刪除"
#: src/discord.py:25 src/discord.py:26 #: src/discord.py:25 src/discord.py:26
msgid "wiki inaccessible" msgid "wiki inaccessible"
msgstr "wiki 無法訪問" msgstr "wiki 無法存取"
#: src/discord.py:27 #: src/discord.py:27
msgid "unknown error" msgid "unknown error"
@ -34,4 +34,4 @@ msgstr "未知錯誤"
#: src/discord.py:28 #: src/discord.py:28
#, python-brace-format #, python-brace-format
msgid "This recent changes webhook has been removed for `{reason}`!" msgid "This recent changes webhook has been removed for `{reason}`!"
msgstr "此最近跟改 webhook 因為 `{reason}` 而被移除!" msgstr "此近期變更 webhook 因為 `{reason}` 而被移除!"

View file

@ -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"]) 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": elif post_type == "ARTICLE_COMMENT":
if article_page is None: 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"]: 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"]) 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: 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) 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": elif post_type == "ARTICLE_COMMENT":
if article_page is None: 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"]: if not post["isReply"]:
embed.event_type = "discussion/comment/post" embed.event_type = "discussion/comment/post"
embed["url"] = "{url}?commentId={commentId}".format(url=article_page["fullUrl"], commentId=post["threadId"]) embed["url"] = "{url}?commentId={commentId}".format(url=article_page["fullUrl"], commentId=post["threadId"])

View file

@ -326,6 +326,35 @@ async def compact_formatter(action, change, parsed_comment, categories, recent_c
content = "⚙️ "+_( content = "⚙️ "+_(
"[{author}]({author_url}) changed wiki settings ({reason})".format(author=author, author_url=author_url, "[{author}]({author_url}) changed wiki settings ({reason})".format(author=author, author_url=author_url,
reason=parsed_comment)) 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": elif action == "suppressed":
content = "👁️ "+_("An action has been hidden by administration.") content = "👁️ "+_("An action has been hidden by administration.")
else: 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) link = create_article_path("Special:Tags", WIKI_ARTICLE_PATH)
embed["title"] = _("Deactivated a tag \"{tag}\"").format(tag=change["logparams"]["tag"]) embed["title"] = _("Deactivated a tag \"{tag}\"").format(tag=change["logparams"]["tag"])
elif action == "managewiki/settings": # Miraheze's ManageWiki extension https://github.com/miraheze/ManageWiki 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") embed["title"] = _("Changed wiki settings")
if change["logparams"].get("changes", ""): if change["logparams"].get("changes", ""):
embed.add_field("Setting", 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": elif action == "suppressed":
link = create_article_path("", WIKI_ARTICLE_PATH) link = create_article_path("", WIKI_ARTICLE_PATH)
embed["title"] = _("Action has been hidden by administration.") embed["title"] = _("Action has been hidden by administration.")

View file

@ -17,7 +17,20 @@ from bs4 import BeautifulSoup
logger = logging.getLogger("rcgcdb.wiki") 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 @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"] identification_string = change["_embedded"]["thread"][0]["containerType"]
comment_page = None comment_page = None
if identification_string == "ARTICLE_COMMENT" and comment_pages is not None: if identification_string == "ARTICLE_COMMENT" and comment_pages is not None:
comment_page = comment_pages[change["forumId"]] 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"] 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) await appearance_mode(identification_string, change, target, db_wiki["wiki"], article_page=comment_page)