make compact emoji optional

This commit is contained in:
Markus-Rost 2020-12-06 14:36:28 +01:00
parent 9bfba42529
commit d3b7219777
7 changed files with 589 additions and 355 deletions

View file

@ -311,7 +311,7 @@ class AdvancedSettings:
@staticmethod @staticmethod
def set_ignored_events(): def set_ignored_events():
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", "edit", "new", "external"] 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", "cargo/createtable", "cargo/deletetable", "cargo/recreatetable", "cargo/replacetable", "upload/revert", "newusers/create", "newusers/autocreate", "newusers/create2", "newusers/byemail", "newusers/newusers", "edit", "new", "external"]
option = default_or_custom( option = default_or_custom(
input( input(
"Provide a list of entry types that are supposed to be ignored. Separate them using commas. Example: external, edit, upload/overwrite. (default: external)\n"), "Provide a list of entry types that are supposed to be ignored. Separate them using commas. Example: external, edit, upload/overwrite. (default: external)\n"),

View file

@ -63,250 +63,6 @@
"rcgcdw.misc": { "rcgcdw.misc": {
} }
} }
},
"appearance":{
"mode": "embed",
"embed": {
"show_edit_changes": false,
"show_footer": true,
"embed_images": true,
"daily_overview": {
"color": 16312092,
"icon":""
},
"new":{
"icon":"https://i.imgur.com/6HIbEq8.png",
"color":"THIS COLOR DEPENDS ON EDIT SIZE, PLEASE DON'T CHANGE"
},
"edit":{
"icon":"",
"color":"THIS COLOR DEPENDS ON EDIT SIZE, PLEASE DON'T CHANGE"
},
"upload/overwrite":{
"icon":"https://i.imgur.com/egJpa81.png",
"color":12390624
},
"upload/upload":{
"icon":"https://i.imgur.com/egJpa81.png",
"color":null
},
"upload/revert": {
"icon": "https://i.imgur.com/egJpa81.png",
"color": null
},
"delete/delete":{
"icon":"https://i.imgur.com/BU77GD3.png",
"color":1
},
"delete/delete_redir":{
"icon":"https://i.imgur.com/BU77GD3.png",
"color":1
},
"delete/restore":{
"icon":"https://i.imgur.com/9MnROIU.png",
"color":null
},
"delete/revision":{
"icon":"https://i.imgur.com/1gps6EZ.png",
"color":null
},
"delete/event":{
"icon":"https://i.imgur.com/1gps6EZ.png",
"color":null
},
"merge/merge":{
"icon":"https://i.imgur.com/uQMK9XK.png",
"color":null
},
"move/move":{
"icon":"https://i.imgur.com/eXz9dog.png",
"color":null
},
"move/move_redir":{
"icon":"https://i.imgur.com/UtC3YX2.png",
"color":null
},
"block/block":{
"icon":"https://i.imgur.com/g7KgZHf.png",
"color":1
},
"block/unblock":{
"icon":"https://i.imgur.com/bvtBJ8o.png",
"color":1
},
"block/reblock":{
"icon":"https://i.imgur.com/g7KgZHf.png",
"color":1
},
"protect/protect":{
"icon":"https://i.imgur.com/bzPt89Z.png",
"color":null
},
"protect/modify":{
"icon":"https://i.imgur.com/bzPt89Z.png",
"color":null
},
"protect/move_prot":{
"icon":"https://i.imgur.com/bzPt89Z.png",
"color":null
},
"protect/unprotect":{
"icon":"https://i.imgur.com/2wN3Qcq.png",
"color":null
},
"import/upload":{
"icon":"",
"color":null
},
"import/interwiki":{
"icon":"https://i.imgur.com/sFkhghb.png",
"color":null
},
"rights/rights":{
"icon":"",
"color":null
},
"rights/autopromote": {
"icon":"",
"color":null
},
"abusefilter/abusefilter":{
"icon":"https://i.imgur.com/Sn2NzRJ.png",
"color":null
},
"abusefilter/modify":{
"icon":"https://i.imgur.com/Sn2NzRJ.png",
"color":null
},
"abusefilter/create": {
"icon":"https://i.imgur.com/Sn2NzRJ.png",
"color":null
},
"interwiki/iw_add":{
"icon":"https://i.imgur.com/sFkhghb.png",
"color":null
},
"interwiki/iw_edit":{
"icon":"https://i.imgur.com/sFkhghb.png",
"color":null
},
"interwiki/iw_delete":{
"icon":"https://i.imgur.com/sFkhghb.png",
"color":null
},
"curseprofile/comment-created":{
"icon":"https://i.imgur.com/Lvy5E32.png",
"color":null
},
"curseprofile/comment-edited":{
"icon":"https://i.imgur.com/Lvy5E32.png",
"color":null
},
"curseprofile/comment-deleted":{
"icon":"",
"color":null
},
"curseprofile/comment-purged":{
"icon":"",
"color":null
},
"curseprofile/comment-replied":{
"icon":"https://i.imgur.com/hkyYsI1.png",
"color":null
},
"curseprofile/profile-edited":{
"icon":"",
"color":null
},
"contentmodel/change":{
"icon":"",
"color":null
},
"cargo/deletetable": {
"icon": "",
"color": null
},
"cargo/createtable": {
"icon": "",
"color": null
},
"cargo/replacetable": {
"icon": "",
"color": null
},
"cargo/recreatetable": {
"icon": "",
"color": null
},
"sprite/sprite":{
"icon":"",
"color":null
},
"sprite/sheet":{
"icon":"",
"color":null
},
"sprite/slice":{
"icon":"",
"color":null
},
"managetags/create":{
"icon":"",
"color":null
},
"managetags/delete":{
"icon":"",
"color":null
},
"managetags/activate":{
"icon":"",
"color":null
},
"managetags/deactivate":{
"icon":"",
"color":null
},
"tag/update":{
"icon":"",
"color":null
},
"suppressed":{
"icon": "https://i.imgur.com/1gps6EZ.png",
"color": 8092539
},
"discussion/forum/post": {
"icon": "",
"color":null
},
"discussion/forum/reply": {
"icon": "",
"color":null
},
"discussion/forum/poll": {
"icon": "",
"color":null
},
"discussion/forum/quiz": {
"icon": "",
"color":null
},
"discussion/wall/post": {
"icon": "",
"color":null
},
"discussion/wall/reply": {
"icon": "",
"color":null
},
"discussion/comment/post": {
"icon": "",
"color":null
},
"discussion/comment/reply": {
"icon": "",
"color":null
}
}
}, },
"fandom_discussions": { "fandom_discussions": {
"enabled": false, "enabled": false,
@ -322,5 +78,465 @@
} }
}, },
"show_forums": [] "show_forums": []
} },
} "appearance":{
"mode": "embed",
"embed": {
"show_edit_changes": false,
"show_footer": true,
"embed_images": true,
}
},
"event_appearance": {
"daily_overview": {
"icon": "",
"color": 16312092,
"emoji": ""
},
"new": {
"icon": "https://i.imgur.com/6HIbEq8.png",
"color": "THIS COLOR DEPENDS ON EDIT SIZE, PLEASE DON'T CHANGE",
"emoji": "🆕"
},
"edit": {
"icon": "",
"color": "THIS COLOR DEPENDS ON EDIT SIZE, PLEASE DON'T CHANGE",
"emoji": "📝"
},
"upload/overwrite": {
"icon": "https://i.imgur.com/egJpa81.png",
"color": 12390624,
"emoji": "🖼️"
},
"upload/upload": {
"icon": "https://i.imgur.com/egJpa81.png",
"color": 12390624,
"emoji": "🖼️"
},
"upload/revert": {
"icon": "https://i.imgur.com/egJpa81.png",
"color": 12390624,
"emoji": "⏮️"
},
"delete/delete": {
"icon": "https://i.imgur.com/BU77GD3.png",
"color": 1,
"emoji": "🗑️"
},
"delete/delete_redir": {
"icon": "https://i.imgur.com/BU77GD3.png",
"color": 1,
"emoji": "🗑️"
},
"delete/restore": {
"icon": "https://i.imgur.com/9MnROIU.png",
"color": 1,
"emoji": "♻️"
},
"delete/revision": {
"icon": "https://i.imgur.com/1gps6EZ.png",
"color": 1,
"emoji": "👁️"
},
"delete/event": {
"icon": "https://i.imgur.com/1gps6EZ.png",
"color": 1,
"emoji": "👁️"
},
"merge/merge": {
"icon": "https://i.imgur.com/uQMK9XK.png",
"color": 25600,
"emoji": "🖇️"
},
"move/move": {
"icon": "https://i.imgur.com/eXz9dog.png",
"color": 25600,
"emoji": "📨"
},
"move/move_redir": {
"icon": "https://i.imgur.com/UtC3YX2.png",
"color": 25600,
"emoji": "📨"
},
"block/block": {
"icon": "https://i.imgur.com/g7KgZHf.png",
"color": 1,
"emoji": "🚫"
},
"block/unblock": {
"icon": "https://i.imgur.com/bvtBJ8o.png",
"color": 1,
"emoji": "✅"
},
"block/reblock": {
"icon": "https://i.imgur.com/g7KgZHf.png",
"color": 1,
"emoji": "🚫"
},
"protect/protect": {
"icon": "https://i.imgur.com/bzPt89Z.png",
"color": 16312092,
"emoji": "🔒"
},
"protect/modify": {
"icon": "https://i.imgur.com/bzPt89Z.png",
"color": 16312092,
"emoji": "🔐"
},
"protect/move_prot": {
"icon": "https://i.imgur.com/bzPt89Z.png",
"color": 16312092,
"emoji": "🔏"
},
"protect/unprotect": {
"icon": "https://i.imgur.com/2wN3Qcq.png",
"color": 16312092,
"emoji": "🔓"
},
"import/upload": {
"icon": "",
"color": 65280,
"emoji": "📥"
},
"import/interwiki": {
"icon": "https://i.imgur.com/sFkhghb.png",
"color": 65280,
"emoji": "📥"
},
"rights/rights": {
"icon": "",
"color": 16711680,
"emoji": "🏅"
},
"rights/autopromote": {
"icon": "",
"color": 16711680,
"emoji": "🏅"
},
"abusefilter/modify": {
"icon": "https://i.imgur.com/Sn2NzRJ.png",
"color": 16711680,
"emoji": "🔍"
},
"abusefilter/create": {
"icon": "https://i.imgur.com/Sn2NzRJ.png",
"color": 16711680,
"emoji": "🔍"
},
"interwiki/iw_add": {
"icon": "https://i.imgur.com/sFkhghb.png",
"color": 16711680,
"emoji": "🔗"
},
"interwiki/iw_edit": {
"icon": "https://i.imgur.com/sFkhghb.png",
"color": 16711680,
"emoji": "🔗"
},
"interwiki/iw_delete": {
"icon": "https://i.imgur.com/sFkhghb.png",
"color": 16711680,
"emoji": "🔗"
},
"curseprofile/comment-created": {
"icon": "https://i.imgur.com/Lvy5E32.png",
"color": 16089376,
"emoji": "✉️"
},
"curseprofile/comment-edited": {
"icon": "https://i.imgur.com/Lvy5E32.png",
"color": 16089376,
"emoji": "📧"
},
"curseprofile/comment-deleted": {
"icon": "",
"color": 16089376,
"emoji": "🗑️"
},
"curseprofile/comment-purged":{
"icon":"",
"color": 16089376,
"emoji": "👁️"
},
"curseprofile/comment-replied": {
"icon": "https://i.imgur.com/hkyYsI1.png",
"color": 16089376,
"emoji": "📩"
},
"curseprofile/profile-edited": {
"icon": "",
"color": 16089376,
"emoji": "📌"
},
"contentmodel/change": {
"icon": "",
"color": 25600,
"emoji": "📋"
},
"cargo/deletetable": {
"icon": "",
"color": 16776960,
"emoji": "📦"
},
"cargo/createtable": {
"icon": "",
"color": 16776960,
"emoji": "📦"
},
"cargo/replacetable": {
"icon": "",
"color": 16776960,
"emoji": "📦"
},
"cargo/recreatetable": {
"icon": "",
"color": 16776960,
"emoji": "📦"
},
"sprite/sprite": {
"icon": "",
"color": 16776960,
"emoji": "🪟"
},
"sprite/sheet": {
"icon": "",
"color": 16776960,
"emoji": "🪟"
},
"sprite/slice": {
"icon": "",
"color": 16776960,
"emoji": "🪟"
},
"managetags/create": {
"icon": "",
"color": 16776960,
"emoji": "🏷️"
},
"managetags/delete": {
"icon": "",
"color": 16776960,
"emoji": "🏷️"
},
"managetags/activate": {
"icon": "",
"color": 16776960,
"emoji": "🏷️"
},
"managetags/deactivate": {
"icon": "",
"color": 16776960,
"emoji": "🏷️"
},
"newusers/autocreate": {
"icon": "",
"color": 65280,
"emoji": "🗿"
},
"newusers/byemail": {
"icon": "",
"color": 65280,
"emoji": "🗿"
},
"newusers/create": {
"icon": "",
"color": 65280,
"emoji": "🗿"
},
"newusers/create2": {
"icon": "",
"color": 65280,
"emoji": "🗿"
},
"newusers/newusers": {
"icon": "",
"color": 65280,
"emoji": "🗿"
},
"managewiki/delete": {
"icon": "",
"color": 8421504,
"emoji": "🗑️"
},
"managewiki/lock": {
"icon": "",
"color": 8421504,
"emoji": "🔒"
},
"managewiki/namespaces": {
"icon": "",
"color": 8421504,
"emoji": "📦"
},
"managewiki/namespaces-delete": {
"icon": "",
"color": 8421504,
"emoji": "🗑️"
},
"managewiki/rights": {
"icon": "",
"color": 8421504,
"emoji": "🏅"
},
"managewiki/settings": {
"icon": "",
"color": 8421504,
"emoji": "⚙️"
},
"managewiki/undelete": {
"icon": "",
"color": 8421504,
"emoji": "♻️"
},
"managewiki/unlock": {
"icon": "",
"color": 8421504,
"emoji": "🔓"
},
"datadump/generate": {
"icon": "",
"color": 8421504,
"emoji": "📤"
},
"datadump/delete": {
"icon": "",
"color": 8421504,
"emoji": "🗑️"
},
"pagetranslation/mark": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/unmark": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/moveok": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/movenok": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/deletefok": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/deletefnok": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/deletelok": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/deletelnok": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/encourage": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/discourage": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/prioritylanguages": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/associate": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagetranslation/dissociate": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"translationreview/message": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"translationreview/group": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"pagelang/pagelang": {
"icon": "",
"color": 8421504,
"emoji": "🌐"
},
"renameuser/renameuser": {
"icon": "",
"color": 8421504,
"emoji": "📛"
},
"suppressed": {
"icon": "https://i.imgur.com/1gps6EZ.png",
"color": 1,
"emoji": "👁️"
},
"discussion/forum/post": {
"icon": "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada",
"color": 54998,
"emoji": "📝"
},
"discussion/forum/reply": {
"icon": "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada",
"color": 54998,
"emoji": "📝"
},
"discussion/forum/poll": {
"icon": "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada",
"color": 54998,
"emoji": "📝"
},
"discussion/forum/quiz": {
"icon": "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada",
"color": 54998,
"emoji": "📝"
},
"discussion/wall/post": {
"icon": "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada",
"color": 3752525,
"emoji": "✉️"
},
"discussion/wall/reply": {
"icon": "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada",
"color": 3752525,
"emoji": "📩"
},
"discussion/comment/post": {
"icon": "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada",
"color": 10802,
"emoji": "🗒️"
},
"discussion/comment/reply": {
"icon": "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada",
"color": 10802,
"emoji": "🗒️"
},
"unknown": {
"icon": "",
"color": 0,
"emoji": "❓"
}
}
}

