mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
22f58df474
|
@ -443,6 +443,7 @@ async def discussion_handler():
|
|||
else:
|
||||
logger.exception("Exception on Feeds formatter")
|
||||
await generic_msg_sender_exception_logger(traceback.format_exc(), "Exception in feed formatter", Post=str(post)[0:1000], Wiki=db_wiki["wiki"])
|
||||
# Lets stack the messages
|
||||
for messages in message_list.values():
|
||||
messages = stack_message_list(messages)
|
||||
for message in messages:
|
||||
|
|
|
@ -42,14 +42,16 @@ async def compact_formatter(action, change, parsed_comment, categories, recent_c
|
|||
wiki=WIKI_SCRIPT_PATH, pageid=change["pageid"], diff=change["revid"], oldrev=change["old_revid"],
|
||||
article=change["title"]))
|
||||
edit_size = change["newlen"] - change["oldlen"]
|
||||
sign = ""
|
||||
if edit_size > 0:
|
||||
sign = "+"
|
||||
else:
|
||||
sign = ""
|
||||
bold = ""
|
||||
if abs(edit_size) > 500:
|
||||
bold = "**"
|
||||
if action == "edit":
|
||||
content = "📝 "+_("[{author}]({author_url}) edited [{article}]({edit_link}){comment} ({sign}{edit_size})").format(author=author, author_url=author_url, article=change["title"], edit_link=edit_link, comment=parsed_comment, edit_size=edit_size, sign=sign)
|
||||
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:
|
||||
content = "🆕 "+_("[{author}]({author_url}) created [{article}]({edit_link}){comment} ({sign}{edit_size})").format(author=author, author_url=author_url, article=change["title"], edit_link=edit_link, comment=parsed_comment, edit_size=edit_size, sign=sign)
|
||||
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":
|
||||
file_link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
content = "🖼️ "+_("[{author}]({author_url}) uploaded [{file}]({file_link}){comment}").format(author=author,
|
||||
|
@ -151,43 +153,73 @@ async def compact_formatter(action, change, parsed_comment, categories, recent_c
|
|||
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":
|
||||
link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]), WIKI_ARTICLE_PATH))
|
||||
content = "✉️ "+_("[{author}]({author_url}) left a [comment]({comment}) on {target} profile").format(author=author, author_url=author_url, comment=link, target=change["title"].split(':')[1]+"'s" if change["title"].split(':')[1] != change["user"] else _("their own profile"))
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
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))
|
||||
else:
|
||||
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":
|
||||
link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]), WIKI_ARTICLE_PATH))
|
||||
content = "📩 "+_("[{author}]({author_url}) replied to a [comment]({comment}) on {target} profile").format(author=author,
|
||||
author_url=author_url,
|
||||
comment=link,
|
||||
target=change["title"].split(':')[1] if change["title"].split(':')[1] !=change["user"] else _("their own"))
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
if target_user != author:
|
||||
content = "📩 "+ _(
|
||||
"[{author}]({author_url}) replied to a [comment]({comment}) on {target}'s profile".format(author=author,
|
||||
author_url=author_url,
|
||||
comment=link,
|
||||
target=target_user))
|
||||
else:
|
||||
content = "📩 "+ _(
|
||||
"[{author}]({author_url}) replied to a [comment]({comment}) on their own profile".format(author=author,
|
||||
comment=link,
|
||||
author_url=author_url))
|
||||
elif action == "curseprofile/comment-edited":
|
||||
link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]), WIKI_ARTICLE_PATH))
|
||||
content = "📧 "+_("[{author}]({author_url}) edited a [comment]({comment}) on {target} profile").format(author=author,
|
||||
author_url=author_url,
|
||||
comment=link,
|
||||
target=change["title"].split(':')[1] if change["title"].split(':')[1] !=change["user"] else _("their own"))
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
if target_user != author:
|
||||
content = "📧 "+ _(
|
||||
"[{author}]({author_url}) edited a [comment]({comment}) on {target}'s profile".format(author=author,
|
||||
author_url=author_url,
|
||||
comment=link,
|
||||
target=target_user))
|
||||
else:
|
||||
content = "📧 "+ _(
|
||||
"[{author}]({author_url}) edited a [comment]({comment}) on their own profile".format(author=author,
|
||||
comment=link,
|
||||
author_url=author_url))
|
||||
elif action == "curseprofile/comment-purged":
|
||||
link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]), WIKI_ARTICLE_PATH))
|
||||
content = "👁️ "+_("[{author}]({author_url}) purged a comment on {target} profile").format(author=author,
|
||||
author_url=author_url,
|
||||
target=
|
||||
change["title"].split(':')[
|
||||
1] if
|
||||
change["title"].split(':')[
|
||||
1] != change[
|
||||
"user"] else _(
|
||||
"their own"))
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
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))
|
||||
else:
|
||||
content = "👁️ " + _("[{author}]({author_url}) purged a comment on their own profile".format(author=author, author_url=author_url))
|
||||
elif action == "curseprofile/comment-deleted":
|
||||
content = "🗑️ "+_("[{author}]({author_url}) deleted a comment on {target} profile").format(author=author,
|
||||
author_url=author_url,
|
||||
target=change["title"].split(':')[1] if change["title"].split(':')[1] !=change["user"] else _("their own"))
|
||||
if "4:comment_id" in change["logparams"]:
|
||||
link = link_formatter(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]), WIKI_ARTICLE_PATH))
|
||||
else:
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
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))
|
||||
else:
|
||||
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":
|
||||
link = link_formatter(create_article_path("UserProfile:{user}".format(user=change["title"].split(":")[1]), WIKI_ARTICLE_PATH))
|
||||
target = _("[{target}]({target_url})'s").format(target=change["title"].split(':')[1], target_url=link) if change["title"].split(':')[1] != author else _("[their own]({target_url})").format(target_url=link)
|
||||
content = "📌 "+_("[{author}]({author_url}) edited the {field} on {target} profile. *({desc})*").format(author=author,
|
||||
author_url=author_url,
|
||||
target=target,
|
||||
field=profile_field_name(change["logparams"]['4:section'], False, message_target[0][0]),
|
||||
desc=BeautifulSoup(change["parsedcomment"], "lxml").get_text())
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
link = link_formatter(create_article_path("UserProfile:{user}".format(user=target_user), WIKI_ARTICLE_PATH))
|
||||
if target_user != author:
|
||||
content = "📌 "+_("[{author}]({author_url}) edited the {field} on [{target}]({target_url})'s profile. *({desc})*").format(author=author,
|
||||
author_url=author_url,
|
||||
target=target_user,
|
||||
target_url=link,
|
||||
field=profile_field_name(change["logparams"]['4:section'], False),
|
||||
desc=BeautifulSoup(change["parsedcomment"], "lxml").get_text())
|
||||
else:
|
||||
content = "📌 " + _("[{author}]({author_url}) edited the {field} on [their own]({target_url}) profile. *({desc})*").format(
|
||||
author=author,
|
||||
author_url=author_url,
|
||||
target_url=link,
|
||||
field=profile_field_name(change["logparams"]['4:section'], False),
|
||||
desc=BeautifulSoup(change["parsedcomment"], "lxml").get_text())
|
||||
elif action in ("rights/rights", "rights/autopromote"):
|
||||
link = link_formatter(create_article_path("User:{user}".format(user=change["title"].split(":")[1]), WIKI_ARTICLE_PATH))
|
||||
old_groups = []
|
||||
|
@ -356,6 +388,150 @@ async def compact_formatter(action, change, parsed_comment, categories, recent_c
|
|||
author=author, author_url=author_url, wiki_name=change["logparams"].get("wiki", _("Unknown")),
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/mark":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
if "?" in link:
|
||||
link = link + "&oldid=" + change["logparams"]["revision"]
|
||||
else:
|
||||
link = link + "?oldid=" + change["logparams"]["revision"]
|
||||
link = link_formatter(link)
|
||||
content = "🌐 " + _("[{author}]({author_url}) marked [{article}]({article_url}) for translation{comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/unmark":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
content = "🌐 " + _("[{author}]({author_url}) removed [{article}]({article_url}) from the translation system{comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/moveok":
|
||||
link = link_formatter(create_article_path(change["logparams"]["target"], WIKI_ARTICLE_PATH))
|
||||
content = "🌐 " + _("[{author}]({author_url}) completed moving translation pages from *{article}* to [{target}]({target_url}){comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], target=change["logparams"]["target"], target_url=link,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/movenok":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
target_url = link_formatter(create_article_path(change["logparams"]["target"], WIKI_ARTICLE_PATH))
|
||||
content = "🌐 " + _("[{author}]({author_url}) encountered a problem while moving [{article}]({article_url}) to [{target}]({target_url}){comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
target=change["logparams"]["target"], target_url=target_url,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/deletefok":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
content = "🌐 " + _("[{author}]({author_url}) completed deletion of translatable page [{article}]({article_url}){comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/deletefnok":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
target_url = link_formatter(create_article_path(change["logparams"]["target"], WIKI_ARTICLE_PATH))
|
||||
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,
|
||||
article=change["title"], article_url=link,
|
||||
target=change["logparams"]["target"], target_url=target_url,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/deletelok":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
content = "🌐 " + _("[{author}]({author_url}) completed deletion of translation page [{article}]({article_url}){comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/deletelnok":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
target_url = link_formatter(create_article_path(change["logparams"]["target"], WIKI_ARTICLE_PATH))
|
||||
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,
|
||||
article=change["title"], article_url=link,
|
||||
target=change["logparams"]["target"], target_url=target_url,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/encourage":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
content = "🌐 " + _("[{author}]({author_url}) encouraged translation of [{article}]({article_url}){comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/discourage":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
content = "🌐 " + _("[{author}]({author_url}) discouraged translation of [{article}]({article_url}){comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/prioritylanguages":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
if "languages" in change["logparams"]:
|
||||
languages = "`, `".join(change["logparams"]["languages"].split(","))
|
||||
if change["logparams"]["force"] == "on":
|
||||
content = "🌐 " + _("[{author}]({author_url}) limited languages for [{article}]({article_url}) to `{languages}`{comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
languages=languages, comment=parsed_comment
|
||||
)
|
||||
else:
|
||||
content = "🌐 " + _("[{author}]({author_url}) set the priority languages for [{article}]({article_url}) to `{languages}`{comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
languages=languages, comment=parsed_comment
|
||||
)
|
||||
else:
|
||||
content = "🌐 " + _("[{author}]({author_url}) removed priority languages from [{article}]({article_url}){comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/associate":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
content = "🌐 " + _("[{author}]({author_url}) added translatable page [{article}]({article_url}) to aggregate group \"{group}\"{comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
group=change["logparams"]["aggregategroup"], comment=parsed_comment
|
||||
)
|
||||
elif action == "pagetranslation/dissociate":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
content = "🌐 " + _("[{author}]({author_url}) removed translatable page [{article}]({article_url}) from aggregate group \"{group}\"{comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
group=change["logparams"]["aggregategroup"], comment=parsed_comment
|
||||
)
|
||||
elif action == "translationreview/message":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
if "?" in link:
|
||||
link = link + "&oldid=" + change["logparams"]["revision"]
|
||||
else:
|
||||
link = link + "?oldid=" + change["logparams"]["revision"]
|
||||
link = link_formatter(link)
|
||||
content = "🌐 " + _("[{author}]({author_url}) reviewed translation [{article}]({article_url}){comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
comment=parsed_comment
|
||||
)
|
||||
elif action == "translationreview/group":
|
||||
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
|
||||
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(
|
||||
author=author, author_url=author_url, language=change["logparams"]["language"],
|
||||
article=change["logparams"]["group-label"], article_url=link,
|
||||
old_state=change["logparams"]["old-state"], new_state=change["logparams"]["new-state"],
|
||||
comment=parsed_comment
|
||||
)
|
||||
else:
|
||||
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"],
|
||||
article=change["logparams"]["group-label"], article_url=link,
|
||||
new_state=change["logparams"]["new-state"], comment=parsed_comment
|
||||
)
|
||||
elif action == "renameuser/renameuser":
|
||||
link = link_formatter(create_article_path("User:"+change["logparams"]["newuser"], WIKI_ARTICLE_PATH))
|
||||
edits = change["logparams"]["edits"]
|
||||
|
@ -372,7 +548,7 @@ async def compact_formatter(action, change, parsed_comment, categories, recent_c
|
|||
content = "👁️ "+_("An action has been hidden by administration.")
|
||||
else:
|
||||
logger.warning("No entry for {event} with params: {params}".format(event=action, params=change))
|
||||
if not settings["support"]:
|
||||
if not settings.get("support", None):
|
||||
return
|
||||
else:
|
||||
content = "❓ "+_("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"])
|
||||
|
@ -472,7 +648,7 @@ async def embed_formatter(action, change, parsed_comment, categories, recent_cha
|
|||
logger.warning("Request for additional image information have failed. The preview will not be shown.")
|
||||
if action in ("upload/overwrite", "upload/revert"):
|
||||
if additional_info_retrieved:
|
||||
article_encoded = change["title"].replace(" ", "_").replace("%", "%25").replace("\\", "%5C").replace("&", "%26")
|
||||
article_encoded = change["title"].replace(" ", "_").replace("%", "%25").replace("\\", "%5C").replace("&", "%26").replace(')', '\\)')
|
||||
try:
|
||||
revision = img_info[num+1]
|
||||
except IndexError:
|
||||
|
@ -532,8 +708,11 @@ async def embed_formatter(action, change, parsed_comment, categories, recent_cha
|
|||
english_length = english_length.rstrip("s").strip()
|
||||
block_time = _("for {num} {translated_length}").format(num=english_length_num, translated_length=ngettext(english_length, english_length + "s", int(english_length_num)))
|
||||
except (AttributeError, ValueError):
|
||||
date_time_obj = datetime.datetime.strptime(change["logparams"]["expiry"], '%Y-%m-%dT%H:%M:%SZ')
|
||||
block_time = _("until {}").format(date_time_obj.strftime("%Y-%m-%d %H:%M:%S UTC"))
|
||||
if "expiry" in change["logparams"]:
|
||||
date_time_obj = datetime.datetime.strptime(change["logparams"]["expiry"], '%Y-%m-%dT%H:%M:%SZ')
|
||||
block_time = _("until {}").format(date_time_obj.strftime("%Y-%m-%d %H:%M:%S UTC"))
|
||||
else:
|
||||
block_time = _("unknown expiry time") # THIS IS HERE JUST TEMPORARY AS A HOT FIX TO #157, will be changed with release of 1.13
|
||||
if "sitewide" not in change["logparams"]:
|
||||
restriction_description = ""
|
||||
if "restrictions" in change["logparams"]:
|
||||
|
@ -569,49 +748,67 @@ async def embed_formatter(action, change, parsed_comment, categories, recent_cha
|
|||
user = change["title"].split(':', 1)[1]
|
||||
embed["title"] = _("Unblocked {blocked_user}").format(blocked_user=user)
|
||||
elif action == "curseprofile/comment-created":
|
||||
if settings["appearance"]["embed"]["show_edit_changes"]:
|
||||
if message_target[0][1] == 3:
|
||||
parsed_comment = await recent_changes.pull_comment(change["logparams"]["4:comment_id"], WIKI_API_PATH, rate_limiter)
|
||||
link = create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]), WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Left a comment on {target}'s profile").format(target=change["title"].split(':')[1]) if change["title"].split(':')[1] != \
|
||||
change["user"] else _(
|
||||
"Left a comment on their own profile")
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
if target_user != change["user"]:
|
||||
embed["title"] = _("Left a comment on {target}'s profile").format(target=target_user)
|
||||
else:
|
||||
embed["title"] = _("Left a comment on their own profile")
|
||||
elif action == "curseprofile/comment-replied":
|
||||
if settings["appearance"]["embed"]["show_edit_changes"]:
|
||||
if message_target[0][1] == 3:
|
||||
parsed_comment = await recent_changes.pull_comment(change["logparams"]["4:comment_id"], WIKI_API_PATH, rate_limiter)
|
||||
link = create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]), WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Replied to a comment on {target}'s profile").format(target=change["title"].split(':')[1]) if change["title"].split(':')[1] != \
|
||||
change["user"] else _(
|
||||
"Replied to a comment on their own profile")
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
if target_user != change["user"]:
|
||||
embed["title"] = _("Replied to a comment on {target}'s profile").format(target=target_user)
|
||||
else:
|
||||
embed["title"] = _("Replied to a comment on their own profile")
|
||||
elif action == "curseprofile/comment-edited":
|
||||
if settings["appearance"]["embed"]["show_edit_changes"]:
|
||||
if message_target[0][1] == 3:
|
||||
parsed_comment = await recent_changes.pull_comment(change["logparams"]["4:comment_id"], WIKI_API_PATH, rate_limiter)
|
||||
link = create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]), WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Edited a comment on {target}'s profile").format(target=change["title"].split(':')[1]) if change["title"].split(':')[1] != \
|
||||
change["user"] else _(
|
||||
"Edited a comment on their own profile")
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
if target_user != change["user"]:
|
||||
embed["title"] = _("Edited a comment on {target}'s profile").format(target=target_user)
|
||||
else:
|
||||
embed["title"] = _("Edited a comment on their own profile")
|
||||
elif action == "curseprofile/profile-edited":
|
||||
link = create_article_path("UserProfile:{target}".format(target=change["title"].split(':')[1]), WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Edited {target}'s profile").format(target=change["title"].split(':')[1]) if change["user"] != change["title"].split(':')[1] else _("Edited their own profile")
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
link = create_article_path("UserProfile:{target}".format(target=target_user), WIKI_ARTICLE_PATH)
|
||||
if target_user != change["user"]:
|
||||
embed["title"] = _("Edited {target}'s profile").format(target=target_user)
|
||||
else:
|
||||
embed["title"] = _("Edited their own profile")
|
||||
if not change["parsedcomment"]: # If the field is empty
|
||||
parsed_comment = _("Cleared the {field} field").format(field=profile_field_name(change["logparams"]['4:section'], True, message_target[0][0]))
|
||||
else:
|
||||
parsed_comment = _("{field} field changed to: {desc}").format(field=profile_field_name(change["logparams"]['4:section'], True, message_target[0][0]), desc=BeautifulSoup(change["parsedcomment"], "lxml").get_text())
|
||||
elif action == "curseprofile/comment-purged":
|
||||
link = create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]), WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Purged a comment on {target}'s profile").format(target=change["title"].split(':')[1])
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
if target_user != change["user"]:
|
||||
embed["title"] = _("Purged a comment on {target}'s profile").format(target=target_user)
|
||||
else:
|
||||
embed["title"] = _("Purged a comment on their own profile")
|
||||
elif action == "curseprofile/comment-deleted":
|
||||
if "4:comment_id" in change["logparams"]:
|
||||
link = create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]), WIKI_ARTICLE_PATH)
|
||||
else:
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Deleted a comment on {target}'s profile").format(target=change["title"].split(':')[1])
|
||||
target_user = change["title"].split(':', 1)[1]
|
||||
if target_user != change["user"]:
|
||||
embed["title"] = _("Deleted a comment on {target}'s profile").format(target=target_user)
|
||||
else:
|
||||
embed["title"] = _("Deleted a comment on their own profile")
|
||||
elif action in ("rights/rights", "rights/autopromote"):
|
||||
link = create_article_path("User:{}".format(change["title"].split(":")[1]), WIKI_ARTICLE_PATH)
|
||||
if action == "rights/rights":
|
||||
embed["title"] = _("Changed group membership for {target}").format(target=change["title"].split(":")[1])
|
||||
else:
|
||||
change["user"] = _("System")
|
||||
author_url = ""
|
||||
embed.set_author(_("System"), author_url)
|
||||
embed["title"] = _("{target} got autopromoted to a new usergroup").format(
|
||||
target=change["title"].split(":")[1])
|
||||
if len(change["logparams"]["oldgroups"]) < len(change["logparams"]["newgroups"]):
|
||||
|
@ -785,6 +982,69 @@ async def embed_formatter(action, change, parsed_comment, categories, recent_cha
|
|||
elif action == "managewiki/unlock":
|
||||
embed["title"] = _("Unlocked a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", _("Unknown")))
|
||||
link = create_article_path("", WIKI_ARTICLE_PATH)
|
||||
elif action == "pagetranslation/mark":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
if "?" in link:
|
||||
link = link + "&oldid=" + change["logparams"]["revision"]
|
||||
else:
|
||||
link = link + "?oldid=" + change["logparams"]["revision"]
|
||||
embed["title"] = _("Marked \"{article}\" for translation").format(article=change["title"])
|
||||
elif action == "pagetranslation/unmark":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Removed \"{article}\" from the translation system").format(article=change["title"])
|
||||
elif action == "pagetranslation/moveok":
|
||||
link = create_article_path(change["logparams"]["target"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Completed moving translation pages from \"{article}\" to \"{target}\"").format(article=change["title"], target=change["logparams"]["target"])
|
||||
elif action == "pagetranslation/movenok":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Encountered a problem while moving \"{article}\" to \"{target}\"").format(article=change["title"], target=change["logparams"]["target"])
|
||||
elif action == "pagetranslation/deletefok":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Completed deletion of translatable page \"{article}\"").format(article=change["title"])
|
||||
elif action == "pagetranslation/deletefnok":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Failed to delete \"{article}\" which belongs to translatable page \"{target}\"").format(article=change["title"], target=change["logparams"]["target"])
|
||||
elif action == "pagetranslation/deletelok":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Completed deletion of translation page \"{article}\"").format(article=change["title"])
|
||||
elif action == "pagetranslation/deletelnok":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Failed to delete \"{article}\" which belongs to translation page \"{target}\"").format(article=change["title"], target=change["logparams"]["target"])
|
||||
elif action == "pagetranslation/encourage":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Encouraged translation of \"{article}\"").format(article=change["title"])
|
||||
elif action == "pagetranslation/discourage":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Discouraged translation of \"{article}\"").format(article=change["title"])
|
||||
elif action == "pagetranslation/prioritylanguages":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
if "languages" in change["logparams"]:
|
||||
languages = "`, `".join(change["logparams"]["languages"].split(","))
|
||||
if change["logparams"]["force"] == "on":
|
||||
embed["title"] = _("Limited languages for \"{article}\" to `{languages}`").format(article=change["title"], languages=languages)
|
||||
else:
|
||||
embed["title"] = _("Priority languages for \"{article}\" set to `{languages}`").format(article=change["title"], languages=languages)
|
||||
else:
|
||||
embed["title"] = _("Removed priority languages from \"{article}\"").format(article=change["title"])
|
||||
elif action == "pagetranslation/associate":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Added translatable page \"{article}\" to aggregate group \"{group}\"").format(article=change["title"], group=change["logparams"]["aggregategroup"])
|
||||
elif action == "pagetranslation/dissociate":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Removed translatable page \"{article}\" from aggregate group \"{group}\"").format(article=change["title"], group=change["logparams"]["aggregategroup"])
|
||||
elif action == "translationreview/message":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
if "?" in link:
|
||||
link = link + "&oldid=" + change["logparams"]["revision"]
|
||||
else:
|
||||
link = link + "?oldid=" + change["logparams"]["revision"]
|
||||
embed["title"] = _("Reviewed translation \"{article}\"").format(article=change["title"])
|
||||
elif action == "translationreview/group":
|
||||
link = create_article_path(change["title"], WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Changed the state of `{language}` translations of \"{article}\"").format(language=change["logparams"]["language"], article=change["title"])
|
||||
if "old-state" in change["logparams"]:
|
||||
embed.add_field(_("Old state"), change["logparams"]["old-state"], inline=True)
|
||||
embed.add_field(_("New state"), change["logparams"]["new-state"], inline=True)
|
||||
elif action == "renameuser/renameuser":
|
||||
edits = change["logparams"]["edits"]
|
||||
if edits > 0:
|
||||
|
@ -794,14 +1054,14 @@ async def embed_formatter(action, change, parsed_comment, categories, recent_cha
|
|||
link = create_article_path("User:"+change["logparams"]["newuser"], WIKI_ARTICLE_PATH)
|
||||
elif action == "suppressed":
|
||||
link = create_article_path("", WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Action has been hidden by administration.")
|
||||
embed["title"] = _("Action has been hidden by administration")
|
||||
embed["author"]["name"] = _("Unknown")
|
||||
else:
|
||||
logger.warning("No entry for {event} with params: {params}".format(event=action, params=change))
|
||||
link = create_article_path("Special:RecentChanges", WIKI_ARTICLE_PATH)
|
||||
embed["title"] = _("Unknown event `{event}`").format(event=action)
|
||||
embed["color"] = 0
|
||||
if settings["support"]:
|
||||
if settings.get("support", None):
|
||||
change_params = "[```json\n{params}\n```]({support})".format(params=json.dumps(change, indent=2), support=settings["support"])
|
||||
if len(change_params) > 1000:
|
||||
embed.add_field(_("Report this on the support server"), settings["support"])
|
||||
|
@ -824,6 +1084,8 @@ async def embed_formatter(action, change, parsed_comment, categories, recent_cha
|
|||
else:
|
||||
tag_displayname.append(tag)
|
||||
embed.add_field(_("Tags"), ", ".join(tag_displayname))
|
||||
if len(embed["title"]) > 254:
|
||||
embed["title"] = embed["title"][0:253]+"…"
|
||||
logger.debug("Current params in edit action: {}".format(change))
|
||||
if categories and not (len(categories["new"]) == 0 and len(categories["removed"]) == 0):
|
||||
new_cat = (_("**Added**: ") + ", ".join(list(categories["new"])[0:16]) + ("\n" if len(categories["new"])<=15 else _(" and {} more\n").format(len(categories["new"])-15))) if categories["new"] else ""
|
||||
|
|
|
@ -19,7 +19,7 @@ class UpdateDB:
|
|||
if update[2] is None:
|
||||
sql = "UPDATE rcgcdw SET rcid = ? WHERE wiki = ? AND ( rcid != -1 OR rcid IS NULL )"
|
||||
else:
|
||||
sql = "UPDATE rcgcdw SET postid = ? WHERE wiki = ?"
|
||||
sql = "UPDATE rcgcdw SET postid = ? WHERE wiki = ? AND ( postid != '-1' OR postid IS NULL )"
|
||||
db_cursor.execute(sql, (update[1], update[0],))
|
||||
db_connection.commit()
|
||||
self.clear_list()
|
||||
|
|
15
src/wiki.py
15
src/wiki.py
|
@ -17,21 +17,6 @@ from bs4 import BeautifulSoup
|
|||
|
||||
logger = logging.getLogger("rcgcdb.wiki")
|
||||
|
||||
supported_logs = {"protect/protect", "protect/modify", "protect/unprotect", "upload/overwrite", "upload/upload",
|
||||
"delete/delete", "delete/delete_redir", "delete/restore", "delete/revision", "delete/event",
|
||||
"import/upload", "import/interwiki", "merge/merge", "move/move", "move/move_redir",
|
||||
"protect/move_prot", "block/block", "block/unblock", "block/reblock", "rights/rights",
|
||||
"rights/autopromote", "abusefilter/modify", "abusefilter/create", "interwiki/iw_add",
|
||||
"interwiki/iw_edit", "interwiki/iw_delete", "curseprofile/comment-created",
|
||||
"curseprofile/comment-edited", "curseprofile/comment-deleted", "curseprofile/comment-purged",
|
||||
"curseprofile/profile-edited", "curseprofile/comment-replied", "contentmodel/change", "sprite/sprite",
|
||||
"sprite/sheet", "sprite/slice", "managetags/create", "managetags/delete", "managetags/activate",
|
||||
"managetags/deactivate", "tag/update", "cargo/createtable", "cargo/deletetable",
|
||||
"cargo/recreatetable", "cargo/replacetable", "upload/revert", "newusers/create",
|
||||
"newusers/autocreate", "newusers/create2", "newusers/byemail", "newusers/newusers",
|
||||
"managewiki/settings", "managewiki/delete", "managewiki/lock", "managewiki/unlock",
|
||||
"managewiki/namespaces", "managewiki/namespaces-delete", "managewiki/rights", "managewiki/undelete"}
|
||||
|
||||
|
||||
@dataclass
|
||||
class Wiki:
|
||||
|
|
Loading…
Reference in a new issue