Merge remote-tracking branch 'origin/iw-import' into testing

This commit is contained in:
Frisk 2023-09-16 19:26:00 +02:00
commit c8dad99ca4

View file

@ -787,11 +787,14 @@ def embed_import_interwiki(ctx, change):
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
embed_helper(ctx, embed, change)
embed["url"] = ctx.client.create_article_path(sanitize_to_url(change["title"]))
embed["title"] = ctx.ngettext("Imported {article} with {count} revision from \"{source}\"",
"Imported {article} with {count} revisions from \"{source}\"",
change["logparams"]["count"]).format(
article=sanitize_to_markdown(change["title"]), count=change["logparams"]["count"],
source=sanitize_to_markdown(change["logparams"]["interwiki_title"]))
if "count" in change["logparams"] and "interwiki_title" in change["logparams"]:
embed["title"] = ctx.ngettext("Imported {article} with {count} revision from \"{source}\"",
"Imported {article} with {count} revisions from \"{source}\"",
change["logparams"]["count"]).format(
article=sanitize_to_markdown(change["title"]), count=change["logparams"]["count"],
source=sanitize_to_markdown(change["logparams"]["interwiki_title"]))
else:
embed["title"] = ctx._("Imported {article}").format(article=sanitize_to_markdown(change["title"]))
return embed
@ -799,16 +802,21 @@ def embed_import_interwiki(ctx, change):
def compact_import_interwiki(ctx, change):
link = clean_link(ctx.client.create_article_path(sanitize_to_url(change["title"])))
author, author_url = compact_author(ctx, change)
source_link = clean_link(ctx.client.create_article_path(change["logparams"]["interwiki_title"]))
parsed_comment = compact_summary(ctx)
content = ctx.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, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link,
count=change["logparams"]["count"], source=sanitize_to_markdown(change["logparams"]["interwiki_title"]),
source_url=source_link,
comment=parsed_comment)
if "count" in change["logparams"] and "interwiki_title" in change["logparams"]:
source_link = clean_link(ctx.client.create_article_path(change["logparams"]["interwiki_title"]))
content = ctx.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, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link,
count=change["logparams"]["count"], source=sanitize_to_markdown(change["logparams"]["interwiki_title"]),
source_url=source_link,
comment=parsed_comment)
else:
content = ctx._("[{author}]({author_url}) imported [{article}]({article_url}){comment}").format(
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link,
comment=parsed_comment)
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)