View file

@ -47,12 +47,14 @@ class DiscordMessage:
def finish_embed(self): def finish_embed(self):
if self.embed["color"] is None: if self.embed["color"] is None:
if settings["appearance"]["embed"].get(self.event_type, {"color": None})["color"] is None: if settings["event_appearance"].get(self.event_type, {"color": None})["color"] is None:
self.embed["color"] = random.randrange(1, 16777215) self.embed["color"] = random.randrange(1, 16777215)
else: else:
self.embed["color"] = settings["appearance"]["embed"][self.event_type]["color"] self.embed["color"] = settings["event_appearance"][self.event_type]["color"]
else: else:
self.embed["color"] = math.floor(self.embed["color"]) self.embed["color"] = math.floor(self.embed["color"])
if not self.embed["author"]["icon_url"] and settings["event_appearance"].get(self.event_type, {"icon": None})["icon"]:
self.embed["author"]["icon_url"] = settings["event_appearance"][self.event_type]["icon"]
def set_author(self, name, url, icon_url=""): def set_author(self, name, url, icon_url=""):
self.embed["author"]["name"] = name self.embed["author"]["name"] = name

View file

@ -28,38 +28,49 @@ def compact_formatter(post_type, post, article_paths):
author = post["createdBy"]["name"] author = post["createdBy"]["name"]
author_url = "<{url}wiki/User:{author}>".format(url=settings["fandom_discussions"]["wiki_url"], author=author) author_url = "<{url}wiki/User:{author}>".format(url=settings["fandom_discussions"]["wiki_url"], author=author)
author_url = link_formatter(create_article_path("User:{user}".format(user=author))) author_url = link_formatter(create_article_path("User:{user}".format(user=author)))
event_type = "discussion"
if post_type == "FORUM": if post_type == "FORUM":
if not post["isReply"]: if not post["isReply"]:
thread_funnel = post.get("funnel") thread_funnel = post.get("funnel")
msg_text = _("[{author}]({author_url}) created [{title}](<{url}f/p/{threadId}>) in {forumName}") msg_text = _("[{author}]({author_url}) created [{title}](<{url}f/p/{threadId}>) in {forumName}")
if thread_funnel == "POLL": if thread_funnel == "POLL":
event_type = "discussion/forum/poll"
msg_text = _("[{author}]({author_url}) created a poll [{title}](<{url}f/p/{threadId}>) in {forumName}") msg_text = _("[{author}]({author_url}) created a poll [{title}](<{url}f/p/{threadId}>) in {forumName}")
elif thread_funnel == "QUIZ": elif thread_funnel == "QUIZ":
event_type = "discussion/forum/quiz"
msg_text = _("[{author}]({author_url}) created a quiz [{title}](<{url}f/p/{threadId}>) in {forumName}") msg_text = _("[{author}]({author_url}) created a quiz [{title}](<{url}f/p/{threadId}>) in {forumName}")
elif thread_funnel != "TEXT": elif thread_funnel == "TEXT":
event_type = "discussion/forum/post"
else:
discussion_logger.warning("The type of {} is an unknown discussion post type. Please post an issue on the project page to have it added https://gitlab.com/piotrex43/RcGcDw/-/issues.".format(thread_funnel)) discussion_logger.warning("The type of {} is an unknown discussion post type. Please post an issue on the project page to have it added https://gitlab.com/piotrex43/RcGcDw/-/issues.".format(thread_funnel))
message = "📝 "+msg_text.format(author=author, author_url=author_url, title=post["title"], url=settings["fandom_discussions"]["wiki_url"], threadId=post["threadId"], forumName=post["forumName"]) event_type = "unknown"
message = msg_text.format(author=author, author_url=author_url, title=post["title"], url=settings["fandom_discussions"]["wiki_url"], threadId=post["threadId"], forumName=post["forumName"])
else: else:
message = "📝 "+_("[{author}]({author_url}) created a [reply](<{url}f/p/{threadId}/r/{postId}>) to [{title}](<{url}f/p/{threadId}>) in {forumName}").format(author=author, author_url=author_url, url=settings["fandom_discussions"]["wiki_url"], threadId=post["threadId"], postId=post["id"], title=post["_embedded"]["thread"][0]["title"], forumName=post["forumName"]) event_type = "discussion/forum/reply"
message = _("[{author}]({author_url}) created a [reply](<{url}f/p/{threadId}/r/{postId}>) to [{title}](<{url}f/p/{threadId}>) in {forumName}").format(author=author, author_url=author_url, url=settings["fandom_discussions"]["wiki_url"], threadId=post["threadId"], postId=post["id"], title=post["_embedded"]["thread"][0]["title"], forumName=post["forumName"])
elif post_type == "WALL": elif post_type == "WALL":
user_wall = _("unknown") # Fail safe user_wall = _("unknown") # Fail safe
if post["forumName"].endswith(' Message Wall'): if post["forumName"].endswith(' Message Wall'):
user_wall = post["forumName"][:-13] user_wall = post["forumName"][:-13]
if not post["isReply"]: if not post["isReply"]:
message = "✉️ "+_("[{author}]({author_url}) created [{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, title=post["title"], url=settings["fandom_discussions"]["wiki_url"], user=user_wall, user_wall=quote_plus(user_wall.replace(" ", "_")), threadId=post["threadId"]) event_type = "discussion/wall/post"
message = _("[{author}]({author_url}) created [{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, title=post["title"], url=settings["fandom_discussions"]["wiki_url"], user=user_wall, user_wall=quote_plus(user_wall.replace(" ", "_")), threadId=post["threadId"])
else: else:
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=settings["fandom_discussions"]["wiki_url"], title=post["_embedded"]["thread"][0]["title"], user=user_wall, user_wall=quote_plus(user_wall.replace(" ", "_")), threadId=post["threadId"], replyId=post["id"]) event_type = "discussion/wall/reply"
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=settings["fandom_discussions"]["wiki_url"], 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_paths is None: if article_paths is None:
article_paths = {"title": _("unknown"), "fullUrl": settings["fandom_discussions"]["wiki_url"]} # No page known article_paths = {"title": _("unknown"), "fullUrl": settings["fandom_discussions"]["wiki_url"]} # No page known
article_paths["fullUrl"] = article_paths["fullUrl"].replace(")", "\)").replace("()", "\(") article_paths["fullUrl"] = article_paths["fullUrl"].replace(")", "\)").replace("()", "\(")
if not post["isReply"]: if not post["isReply"]:
message = "🗒️ "+_( event_type = "discussion/comment/post"
message = _(
"[{author}]({author_url}) created a [comment](<{url}?commentId={commentId}>) on [{article}](<{url}>)").format( "[{author}]({author_url}) created a [comment](<{url}?commentId={commentId}>) on [{article}](<{url}>)").format(
author=author, author_url=author_url, url=article_paths["fullUrl"], article=article_paths["title"], author=author, author_url=author_url, url=article_paths["fullUrl"], article=article_paths["title"],
commentId=post["threadId"]) commentId=post["threadId"])
else: else:
message = "🗒️ "+_( event_type = "discussion/comment/reply"
message = _(
"[{author}]({author_url}) created a [reply](<{url}?commentId={commentId}&replyId={replyId}>) to a [comment](<{url}?commentId={commentId}>) on [{article}](<{url}>)").format( "[{author}]({author_url}) created a [reply](<{url}?commentId={commentId}&replyId={replyId}>) to a [comment](<{url}?commentId={commentId}>) on [{article}](<{url}>)").format(
author=author, author_url=author_url, url=article_paths["fullUrl"], article=article_paths["title"], author=author, author_url=author_url, url=article_paths["fullUrl"], article=article_paths["title"],
commentId=post["threadId"], replyId=post["id"]) commentId=post["threadId"], replyId=post["id"])
@ -68,9 +79,12 @@ def compact_formatter(post_type, post, article_paths):
if not settings["support"]: if not settings["support"]:
return return
else: else:
message = ""+_("Unknown event `{event}` by [{author}]({author_url}), report it on the [support server](<{support}>).").format( message = _("Unknown event `{event}` by [{author}]({author_url}), report it on the [support server](<{support}>).").format(
event=post_type, author=author, author_url=author_url, support=settings["support"]) event=post_type, author=author, author_url=author_url, support=settings["support"])
send_to_discord(DiscordMessage("compact", "discussion", settings["fandom_discussions"]["webhookURL"], content=message), meta=DiscordMessageMetadata("POST")) event_type = "unknown"
if settings["event_appearance"].get(event_type, {"emoji": None})["emoji"]:
message = settings["event_appearance"][event_type]["emoji"] + " " + message
send_to_discord(DiscordMessage("compact", event_type, settings["fandom_discussions"]["webhookURL"], content=message), meta=DiscordMessageMetadata("POST"))
def embed_formatter(post_type, post, article_paths): def embed_formatter(post_type, post, article_paths):
@ -122,6 +136,7 @@ def embed_formatter(post_type, post, article_paths):
embed.event_type = "discussion/forum/post" embed.event_type = "discussion/forum/post"
else: else:
discussion_logger.warning("The type of {} is an unknown discussion post type. Please post an issue on the project page to have it added https://gitlab.com/piotrex43/RcGcDw/-/issues.".format(thread_funnel)) discussion_logger.warning("The type of {} is an unknown discussion post type. Please post an issue on the project page to have it added https://gitlab.com/piotrex43/RcGcDw/-/issues.".format(thread_funnel))
embed.event_type = "unknown"
if post["_embedded"]["thread"][0]["tags"]: if post["_embedded"]["thread"][0]["tags"]:
tag_displayname = [] tag_displayname = []
for tag in post["_embedded"]["thread"][0]["tags"]: for tag in post["_embedded"]["thread"][0]["tags"]:
@ -161,7 +176,7 @@ def embed_formatter(post_type, post, article_paths):
else: else:
discussion_logger.warning("No entry for {event} with params: {params}".format(event=post_type, params=post)) discussion_logger.warning("No entry for {event} with params: {params}".format(event=post_type, params=post))
embed["title"] = _("Unknown event `{event}`").format(event=post_type) embed["title"] = _("Unknown event `{event}`").format(event=post_type)
embed["color"] = 0 embed.event_type = "unknown"
if settings.get("support", None): if settings.get("support", None):
change_params = "[```json\n{params}\n```]({support})".format(params=json.dumps(post, indent=2), change_params = "[```json\n{params}\n```]({support})".format(params=json.dumps(post, indent=2),
support=settings["support"]) support=settings["support"])

View file

@ -29,7 +29,7 @@ supported_logs = {"protect/protect", "protect/modify", "protect/unprotect", "upl
"curseprofile/comment-edited", "curseprofile/comment-deleted", "curseprofile/comment-purged", "curseprofile/comment-edited", "curseprofile/comment-deleted", "curseprofile/comment-purged",
"curseprofile/profile-edited", "curseprofile/comment-replied", "contentmodel/change", "sprite/sprite", "curseprofile/profile-edited", "curseprofile/comment-replied", "contentmodel/change", "sprite/sprite",
"sprite/sheet", "sprite/slice", "managetags/create", "managetags/delete", "managetags/activate", "sprite/sheet", "sprite/slice", "managetags/create", "managetags/delete", "managetags/activate",
"managetags/deactivate", "tag/update", "cargo/createtable", "cargo/deletetable", "managetags/deactivate", "cargo/createtable", "cargo/deletetable",
"cargo/recreatetable", "cargo/replacetable", "upload/revert", "newusers/create", "cargo/recreatetable", "cargo/replacetable", "upload/revert", "newusers/create",
"newusers/autocreate", "newusers/create2", "newusers/byemail", "newusers/newusers", "newusers/autocreate", "newusers/create2", "newusers/byemail", "newusers/newusers",
"managewiki/settings", "managewiki/delete", "managewiki/lock", "managewiki/unlock", "managewiki/settings", "managewiki/delete", "managewiki/lock", "managewiki/unlock",

View file

@ -113,49 +113,49 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
if change["title"].startswith("MediaWiki:Tag-"): if change["title"].startswith("MediaWiki:Tag-"):
pass pass
if action == "edit": if action == "edit":
content = "📝 "+_("[{author}]({author_url}) edited [{article}]({edit_link}){comment} {bold}({sign}{edit_size}){bold}").format(author=author, author_url=author_url, article=change["title"], edit_link=edit_link, comment=parsed_comment, edit_size=edit_size, sign=sign, bold=bold) content = _("[{author}]({author_url}) edited [{article}]({edit_link}){comment} {bold}({sign}{edit_size}){bold}").format(author=author, author_url=author_url, article=change["title"], edit_link=edit_link, comment=parsed_comment, edit_size=edit_size, sign=sign, bold=bold)
else: else:
content = "🆕 "+_("[{author}]({author_url}) created [{article}]({edit_link}){comment} {bold}({sign}{edit_size}){bold}").format(author=author, author_url=author_url, article=change["title"], edit_link=edit_link, comment=parsed_comment, edit_size=edit_size, sign=sign, bold=bold) content = _("[{author}]({author_url}) created [{article}]({edit_link}){comment} {bold}({sign}{edit_size}){bold}").format(author=author, author_url=author_url, article=change["title"], edit_link=edit_link, comment=parsed_comment, edit_size=edit_size, sign=sign, bold=bold)
elif action =="upload/upload": elif action =="upload/upload":
file_link = link_formatter(create_article_path(change["title"])) file_link = link_formatter(create_article_path(change["title"]))
content = "🖼️ "+_("[{author}]({author_url}) uploaded [{file}]({file_link}){comment}").format(author=author, content = _("[{author}]({author_url}) uploaded [{file}]({file_link}){comment}").format(author=author,
author_url=author_url, author_url=author_url,
file=change["title"], file=change["title"],
file_link=file_link, file_link=file_link,
comment=parsed_comment) comment=parsed_comment)
elif action == "upload/revert": elif action == "upload/revert":
file_link = link_formatter(create_article_path(change["title"])) file_link = link_formatter(create_article_path(change["title"]))
content = "⏮️ "+_("[{author}]({author_url}) reverted a version of [{file}]({file_link}){comment}").format( content = _("[{author}]({author_url}) reverted a version of [{file}]({file_link}){comment}").format(
author=author, author_url=author_url, file=change["title"], file_link=file_link, comment=parsed_comment) author=author, author_url=author_url, file=change["title"], file_link=file_link, comment=parsed_comment)
elif action == "upload/overwrite": elif action == "upload/overwrite":
file_link = link_formatter(create_article_path(change["title"])) file_link = link_formatter(create_article_path(change["title"]))
content = "🖼️ "+_("[{author}]({author_url}) uploaded a new version of [{file}]({file_link}){comment}").format(author=author, author_url=author_url, file=change["title"], file_link=file_link, comment=parsed_comment) content = _("[{author}]({author_url}) uploaded a new version of [{file}]({file_link}){comment}").format(author=author, author_url=author_url, file=change["title"], file_link=file_link, comment=parsed_comment)
elif action == "delete/delete": elif action == "delete/delete":
page_link = link_formatter(create_article_path(change["title"])) page_link = link_formatter(create_article_path(change["title"]))
content = "🗑️ "+_("[{author}]({author_url}) deleted [{page}]({page_link}){comment}").format(author=author, author_url=author_url, page=change["title"], page_link=page_link, content = _("[{author}]({author_url}) deleted [{page}]({page_link}){comment}").format(author=author, author_url=author_url, page=change["title"], page_link=page_link,
comment=parsed_comment) comment=parsed_comment)
if AUTO_SUPPRESSION_ENABLED: if AUTO_SUPPRESSION_ENABLED:
delete_messages(dict(pageid=change.get("pageid"))) delete_messages(dict(pageid=change.get("pageid")))
elif action == "delete/delete_redir": elif action == "delete/delete_redir":
page_link = link_formatter(create_article_path(change["title"])) page_link = link_formatter(create_article_path(change["title"]))
content = "🗑️ "+_("[{author}]({author_url}) deleted redirect by overwriting [{page}]({page_link}){comment}").format(author=author, author_url=author_url, page=change["title"], page_link=page_link, content = _("[{author}]({author_url}) deleted redirect by overwriting [{page}]({page_link}){comment}").format(author=author, author_url=author_url, page=change["title"], page_link=page_link,
comment=parsed_comment) comment=parsed_comment)
if AUTO_SUPPRESSION_ENABLED: if AUTO_SUPPRESSION_ENABLED:
delete_messages(dict(pageid=change.get("pageid"))) delete_messages(dict(pageid=change.get("pageid")))
elif action == "move/move": elif action == "move/move":
link = link_formatter(create_article_path(change["logparams"]['target_title'])) link = link_formatter(create_article_path(change["logparams"]['target_title']))
redirect_status = _("without making a redirect") if "suppressredirect" in change["logparams"] else _("with a redirect") redirect_status = _("without making a redirect") if "suppressredirect" in change["logparams"] else _("with a redirect")
content = "📨 "+_("[{author}]({author_url}) moved {redirect}*{article}* to [{target}]({target_url}) {made_a_redirect}{comment}").format(author=author, author_url=author_url, redirect="" if "redirect" in change else "", article=change["title"], content = _("[{author}]({author_url}) moved {redirect}*{article}* to [{target}]({target_url}) {made_a_redirect}{comment}").format(author=author, author_url=author_url, redirect="" if "redirect" in change else "", article=change["title"],
target=change["logparams"]['target_title'], target_url=link, comment=parsed_comment, made_a_redirect=redirect_status) target=change["logparams"]['target_title'], target_url=link, comment=parsed_comment, made_a_redirect=redirect_status)
elif action == "move/move_redir": elif action == "move/move_redir":
link = link_formatter(create_article_path(change["logparams"]["target_title"])) link = link_formatter(create_article_path(change["logparams"]["target_title"]))
redirect_status = _("without making a redirect") if "suppressredirect" in change["logparams"] else _( redirect_status = _("without making a redirect") if "suppressredirect" in change["logparams"] else _(
"with a redirect") "with a redirect")
content = "📨 "+_("[{author}]({author_url}) moved {redirect}*{article}* over redirect to [{target}]({target_url}) {made_a_redirect}{comment}").format(author=author, author_url=author_url, redirect="" if "redirect" in change else "", article=change["title"], content = _("[{author}]({author_url}) moved {redirect}*{article}* over redirect to [{target}]({target_url}) {made_a_redirect}{comment}").format(author=author, author_url=author_url, redirect="" if "redirect" in change else "", article=change["title"],
target=change["logparams"]['target_title'], target_url=link, comment=parsed_comment, made_a_redirect=redirect_status) target=change["logparams"]['target_title'], target_url=link, comment=parsed_comment, made_a_redirect=redirect_status)
elif action == "protect/move_prot": elif action == "protect/move_prot":
link = link_formatter(create_article_path(change["logparams"]["oldtitle_title"])) link = link_formatter(create_article_path(change["logparams"]["oldtitle_title"]))
content = "🔏 "+_( content = _(
"[{author}]({author_url}) moved protection settings from {redirect}*{article}* to [{target}]({target_url}){comment}").format(author=author, author_url=author_url, redirect="" if "redirect" in change else "", article=change["logparams"]["oldtitle_title"], "[{author}]({author_url}) moved protection settings from {redirect}*{article}* to [{target}]({target_url}){comment}").format(author=author, author_url=author_url, redirect="" if "redirect" in change else "", article=change["logparams"]["oldtitle_title"],
target=change["title"], target_url=link, comment=parsed_comment) target=change["title"], target_url=link, comment=parsed_comment)
elif action == "block/block": elif action == "block/block":
@ -206,34 +206,34 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
if len(restriction_description) > 1020: if len(restriction_description) > 1020:
logger.debug(restriction_description) logger.debug(restriction_description)
restriction_description = restriction_description[:1020] + "" restriction_description = restriction_description[:1020] + ""
content = "🚫 "+_( content = _(
"[{author}]({author_url}) blocked [{user}]({user_url}) {time}{restriction_desc}{comment}").format(author=author, author_url=author_url, user=user, time=block_time, user_url=link, restriction_desc=restriction_description, comment=parsed_comment) "[{author}]({author_url}) blocked [{user}]({user_url}) {time}{restriction_desc}{comment}").format(author=author, author_url=author_url, user=user, time=block_time, user_url=link, restriction_desc=restriction_description, comment=parsed_comment)
elif action == "block/reblock": elif action == "block/reblock":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
user = change["title"].split(':', 1)[1] user = change["title"].split(':', 1)[1]
content = "🚫 "+_("[{author}]({author_url}) changed block settings for [{blocked_user}]({user_url}){comment}").format(author=author, author_url=author_url, blocked_user=user, user_url=link, comment=parsed_comment) content = _("[{author}]({author_url}) changed block settings for [{blocked_user}]({user_url}){comment}").format(author=author, author_url=author_url, blocked_user=user, user_url=link, comment=parsed_comment)
elif action == "block/unblock": elif action == "block/unblock":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
user = change["title"].split(':', 1)[1] user = change["title"].split(':', 1)[1]
content = ""+_("[{author}]({author_url}) unblocked [{blocked_user}]({user_url}){comment}").format(author=author, author_url=author_url, blocked_user=user, user_url=link, comment=parsed_comment) content = _("[{author}]({author_url}) unblocked [{blocked_user}]({user_url}){comment}").format(author=author, author_url=author_url, blocked_user=user, user_url=link, comment=parsed_comment)
elif action == "curseprofile/comment-created": elif action == "curseprofile/comment-created":
link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]))) link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"])))
target_user = change["title"].split(':', 1)[1] target_user = change["title"].split(':', 1)[1]
if target_user != author: if target_user != author:
content = "✉️ "+ _("[{author}]({author_url}) left a [comment]({comment}) on {target}'s profile".format(author=author, author_url=author_url, comment=link, target=target_user)) content = _("[{author}]({author_url}) left a [comment]({comment}) on {target}'s profile".format(author=author, author_url=author_url, comment=link, target=target_user))
else: else:
content = "✉️ "+ _("[{author}]({author_url}) left a [comment]({comment}) on their own profile".format(author=author, author_url=author_url, comment=link)) content = _("[{author}]({author_url}) left a [comment]({comment}) on their own profile".format(author=author, author_url=author_url, comment=link))
elif action == "curseprofile/comment-replied": elif action == "curseprofile/comment-replied":
link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]))) link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"])))
target_user = change["title"].split(':', 1)[1] target_user = change["title"].split(':', 1)[1]
if target_user != author: if target_user != author:
content = "📩 "+ _( content = _(
"[{author}]({author_url}) replied to a [comment]({comment}) on {target}'s profile".format(author=author, "[{author}]({author_url}) replied to a [comment]({comment}) on {target}'s profile".format(author=author,
author_url=author_url, author_url=author_url,
comment=link, comment=link,
target=target_user)) target=target_user))
else: else:
content = "📩 "+ _( content = _(
"[{author}]({author_url}) replied to a [comment]({comment}) on their own profile".format(author=author, "[{author}]({author_url}) replied to a [comment]({comment}) on their own profile".format(author=author,
comment=link, comment=link,
author_url=author_url)) author_url=author_url))
@ -241,22 +241,22 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]))) link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"])))
target_user = change["title"].split(':', 1)[1] target_user = change["title"].split(':', 1)[1]
if target_user != author: if target_user != author:
content = "📧 "+ _( content = _(
"[{author}]({author_url}) edited a [comment]({comment}) on {target}'s profile".format(author=author, "[{author}]({author_url}) edited a [comment]({comment}) on {target}'s profile".format(author=author,
author_url=author_url, author_url=author_url,
comment=link, comment=link,
target=target_user)) target=target_user))
else: else:
content = "📧 "+ _( content = _(
"[{author}]({author_url}) edited a [comment]({comment}) on their own profile".format(author=author, "[{author}]({author_url}) edited a [comment]({comment}) on their own profile".format(author=author,
comment=link, comment=link,
author_url=author_url)) author_url=author_url))
elif action == "curseprofile/comment-purged": elif action == "curseprofile/comment-purged":
target_user = change["title"].split(':', 1)[1] target_user = change["title"].split(':', 1)[1]
if target_user != author: if target_user != author:
content = "👁️ " + _("[{author}]({author_url}) purged a comment on {target}'s profile".format(author=author, author_url=author_url,target=target_user)) content = _("[{author}]({author_url}) purged a comment on {target}'s profile".format(author=author, author_url=author_url,target=target_user))
else: else:
content = "👁️ " + _("[{author}]({author_url}) purged a comment on their own profile".format(author=author, author_url=author_url)) content = _("[{author}]({author_url}) purged a comment on their own profile".format(author=author, author_url=author_url))
elif action == "curseprofile/comment-deleted": elif action == "curseprofile/comment-deleted":
if "4:comment_id" in change["logparams"]: if "4:comment_id" in change["logparams"]:
link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]))) link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"])))
@ -264,21 +264,21 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
target_user = change["title"].split(':', 1)[1] target_user = change["title"].split(':', 1)[1]
if target_user != author: if target_user != author:
content = "🗑️ "+ _("[{author}]({author_url}) deleted a [comment]({comment}) on {target}'s profile".format(author=author,author_url=author_url, comment=link, target=target_user)) content = _("[{author}]({author_url}) deleted a [comment]({comment}) on {target}'s profile".format(author=author,author_url=author_url, comment=link, target=target_user))
else: else:
content = "🗑️ "+ _("[{author}]({author_url}) deleted a [comment]({comment}) on their own profile".format(author=author, author_url=author_url, comment=link)) content = _("[{author}]({author_url}) deleted a [comment]({comment}) on their own profile".format(author=author, author_url=author_url, comment=link))
elif action == "curseprofile/profile-edited": elif action == "curseprofile/profile-edited":
target_user = change["title"].split(':', 1)[1] target_user = change["title"].split(':', 1)[1]
link = link_formatter(create_article_path("UserProfile:{user}".format(user=target_user))) link = link_formatter(create_article_path("UserProfile:{user}".format(user=target_user)))
if target_user != author: if target_user != author:
content = "📌 "+_("[{author}]({author_url}) edited the {field} on [{target}]({target_url})'s profile. *({desc})*").format(author=author, content = _("[{author}]({author_url}) edited the {field} on [{target}]({target_url})'s profile. *({desc})*").format(author=author,
author_url=author_url, author_url=author_url,
target=target_user, target=target_user,
target_url=link, target_url=link,
field=profile_field_name(change["logparams"]['4:section'], False), field=profile_field_name(change["logparams"]['4:section'], False),
desc=BeautifulSoup(change["parsedcomment"], "lxml").get_text()) desc=BeautifulSoup(change["parsedcomment"], "lxml").get_text())
else: else:
content = "📌 " + _("[{author}]({author_url}) edited the {field} on [their own]({target_url}) profile. *({desc})*").format( content = _("[{author}]({author_url}) edited the {field} on [their own]({target_url}) profile. *({desc})*").format(
author=author, author=author,
author_url=author_url, author_url=author_url,
target_url=link, target_url=link,
@ -298,21 +298,21 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
new_groups = [_("none")] new_groups = [_("none")]
if action == "rights/rights": if action == "rights/rights":
content = "🏅 "+_("[{author}]({author_url}) changed group membership for [{target}]({target_url}) from {old_groups} to {new_groups}{comment}").format(author=author, author_url=author_url, target=change["title"].split(":")[1], target_url=link, old_groups=", ".join(old_groups), new_groups=', '.join(new_groups), comment=parsed_comment) content = _("[{author}]({author_url}) changed group membership for [{target}]({target_url}) from {old_groups} to {new_groups}{comment}").format(author=author, author_url=author_url, target=change["title"].split(":")[1], target_url=link, old_groups=", ".join(old_groups), new_groups=', '.join(new_groups), comment=parsed_comment)
else: else:
content = "🏅 "+_("{author} autopromoted [{target}]({target_url}) from {old_groups} to {new_groups}{comment}").format( content = _("{author} autopromoted [{target}]({target_url}) from {old_groups} to {new_groups}{comment}").format(
author=_("System"), author_url=author_url, target=change["title"].split(":")[1], target_url=link, author=_("System"), author_url=author_url, target=change["title"].split(":")[1], target_url=link,
old_groups=", ".join(old_groups), new_groups=', '.join(new_groups), old_groups=", ".join(old_groups), new_groups=', '.join(new_groups),
comment=parsed_comment) comment=parsed_comment)
elif action == "protect/protect": elif action == "protect/protect":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🔒 "+_("[{author}]({author_url}) protected [{article}]({article_url}) with the following settings: {settings}{comment}").format(author=author, author_url=author_url, content = _("[{author}]({author_url}) protected [{article}]({article_url}) with the following settings: {settings}{comment}").format(author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
settings=change["logparams"]["description"]+(_(" [cascading]") if "cascade" in change["logparams"] else ""), settings=change["logparams"]["description"]+(_(" [cascading]") if "cascade" in change["logparams"] else ""),
comment=parsed_comment) comment=parsed_comment)
elif action == "protect/modify": elif action == "protect/modify":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🔐 "+_( content = _(
"[{author}]({author_url}) modified protection settings of [{article}]({article_url}) to: {settings}{comment}").format( "[{author}]({author_url}) modified protection settings of [{article}]({article_url}) to: {settings}{comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
@ -320,11 +320,11 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
comment=parsed_comment) comment=parsed_comment)
elif action == "protect/unprotect": elif action == "protect/unprotect":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🔓 "+_("[{author}]({author_url}) removed protection from [{article}]({article_url}){comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, comment=parsed_comment) content = _("[{author}]({author_url}) removed protection from [{article}]({article_url}){comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, comment=parsed_comment)
elif action == "delete/revision": elif action == "delete/revision":
amount = len(change["logparams"]["ids"]) amount = len(change["logparams"]["ids"])
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "👁️ "+ngettext("[{author}]({author_url}) changed visibility of revision on page [{article}]({article_url}){comment}", content = ngettext("[{author}]({author_url}) changed visibility of revision on page [{article}]({article_url}){comment}",
"[{author}]({author_url}) changed visibility of {amount} revisions on page [{article}]({article_url}){comment}", amount).format(author=author, author_url=author_url, "[{author}]({author_url}) changed visibility of {amount} revisions on page [{article}]({article_url}){comment}", amount).format(author=author, author_url=author_url,
article=change["title"], article_url=link, amount=amount, comment=parsed_comment) article=change["title"], article_url=link, amount=amount, comment=parsed_comment)
if AUTO_SUPPRESSION_ENABLED: if AUTO_SUPPRESSION_ENABLED:
@ -337,14 +337,14 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
delete_messages(dict(pageid=pageid)) delete_messages(dict(pageid=pageid))
elif action == "import/upload": elif action == "import/upload":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "📥 "+ngettext("[{author}]({author_url}) imported [{article}]({article_url}) with {count} revision{comment}", content = ngettext("[{author}]({author_url}) imported [{article}]({article_url}) with {count} revision{comment}",
"[{author}]({author_url}) imported [{article}]({article_url}) with {count} revisions{comment}", change["logparams"]["count"]).format( "[{author}]({author_url}) imported [{article}]({article_url}) with {count} revisions{comment}", change["logparams"]["count"]).format(
author=author, author_url=author_url, article=change["title"], article_url=link, count=change["logparams"]["count"], comment=parsed_comment) author=author, author_url=author_url, article=change["title"], article_url=link, count=change["logparams"]["count"], comment=parsed_comment)
elif action == "delete/restore": elif action == "delete/restore":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "♻️ "+_("[{author}]({author_url}) restored [{article}]({article_url}){comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, comment=parsed_comment) content = _("[{author}]({author_url}) restored [{article}]({article_url}){comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, comment=parsed_comment)
elif action == "delete/event": elif action == "delete/event":
content = "👁️ "+_("[{author}]({author_url}) changed visibility of log events{comment}").format(author=author, author_url=author_url, comment=parsed_comment) content = _("[{author}]({author_url}) changed visibility of log events{comment}").format(author=author, author_url=author_url, comment=parsed_comment)
if AUTO_SUPPRESSION_ENABLED: if AUTO_SUPPRESSION_ENABLED:
try: try:
logparams = change["logparams"] logparams = change["logparams"]
@ -356,131 +356,131 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
elif action == "import/interwiki": elif action == "import/interwiki":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
source_link = link_formatter(create_article_path(change["logparams"]["interwiki_title"])) source_link = link_formatter(create_article_path(change["logparams"]["interwiki_title"]))
content = "📥 "+ngettext("[{author}]({author_url}) imported [{article}]({article_url}) with {count} revision from [{source}]({source_url}){comment}", content = ngettext("[{author}]({author_url}) imported [{article}]({article_url}) with {count} revision from [{source}]({source_url}){comment}",
"[{author}]({author_url}) imported [{article}]({article_url}) with {count} revisions from [{source}]({source_url}){comment}", change["logparams"]["count"]).format( "[{author}]({author_url}) imported [{article}]({article_url}) with {count} revisions from [{source}]({source_url}){comment}", change["logparams"]["count"]).format(
author=author, author_url=author_url, article=change["title"], article_url=link, count=change["logparams"]["count"], source=change["logparams"]["interwiki_title"], source_url=source_link, comment=parsed_comment) author=author, author_url=author_url, article=change["title"], article_url=link, count=change["logparams"]["count"], source=change["logparams"]["interwiki_title"], source_url=source_link, comment=parsed_comment)
elif action == "abusefilter/modify": elif action == "abusefilter/modify":
link = link_formatter(create_article_path("Special:AbuseFilter/history/{number}/diff/prev/{historyid}".format(number=change["logparams"]['newId'], historyid=change["logparams"]["historyId"]))) link = link_formatter(create_article_path("Special:AbuseFilter/history/{number}/diff/prev/{historyid}".format(number=change["logparams"]['newId'], historyid=change["logparams"]["historyId"])))
content = "🔍 "+_("[{author}]({author_url}) edited abuse filter [number {number}]({filter_url})").format(author=author, author_url=author_url, number=change["logparams"]['newId'], filter_url=link) content = _("[{author}]({author_url}) edited abuse filter [number {number}]({filter_url})").format(author=author, author_url=author_url, number=change["logparams"]['newId'], filter_url=link)
elif action == "abusefilter/create": elif action == "abusefilter/create":
link = link_formatter( link = link_formatter(
create_article_path("Special:AbuseFilter/{number}".format(number=change["logparams"]['newId']))) create_article_path("Special:AbuseFilter/{number}".format(number=change["logparams"]['newId'])))
content = "🔍 "+_("[{author}]({author_url}) created abuse filter [number {number}]({filter_url})").format(author=author, author_url=author_url, number=change["logparams"]['newId'], filter_url=link) content = _("[{author}]({author_url}) created abuse filter [number {number}]({filter_url})").format(author=author, author_url=author_url, number=change["logparams"]['newId'], filter_url=link)
elif action == "merge/merge": elif action == "merge/merge":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
link_dest = link_formatter(create_article_path(change["logparams"]["dest_title"])) link_dest = link_formatter(create_article_path(change["logparams"]["dest_title"]))
content = "🖇️ "+_("[{author}]({author_url}) merged revision histories of [{article}]({article_url}) into [{dest}]({dest_url}){comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, dest_url=link_dest, content = _("[{author}]({author_url}) merged revision histories of [{article}]({article_url}) into [{dest}]({dest_url}){comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, dest_url=link_dest,
dest=change["logparams"]["dest_title"], comment=parsed_comment) dest=change["logparams"]["dest_title"], comment=parsed_comment)
elif action == "newusers/autocreate": elif action == "newusers/autocreate":
content = "🗿 "+_("Account [{author}]({author_url}) was created automatically").format(author=author, author_url=author_url) content = _("Account [{author}]({author_url}) was created automatically").format(author=author, author_url=author_url)
elif action == "newusers/create": elif action == "newusers/create":
content = "🗿 "+_("Account [{author}]({author_url}) was created").format(author=author, author_url=author_url) content = _("Account [{author}]({author_url}) was created").format(author=author, author_url=author_url)
elif action == "newusers/create2": elif action == "newusers/create2":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🗿 "+_("Account [{article}]({article_url}) was created by [{author}]({author_url}){comment}").format(article=change["title"], article_url=link, author=author, author_url=author_url, comment=parsed_comment) content = _("Account [{article}]({article_url}) was created by [{author}]({author_url}){comment}").format(article=change["title"], article_url=link, author=author, author_url=author_url, comment=parsed_comment)
elif action == "newusers/byemail": elif action == "newusers/byemail":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🗿 "+_("Account [{article}]({article_url}) was created by [{author}]({author_url}) and password was sent by email{comment}").format(article=change["title"], article_url=link, author=author, author_url=author_url, comment=parsed_comment) content = _("Account [{article}]({article_url}) was created by [{author}]({author_url}) and password was sent by email{comment}").format(article=change["title"], article_url=link, author=author, author_url=author_url, comment=parsed_comment)
elif action == "newusers/newusers": elif action == "newusers/newusers":
content = "🗿 "+_("Account [{author}]({author_url}) was created").format(author=author, author_url=author_url) content = _("Account [{author}]({author_url}) was created").format(author=author, author_url=author_url)
elif action == "interwiki/iw_add": elif action == "interwiki/iw_add":
link = link_formatter(create_article_path("Special:Interwiki")) link = link_formatter(create_article_path("Special:Interwiki"))
content = "🔗 "+_("[{author}]({author_url}) added an entry to the [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(author=author, author_url=author_url, desc=parsed_comment, content = _("[{author}]({author_url}) added an entry to the [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(author=author, author_url=author_url, desc=parsed_comment,
prefix=change["logparams"]['0'], prefix=change["logparams"]['0'],
website=change["logparams"]['1'], website=change["logparams"]['1'],
table_url=link) table_url=link)
elif action == "interwiki/iw_edit": elif action == "interwiki/iw_edit":
link = link_formatter(create_article_path("Special:Interwiki")) link = link_formatter(create_article_path("Special:Interwiki"))
content = "🔗 "+_("[{author}]({author_url}) edited an entry in [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(author=author, author_url=author_url, desc=parsed_comment, content = _("[{author}]({author_url}) edited an entry in [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(author=author, author_url=author_url, desc=parsed_comment,
prefix=change["logparams"]['0'], prefix=change["logparams"]['0'],
website=change["logparams"]['1'], website=change["logparams"]['1'],
table_url=link) table_url=link)
elif action == "interwiki/iw_delete": elif action == "interwiki/iw_delete":
link = link_formatter(create_article_path("Special:Interwiki")) link = link_formatter(create_article_path("Special:Interwiki"))
content = "🔗 "+_("[{author}]({author_url}) deleted an entry in [interwiki table]({table_url})").format(author=author, author_url=author_url, table_url=link) content = _("[{author}]({author_url}) deleted an entry in [interwiki table]({table_url})").format(author=author, author_url=author_url, table_url=link)
elif action == "contentmodel/change": elif action == "contentmodel/change":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "📋 "+_("[{author}]({author_url}) changed the content model of the page [{article}]({article_url}) from {old} to {new}{comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, old=change["logparams"]["oldmodel"], content = _("[{author}]({author_url}) changed the content model of the page [{article}]({article_url}) from {old} to {new}{comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, old=change["logparams"]["oldmodel"],
new=change["logparams"]["newmodel"], comment=parsed_comment) new=change["logparams"]["newmodel"], comment=parsed_comment)
elif action == "sprite/sprite": elif action == "sprite/sprite":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🪟 "+_("[{author}]({author_url}) edited the sprite for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link) content = _("[{author}]({author_url}) edited the sprite for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link)
elif action == "sprite/sheet": elif action == "sprite/sheet":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🪟 "+_("[{author}]({author_url}) created the sprite sheet for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link) content = _("[{author}]({author_url}) created the sprite sheet for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link)
elif action == "sprite/slice": elif action == "sprite/slice":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🪟 "+_("[{author}]({author_url}) edited the slice for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link) content = _("[{author}]({author_url}) edited the slice for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link)
elif action == "cargo/createtable": elif action == "cargo/createtable":
LinkParser.feed(change["logparams"]["0"]) LinkParser.feed(change["logparams"]["0"])
table = LinkParser.new_string table = LinkParser.new_string
LinkParser.new_string = "" LinkParser.new_string = ""
content = "📦 "+_("[{author}]({author_url}) created the Cargo table \"{table}\"").format(author=author, author_url=author_url, table=table) content = _("[{author}]({author_url}) created the Cargo table \"{table}\"").format(author=author, author_url=author_url, table=table)
elif action == "cargo/deletetable": elif action == "cargo/deletetable":
content = "📦 "+_("[{author}]({author_url}) deleted the Cargo table \"{table}\"").format(author=author, author_url=author_url, table=change["logparams"]["0"]) content = _("[{author}]({author_url}) deleted the Cargo table \"{table}\"").format(author=author, author_url=author_url, table=change["logparams"]["0"])
elif action == "cargo/recreatetable": elif action == "cargo/recreatetable":
LinkParser.feed(change["logparams"]["0"]) LinkParser.feed(change["logparams"]["0"])
table = LinkParser.new_string table = LinkParser.new_string
LinkParser.new_string = "" LinkParser.new_string = ""
content = "📦 "+_("[{author}]({author_url}) recreated the Cargo table \"{table}\"").format(author=author, author_url=author_url, table=table) content = _("[{author}]({author_url}) recreated the Cargo table \"{table}\"").format(author=author, author_url=author_url, table=table)
elif action == "cargo/replacetable": elif action == "cargo/replacetable":
LinkParser.feed(change["logparams"]["0"]) LinkParser.feed(change["logparams"]["0"])
table = LinkParser.new_string table = LinkParser.new_string
LinkParser.new_string = "" LinkParser.new_string = ""
content = "📦 "+_("[{author}]({author_url}) replaced the Cargo table \"{table}\"").format(author=author, author_url=author_url, table=table) content = _("[{author}]({author_url}) replaced the Cargo table \"{table}\"").format(author=author, author_url=author_url, table=table)
elif action == "managetags/create": elif action == "managetags/create":
link = link_formatter(create_article_path("Special:Tags")) link = link_formatter(create_article_path("Special:Tags"))
content = "🏷️ "+_("[{author}]({author_url}) created a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link) content = _("[{author}]({author_url}) created a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link)
recent_changes.init_info() recent_changes.init_info()
elif action == "managetags/delete": elif action == "managetags/delete":
link = link_formatter(create_article_path("Special:Tags")) link = link_formatter(create_article_path("Special:Tags"))
content = "🏷️ "+_("[{author}]({author_url}) deleted a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link) content = _("[{author}]({author_url}) deleted a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link)
recent_changes.init_info() recent_changes.init_info()
elif action == "managetags/activate": elif action == "managetags/activate":
link = link_formatter(create_article_path("Special:Tags")) link = link_formatter(create_article_path("Special:Tags"))
content = "🏷️ "+_("[{author}]({author_url}) activated a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link) content = _("[{author}]({author_url}) activated a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link)
elif action == "managetags/deactivate": elif action == "managetags/deactivate":
link = link_formatter(create_article_path("Special:Tags")) link = link_formatter(create_article_path("Special:Tags"))
content = "🏷️ "+_("[{author}]({author_url}) deactivated a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link) 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 == "managewiki/settings": # Miraheze's ManageWiki extension https://github.com/miraheze/ManageWiki elif action == "managewiki/settings": # Miraheze's ManageWiki extension https://github.com/miraheze/ManageWiki
content = "⚙️ "+_("[{author}]({author_url}) changed wiki settings{reason}".format(author=author, author_url=author_url, reason=parsed_comment)) content = _("[{author}]({author_url}) changed wiki settings{reason}".format(author=author, author_url=author_url, reason=parsed_comment))
elif action == "managewiki/delete": elif action == "managewiki/delete":
content = "🗑️ "+_("[{author}]({author_url}) deleted a wiki *{wiki_name}*{comment}").format(author=author, author_url=author_url, 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) wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment)
elif action == "managewiki/lock": elif action == "managewiki/lock":
content = "🔒 "+_("[{author}]({author_url}) locked a wiki *{wiki_name}*{comment}").format( 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) author=author, author_url=author_url, wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment)
elif action == "managewiki/namespaces": elif action == "managewiki/namespaces":
content = "📦 "+_("[{author}]({author_url}) modified a namespace *{namespace_name}* on *{wiki_name}*{comment}").format( 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")), author=author, author_url=author_url, namespace_name=change["logparams"].get("namespace", _("Unknown")),
wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment) wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment)
elif action == "managewiki/namespaces-delete": elif action == "managewiki/namespaces-delete":
content = "🗑️ " + _( content = _(
"[{author}]({author_url}) deleted a namespace *{namespace_name}* on *{wiki_name}*{comment}").format( "[{author}]({author_url}) deleted a namespace *{namespace_name}* on *{wiki_name}*{comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
namespace_name=change["logparams"].get("namespace", _("Unknown")), namespace_name=change["logparams"].get("namespace", _("Unknown")),
wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment) wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment)
elif action == "managewiki/rights": elif action == "managewiki/rights":
group_name = change["title"].split("/permissions/", 1)[1] group_name = change["title"].split("/permissions/", 1)[1]
content = "🏅 " + _("[{author}]({author_url}) modified user group *{group_name}*{comment}").format( content = _("[{author}]({author_url}) modified user group *{group_name}*{comment}").format(
author=author, author_url=author_url, group_name=group_name, comment=parsed_comment author=author, author_url=author_url, group_name=group_name, comment=parsed_comment
) )
elif action == "managewiki/undelete": elif action == "managewiki/undelete":
content = "🏅 " + _("[{author}]({author_url}) restored a wiki *{wiki_name}*{comment}").format( 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 author=author, author_url=author_url, wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment
) )
elif action == "managewiki/unlock": elif action == "managewiki/unlock":
content = "🏅 " + _("[{author}]({author_url}) unlocked a wiki *{wiki_name}*{comment}").format( content = _("[{author}]({author_url}) unlocked a wiki *{wiki_name}*{comment}").format(
author=author, author_url=author_url, wiki_name=change["logparams"].get("wiki", _("Unknown")), author=author, author_url=author_url, wiki_name=change["logparams"].get("wiki", _("Unknown")),
comment=parsed_comment comment=parsed_comment
) )
elif action == "datadump/generate": elif action == "datadump/generate":
content = "🏅 " + _("[{author}]({author_url}) generated *{file}* dump{comment}").format( content = _("[{author}]({author_url}) generated *{file}* dump{comment}").format(
author=author, author_url=author_url, file=change["logparams"]["filename"], author=author, author_url=author_url, file=change["logparams"]["filename"],
comment=parsed_comment comment=parsed_comment
) )
elif action == "datadump/delete": elif action == "datadump/delete":
content = "🏅 " + _("[{author}]({author_url}) deleted *{file}* dump{comment}").format( content = _("[{author}]({author_url}) deleted *{file}* dump{comment}").format(
author=author, author_url=author_url, file=change["logparams"]["filename"], author=author, author_url=author_url, file=change["logparams"]["filename"],
comment=parsed_comment comment=parsed_comment
) )
@ -491,21 +491,21 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
else: else:
link = link + "?oldid={}".format(change["logparams"]["revision"]) link = link + "?oldid={}".format(change["logparams"]["revision"])
link = link_formatter(link) link = link_formatter(link)
content = "🌐 " + _("[{author}]({author_url}) marked [{article}]({article_url}) for translation{comment}").format( content = _("[{author}]({author_url}) marked [{article}]({article_url}) for translation{comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
comment=parsed_comment comment=parsed_comment
) )
elif action == "pagetranslation/unmark": elif action == "pagetranslation/unmark":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🌐 " + _("[{author}]({author_url}) removed [{article}]({article_url}) from the translation system{comment}").format( content = _("[{author}]({author_url}) removed [{article}]({article_url}) from the translation system{comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
comment=parsed_comment comment=parsed_comment
) )
elif action == "pagetranslation/moveok": elif action == "pagetranslation/moveok":
link = link_formatter(create_article_path(change["logparams"]["target"])) link = link_formatter(create_article_path(change["logparams"]["target"]))
content = "🌐 " + _("[{author}]({author_url}) completed moving translation pages from *{article}* to [{target}]({target_url}){comment}").format( content = _("[{author}]({author_url}) completed moving translation pages from *{article}* to [{target}]({target_url}){comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], target=change["logparams"]["target"], target_url=link, article=change["title"], target=change["logparams"]["target"], target_url=link,
comment=parsed_comment comment=parsed_comment
@ -513,7 +513,7 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
elif action == "pagetranslation/movenok": elif action == "pagetranslation/movenok":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
target_url = link_formatter(create_article_path(change["logparams"]["target"])) target_url = link_formatter(create_article_path(change["logparams"]["target"]))
content = "🌐 " + _("[{author}]({author_url}) encountered a problem while moving [{article}]({article_url}) to [{target}]({target_url}){comment}").format( content = _("[{author}]({author_url}) encountered a problem while moving [{article}]({article_url}) to [{target}]({target_url}){comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
target=change["logparams"]["target"], target_url=target_url, target=change["logparams"]["target"], target_url=target_url,
@ -521,7 +521,7 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
) )
elif action == "pagetranslation/deletefok": elif action == "pagetranslation/deletefok":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🌐 " + _("[{author}]({author_url}) completed deletion of translatable page [{article}]({article_url}){comment}").format( content = _("[{author}]({author_url}) completed deletion of translatable page [{article}]({article_url}){comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
comment=parsed_comment comment=parsed_comment
@ -529,7 +529,7 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
elif action == "pagetranslation/deletefnok": elif action == "pagetranslation/deletefnok":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
target_url = link_formatter(create_article_path(change["logparams"]["target"])) target_url = link_formatter(create_article_path(change["logparams"]["target"]))
content = "🌐 " + _("[{author}]({author_url}) failed to delete [{article}]({article_url}) which belongs to translatable page [{target}]({target_url}){comment}").format( content = _("[{author}]({author_url}) failed to delete [{article}]({article_url}) which belongs to translatable page [{target}]({target_url}){comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
target=change["logparams"]["target"], target_url=target_url, target=change["logparams"]["target"], target_url=target_url,
@ -537,7 +537,7 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
) )
elif action == "pagetranslation/deletelok": elif action == "pagetranslation/deletelok":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🌐 " + _("[{author}]({author_url}) completed deletion of translation page [{article}]({article_url}){comment}").format( content = _("[{author}]({author_url}) completed deletion of translation page [{article}]({article_url}){comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
comment=parsed_comment comment=parsed_comment
@ -545,7 +545,7 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
elif action == "pagetranslation/deletelnok": elif action == "pagetranslation/deletelnok":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
target_url = link_formatter(create_article_path(change["logparams"]["target"])) target_url = link_formatter(create_article_path(change["logparams"]["target"]))
content = "🌐 " + _("[{author}]({author_url}) failed to delete [{article}]({article_url}) which belongs to translation page [{target}]({target_url}){comment}").format( content = _("[{author}]({author_url}) failed to delete [{article}]({article_url}) which belongs to translation page [{target}]({target_url}){comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
target=change["logparams"]["target"], target_url=target_url, target=change["logparams"]["target"], target_url=target_url,
@ -553,14 +553,14 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
) )
elif action == "pagetranslation/encourage": elif action == "pagetranslation/encourage":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🌐 " + _("[{author}]({author_url}) encouraged translation of [{article}]({article_url}){comment}").format( content = _("[{author}]({author_url}) encouraged translation of [{article}]({article_url}){comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
comment=parsed_comment comment=parsed_comment
) )
elif action == "pagetranslation/discourage": elif action == "pagetranslation/discourage":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🌐 " + _("[{author}]({author_url}) discouraged translation of [{article}]({article_url}){comment}").format( content = _("[{author}]({author_url}) discouraged translation of [{article}]({article_url}){comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
comment=parsed_comment comment=parsed_comment
@ -570,33 +570,33 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
if "languages" in change["logparams"]: if "languages" in change["logparams"]:
languages = "`, `".join(change["logparams"]["languages"].split(",")) languages = "`, `".join(change["logparams"]["languages"].split(","))
if change["logparams"]["force"] == "on": if change["logparams"]["force"] == "on":
content = "🌐 " + _("[{author}]({author_url}) limited languages for [{article}]({article_url}) to `{languages}`{comment}").format( content = _("[{author}]({author_url}) limited languages for [{article}]({article_url}) to `{languages}`{comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
languages=languages, comment=parsed_comment languages=languages, comment=parsed_comment
) )
else: else:
content = "🌐 " + _("[{author}]({author_url}) set the priority languages for [{article}]({article_url}) to `{languages}`{comment}").format( content = _("[{author}]({author_url}) set the priority languages for [{article}]({article_url}) to `{languages}`{comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
languages=languages, comment=parsed_comment languages=languages, comment=parsed_comment
) )
else: else:
content = "🌐 " + _("[{author}]({author_url}) removed priority languages from [{article}]({article_url}){comment}").format( content = _("[{author}]({author_url}) removed priority languages from [{article}]({article_url}){comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
comment=parsed_comment comment=parsed_comment
) )
elif action == "pagetranslation/associate": elif action == "pagetranslation/associate":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🌐 " + _("[{author}]({author_url}) added translatable page [{article}]({article_url}) to aggregate group \"{group}\"{comment}").format( content = _("[{author}]({author_url}) added translatable page [{article}]({article_url}) to aggregate group \"{group}\"{comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
group=change["logparams"]["aggregategroup"], comment=parsed_comment group=change["logparams"]["aggregategroup"], comment=parsed_comment
) )
elif action == "pagetranslation/dissociate": elif action == "pagetranslation/dissociate":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
content = "🌐 " + _("[{author}]({author_url}) removed translatable page [{article}]({article_url}) from aggregate group \"{group}\"{comment}").format( content = _("[{author}]({author_url}) removed translatable page [{article}]({article_url}) from aggregate group \"{group}\"{comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
group=change["logparams"]["aggregategroup"], comment=parsed_comment group=change["logparams"]["aggregategroup"], comment=parsed_comment
@ -608,7 +608,7 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
else: else:
link = link + "?oldid={}".format(change["logparams"]["revision"]) link = link + "?oldid={}".format(change["logparams"]["revision"])
link = link_formatter(link) link = link_formatter(link)
content = "🌐 " + _("[{author}]({author_url}) reviewed translation [{article}]({article_url}){comment}").format( content = _("[{author}]({author_url}) reviewed translation [{article}]({article_url}){comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
comment=parsed_comment comment=parsed_comment
@ -616,14 +616,14 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
elif action == "translationreview/group": elif action == "translationreview/group":
link = link_formatter(create_article_path(change["title"])) link = link_formatter(create_article_path(change["title"]))
if "old-state" in change["logparams"]: if "old-state" in change["logparams"]:
content = "🌐 " + _("[{author}]({author_url}) changed the state of `{language}` translations of [{article}]({article_url}) from `{old_state}` to `{new_state}`{comment}").format( content = _("[{author}]({author_url}) changed the state of `{language}` translations of [{article}]({article_url}) from `{old_state}` to `{new_state}`{comment}").format(
author=author, author_url=author_url, language=change["logparams"]["language"], author=author, author_url=author_url, language=change["logparams"]["language"],
article=change["logparams"]["group-label"], article_url=link, article=change["logparams"]["group-label"], article_url=link,
old_state=change["logparams"]["old-state"], new_state=change["logparams"]["new-state"], old_state=change["logparams"]["old-state"], new_state=change["logparams"]["new-state"],
comment=parsed_comment comment=parsed_comment
) )
else: else:
content = "🌐 " + _("[{author}]({author_url}) changed the state of `{language}` translations of [{article}]({article_url}) to `{new_state}`{comment}").format( content = _("[{author}]({author_url}) changed the state of `{language}` translations of [{article}]({article_url}) to `{new_state}`{comment}").format(
author=author, author_url=author_url, language=change["logparams"]["language"], author=author, author_url=author_url, language=change["logparams"]["language"],
article=change["logparams"]["group-label"], article_url=link, article=change["logparams"]["group-label"], article_url=link,
new_state=change["logparams"]["new-state"], comment=parsed_comment new_state=change["logparams"]["new-state"], comment=parsed_comment
@ -636,7 +636,7 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
new_lang = "`{}`".format(change["logparams"]["newlanguage"]) new_lang = "`{}`".format(change["logparams"]["newlanguage"])
if change["logparams"]["newlanguage"][-5:] == "[def]": if change["logparams"]["newlanguage"][-5:] == "[def]":
new_lang = "`{}` {}".format(change["logparams"]["oldlanguage"][:-5], _("(default)")) new_lang = "`{}` {}".format(change["logparams"]["oldlanguage"][:-5], _("(default)"))
content = "🌐 " + _("[{author}]({author_url}) changed the language of [{article}]({article_url}) from {old_lang} to {new_lang}{comment}").format( content = _("[{author}]({author_url}) changed the language of [{article}]({article_url}) from {old_lang} to {new_lang}{comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
old_lang=old_lang, new_lang=new_lang, comment=parsed_comment old_lang=old_lang, new_lang=new_lang, comment=parsed_comment
@ -645,24 +645,27 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
link = link_formatter(create_article_path("User:"+change["logparams"]["newuser"])) link = link_formatter(create_article_path("User:"+change["logparams"]["newuser"]))
edits = change["logparams"]["edits"] edits = change["logparams"]["edits"]
if edits > 0: if edits > 0:
content = "📛 " + ngettext("[{author}]({author_url}) renamed user *{old_name}* with {edits} edit to [{new_name}]({link}){comment}", content = ngettext("[{author}]({author_url}) renamed user *{old_name}* with {edits} edit to [{new_name}]({link}){comment}",
"[{author}]({author_url}) renamed user *{old_name}* with {edits} edits to [{new_name}]({link}){comment}", edits).format( "[{author}]({author_url}) renamed user *{old_name}* with {edits} edits to [{new_name}]({link}){comment}", edits).format(
author=author, author_url=author_url, old_name=change["logparams"]["olduser"], edits=edits, new_name=change["logparams"]["newuser"], link=link, comment=parsed_comment author=author, author_url=author_url, old_name=change["logparams"]["olduser"], edits=edits, new_name=change["logparams"]["newuser"], link=link, comment=parsed_comment
) )
else: else:
content = "📛 " + _("[{author}]({author_url}) renamed user *{old_name}* to [{new_name}]({link}){comment}").format( content = _("[{author}]({author_url}) renamed user *{old_name}* to [{new_name}]({link}){comment}").format(
author=author, author_url=author_url, old_name=change["logparams"]["olduser"], new_name=change["logparams"]["newuser"], link=link, comment=parsed_comment author=author, author_url=author_url, old_name=change["logparams"]["olduser"], new_name=change["logparams"]["newuser"], link=link, 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:
logger.warning("No entry for {event} with params: {params}".format(event=action, params=change)) logger.warning("No entry for {event} with params: {params}".format(event=action, params=change))
if not settings.get("support", None): if not settings.get("support", None):
return return
else: else:
content = ""+_( content = _(
"Unknown event `{event}` by [{author}]({author_url}), report it on the [support server](<{support}>).").format( "Unknown event `{event}` by [{author}]({author_url}), report it on the [support server](<{support}>).").format(
event=action, author=author, author_url=author_url, support=settings["support"]) event=action, author=author, author_url=author_url, support=settings["support"])
action = "unknown"
if settings["event_appearance"].get(action, {"emoji": None})["emoji"]:
content = settings["event_appearance"][action]["emoji"] + " " + content
send_to_discord(DiscordMessage("compact", action, settings["webhookURL"], content=content), meta=request_metadata) send_to_discord(DiscordMessage("compact", action, settings["webhookURL"], content=content), meta=request_metadata)
def embed_abuselog_formatter(change, recent_changes): def embed_abuselog_formatter(change, recent_changes):
@ -1242,7 +1245,7 @@ def embed_formatter(action, change, parsed_comment, categories, recent_changes):
logger.warning("No entry for {event} with params: {params}".format(event=action, params=change)) logger.warning("No entry for {event} with params: {params}".format(event=action, params=change))
link = create_article_path("Special:RecentChanges") link = create_article_path("Special:RecentChanges")
embed["title"] = _("Unknown event `{event}`").format(event=action) embed["title"] = _("Unknown event `{event}`").format(event=action)
embed["color"] = 0 embed.event_type = "unknown"
if settings.get("support", None): if settings.get("support", None):
change_params = "[```json\n{params}\n```]({support})".format(params=json.dumps(change, indent=2), change_params = "[```json\n{params}\n```]({support})".format(params=json.dumps(change, indent=2),
support=settings["support"]) support=settings["support"])
@ -1250,7 +1253,6 @@ def embed_formatter(action, change, parsed_comment, categories, recent_changes):
embed.add_field(_("Report this on the support server"), settings["support"]) embed.add_field(_("Report this on the support server"), settings["support"])
else: else:
embed.add_field(_("Report this on the support server"), change_params) embed.add_field(_("Report this on the support server"), change_params)
embed["author"]["icon_url"] = settings["appearance"]["embed"].get(action, {"icon": None})["icon"]
embed["url"] = quote(link.replace(" ", "_"), "/:?=&") embed["url"] = quote(link.replace(" ", "_"), "/:?=&")
if parsed_comment is not None: if parsed_comment is not None:
embed["description"] = parsed_comment embed["description"] = parsed_comment

View file

@ -146,8 +146,7 @@ def day_overview():
embed = DiscordMessage("embed", "daily_overview", settings["webhookURL"]) embed = DiscordMessage("embed", "daily_overview", settings["webhookURL"])
embed["title"] = _("Daily overview") embed["title"] = _("Daily overview")
embed["url"] = create_article_path("Special:Statistics") embed["url"] = create_article_path("Special:Statistics")
embed.set_author(settings["wikiname"], create_article_path(""), embed.set_author(settings["wikiname"], create_article_path(""))
icon_url=settings["appearance"]["embed"]["daily_overview"]["icon"])
if not result[0]: if not result[0]:
if not settings["send_empty_overview"]: if not settings["send_empty_overview"]:
return # no changes in this day return # no changes in this day