mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
Updated formatters accordingly to new model, added gettext as alias for _
This commit is contained in:
parent
9234d8589c
commit
c4dd120e5b
|
@ -46,10 +46,10 @@ def embed_abuselog(ctx: Context, change: dict):
|
||||||
action = "abuselog/{}".format(change["result"])
|
action = "abuselog/{}".format(change["result"])
|
||||||
embed = DiscordMessage(ctx.message_type, action, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, action, ctx.webhook_url)
|
||||||
author = abuse_filter_format_user(change, ctx.settings)
|
author = abuse_filter_format_user(change, ctx.settings)
|
||||||
embed["title"] = _("{user} triggered \"{abuse_filter}\"").format(user=author, abuse_filter=sanitize_to_markdown(change["filter"]))
|
embed["title"] = ctx._("{user} triggered \"{abuse_filter}\"").format(user=author, abuse_filter=sanitize_to_markdown(change["filter"]))
|
||||||
embed.add_field(_("Performed"), abusefilter_translatable(change["action"], ctx._, _("Unknown")))
|
embed.add_field(ctx._("Performed"), abusefilter_translatable(change["action"], ctx._, ctx._("Unknown")))
|
||||||
embed.add_field(_("Action taken"), abusefilter_translatable(change["result"], ctx._, _("Unknown")))
|
embed.add_field(ctx._("Action taken"), abusefilter_translatable(change["result"], ctx._, ctx._("Unknown")))
|
||||||
embed.add_field(_("Title"), sanitize_to_markdown(change.get("title", _("Unknown"))))
|
embed.add_field(ctx._("Title"), sanitize_to_markdown(change.get("title", ctx._("Unknown"))))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,11 +58,11 @@ def compact_abuselog(ctx: Context, change: dict):
|
||||||
action = "abuselog/{}".format(change["result"])
|
action = "abuselog/{}".format(change["result"])
|
||||||
author_url = clean_link(create_article_path("User:{user}".format(user=change["user"])))
|
author_url = clean_link(create_article_path("User:{user}".format(user=change["user"])))
|
||||||
author = abuse_filter_format_user(change, ctx.settings)
|
author = abuse_filter_format_user(change, ctx.settings)
|
||||||
message = _("[{author}]({author_url}) triggered *{abuse_filter}*, performing the action \"{action}\" on *[{target}]({target_url})* - action taken: {result}.").format(
|
message = ctx._("[{author}]({author_url}) triggered *{abuse_filter}*, performing the action \"{action}\" on *[{target}]({target_url})* - action taken: {result}.").format(
|
||||||
author=author, author_url=author_url, abuse_filter=sanitize_to_markdown(change["filter"]),
|
author=author, author_url=author_url, abuse_filter=sanitize_to_markdown(change["filter"]),
|
||||||
action=abusefilter_translatable(change["action"], ctx._, _("Unknown")), target=change.get("title", _("Unknown")),
|
action=abusefilter_translatable(change["action"], ctx._, ctx._("Unknown")), target=change.get("title", ctx._("Unknown")),
|
||||||
target_url=clean_link(create_article_path(sanitize_to_url(change.get("title", _("Unknown"))))),
|
target_url=clean_link(create_article_path(sanitize_to_url(change.get("title", ctx._("Unknown"))))),
|
||||||
result=abusefilter_translatable(change["result"], ctx._, _("Unknown")))
|
result=abusefilter_translatable(change["result"], ctx._, ctx._("Unknown")))
|
||||||
return DiscordMessage(ctx.message_type, action, ctx.webhook_url, content=message)
|
return DiscordMessage(ctx.message_type, action, ctx.webhook_url, content=message)
|
||||||
|
|
||||||
# abusefilter/modify - AbuseFilter filter modification
|
# abusefilter/modify - AbuseFilter filter modification
|
||||||
|
@ -75,7 +75,7 @@ def embed_abuselog_modify(ctx: Context, change: dict):
|
||||||
embed["url"] = create_article_path(
|
embed["url"] = create_article_path(
|
||||||
"Special:AbuseFilter/history/{number}/diff/prev/{historyid}".format(number=change["logparams"]['newId'],
|
"Special:AbuseFilter/history/{number}/diff/prev/{historyid}".format(number=change["logparams"]['newId'],
|
||||||
historyid=change["logparams"]["historyId"]))
|
historyid=change["logparams"]["historyId"]))
|
||||||
embed["title"] = _("Edited abuse filter number {number}").format(number=change["logparams"]['newId'])
|
embed["title"] = ctx._("Edited abuse filter number {number}").format(number=change["logparams"]['newId'])
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ def compact_abuselog_modify(ctx: Context, change: dict):
|
||||||
historyid=change["logparams"][
|
historyid=change["logparams"][
|
||||||
"historyId"])))
|
"historyId"])))
|
||||||
|
|
||||||
content = _("[{author}]({author_url}) edited abuse filter [number {number}]({filter_url})").format(author=author,
|
content = ctx._("[{author}]({author_url}) edited abuse filter [number {number}]({filter_url})").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
number=change[
|
number=change[
|
||||||
"logparams"][
|
"logparams"][
|
||||||
|
@ -103,7 +103,7 @@ def embed_abuselog_create(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path("Special:AbuseFilter/{number}".format(number=change["logparams"]['newId']))
|
embed["url"] = create_article_path("Special:AbuseFilter/{number}".format(number=change["logparams"]['newId']))
|
||||||
embed["title"] = _("Created abuse filter number {number}").format(number=change["logparams"]['newId'])
|
embed["title"] = ctx._("Created abuse filter number {number}").format(number=change["logparams"]['newId'])
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ def compact_abuselog_create(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(
|
link = clean_link(
|
||||||
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,
|
content = ctx._("[{author}]({author_url}) created abuse filter [number {number}]({filter_url})").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
number=change[
|
number=change[
|
||||||
"logparams"][
|
"logparams"][
|
||||||
|
|
|
@ -17,14 +17,9 @@ import logging
|
||||||
import re
|
import re
|
||||||
from src.discord.message import DiscordMessage
|
from src.discord.message import DiscordMessage
|
||||||
from src.api import formatter
|
from src.api import formatter
|
||||||
from src.i18n import formatters_i18n
|
|
||||||
from src.api.context import Context
|
from src.api.context import Context
|
||||||
from src.api.util import embed_helper, compact_author, create_article_path, sanitize_to_markdown
|
from src.api.util import embed_helper, compact_author, create_article_path, sanitize_to_markdown
|
||||||
|
|
||||||
_ = formatters_i18n.gettext
|
|
||||||
ngettext = formatters_i18n.ngettext
|
|
||||||
|
|
||||||
|
|
||||||
# Cargo - https://www.mediawiki.org/wiki/Extension:Cargo
|
# Cargo - https://www.mediawiki.org/wiki/Extension:Cargo
|
||||||
# cargo/createtable - Creation of Cargo table
|
# cargo/createtable - Creation of Cargo table
|
||||||
|
|
||||||
|
@ -34,7 +29,7 @@ def embed_cargo_createtable(ctx: Context, change: dict):
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
||||||
embed["url"] = table.group(2)
|
embed["url"] = table.group(2)
|
||||||
embed["title"] = _("Created the Cargo table \"{table}\"").format(table=table.group(1))
|
embed["title"] = ctx._("Created the Cargo table \"{table}\"").format(table=table.group(1))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +37,7 @@ def embed_cargo_createtable(ctx: Context, change: dict):
|
||||||
def compact_cargo_createtable(ctx: Context, change: dict):
|
def compact_cargo_createtable(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
||||||
content = _("[{author}]({author_url}) created the Cargo table \"{table}\"").format(author=author,
|
content = ctx._("[{author}]({author_url}) created the Cargo table \"{table}\"").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
table=table)
|
table=table)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
@ -57,7 +52,7 @@ def embed_cargo_recreatetable(ctx: Context, change: dict):
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
||||||
embed["url"] = table.group(2)
|
embed["url"] = table.group(2)
|
||||||
embed["title"] = _("Recreated the Cargo table \"{table}\"").format(table=table.group(1))
|
embed["title"] = ctx._("Recreated the Cargo table \"{table}\"").format(table=table.group(1))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,7 +60,7 @@ def embed_cargo_recreatetable(ctx: Context, change: dict):
|
||||||
def compact_cargo_recreatetable(ctx: Context, change: dict):
|
def compact_cargo_recreatetable(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
||||||
content = _("[{author}]({author_url}) recreated the Cargo table \"{table}\"").format(author=author,
|
content = ctx._("[{author}]({author_url}) recreated the Cargo table \"{table}\"").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
table=table)
|
table=table)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
@ -80,7 +75,7 @@ def embed_cargo_replacetable(ctx: Context, change: dict):
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
||||||
embed["url"] = table.group(2)
|
embed["url"] = table.group(2)
|
||||||
embed["title"] = _("Replaced the Cargo table \"{table}\"").format(table=table.group(1))
|
embed["title"] = ctx._("Replaced the Cargo table \"{table}\"").format(table=table.group(1))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,7 +83,7 @@ def embed_cargo_replacetable(ctx: Context, change: dict):
|
||||||
def compact_cargo_replacetable(ctx: Context, change: dict):
|
def compact_cargo_replacetable(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
||||||
content = _("[{author}]({author_url}) replaced the Cargo table \"{table}\"").format(author=author,
|
content = ctx._("[{author}]({author_url}) replaced the Cargo table \"{table}\"").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
table=table)
|
table=table)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
@ -102,14 +97,14 @@ def embed_cargo_deletetable(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path("Special:CargoTables")
|
embed["url"] = create_article_path("Special:CargoTables")
|
||||||
embed["title"] = _("Deleted the Cargo table \"{table}\"").format(table=sanitize_to_markdown(change["logparams"]["0"]))
|
embed["title"] = ctx._("Deleted the Cargo table \"{table}\"").format(table=sanitize_to_markdown(change["logparams"]["0"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="cargo/deletetable")
|
@formatter.compact(event="cargo/deletetable")
|
||||||
def compact_cargo_deletetable(ctx: Context, change: dict):
|
def compact_cargo_deletetable(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
content = _("[{author}]({author_url}) deleted the Cargo table \"{table}\"").format(author=author,
|
content = ctx._("[{author}]({author_url}) deleted the Cargo table \"{table}\"").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
table=sanitize_to_markdown(change["logparams"]["0"]))
|
table=sanitize_to_markdown(change["logparams"]["0"]))
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
|
@ -15,17 +15,12 @@
|
||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from src.configloader import settings
|
|
||||||
from src.discord.message import DiscordMessage
|
from src.discord.message import DiscordMessage
|
||||||
from src.api import formatter
|
from src.api import formatter
|
||||||
from src.i18n import formatters_i18n
|
|
||||||
from src.api.context import Context
|
from src.api.context import Context
|
||||||
from src.api.util import embed_helper, clean_link, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url
|
from src.api.util import embed_helper, clean_link, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url
|
||||||
from src.misc import profile_field_name
|
from src.misc import profile_field_name
|
||||||
|
|
||||||
_ = formatters_i18n.gettext
|
|
||||||
ngettext = formatters_i18n.ngettext
|
|
||||||
|
|
||||||
|
|
||||||
# CurseProfile - https://help.fandom.com/wiki/Extension:CurseProfile
|
# CurseProfile - https://help.fandom.com/wiki/Extension:CurseProfile
|
||||||
# curseprofile/profile-edited - Editing user profile
|
# curseprofile/profile-edited - Editing user profile
|
||||||
|
@ -37,13 +32,13 @@ def embed_curseprofile_profile_edited(ctx: Context, change: dict) -> DiscordMess
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
target_user = change["title"].split(':', 1)[1]
|
target_user = change["title"].split(':', 1)[1]
|
||||||
if target_user != change["user"]:
|
if target_user != change["user"]:
|
||||||
embed["title"] = _("Edited {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
embed["title"] = ctx._("Edited {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
||||||
else:
|
else:
|
||||||
embed["title"] = _("Edited their own profile")
|
embed["title"] = ctx._("Edited their own profile")
|
||||||
if ctx.parsedcomment is None: # If the field is empty
|
if ctx.parsedcomment is None: # If the field is empty
|
||||||
embed["description"] = _("Cleared the {field} field").format(field=profile_field_name(change["logparams"]['4:section'], True))
|
embed["description"] = ctx._("Cleared the {field} field").format(field=profile_field_name(change["logparams"]['4:section'], True))
|
||||||
else:
|
else:
|
||||||
embed["description"] = _("{field} field changed to: {desc}").format(field=profile_field_name(change["logparams"]['4:section'], True), desc=ctx.parsedcomment)
|
embed["description"] = ctx._("{field} field changed to: {desc}").format(field=profile_field_name(change["logparams"]['4:section'], True), desc=ctx.parsedcomment)
|
||||||
embed["url"] = create_article_path("UserProfile:" + sanitize_to_url(target_user))
|
embed["url"] = create_article_path("UserProfile:" + sanitize_to_url(target_user))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -55,16 +50,16 @@ def compact_curseprofile_profile_edited(ctx: Context, change: dict) -> DiscordMe
|
||||||
link = clean_link(create_article_path("UserProfile:" + sanitize_to_url(target_user)))
|
link = clean_link(create_article_path("UserProfile:" + sanitize_to_url(target_user)))
|
||||||
if target_user != author:
|
if target_user != author:
|
||||||
if ctx.parsedcomment is None: # If the field is empty
|
if ctx.parsedcomment is None: # If the field is empty
|
||||||
edit_clear_message = _("[{author}]({author_url}) cleared the {field} on [{target}]({target_url})'s profile.")
|
edit_clear_message = ctx._("[{author}]({author_url}) cleared the {field} on [{target}]({target_url})'s profile.")
|
||||||
else:
|
else:
|
||||||
edit_clear_message = _("[{author}]({author_url}) edited the {field} on [{target}]({target_url})'s profile. *({desc})*")
|
edit_clear_message = ctx._("[{author}]({author_url}) edited the {field} on [{target}]({target_url})'s profile. *({desc})*")
|
||||||
content = edit_clear_message.format(author=author, author_url=author_url, target=sanitize_to_markdown(target_user), target_url=link,
|
content = edit_clear_message.format(author=author, author_url=author_url, target=sanitize_to_markdown(target_user), target_url=link,
|
||||||
field=profile_field_name(change["logparams"]['4:section'], False), desc=ctx.parsedcomment)
|
field=profile_field_name(change["logparams"]['4:section'], False), desc=ctx.parsedcomment)
|
||||||
else:
|
else:
|
||||||
if ctx.parsedcomment is None: # If the field is empty
|
if ctx.parsedcomment is None: # If the field is empty
|
||||||
edit_clear_message = _("[{author}]({author_url}) cleared the {field} on [their own]({target_url}) profile.")
|
edit_clear_message = ctx._("[{author}]({author_url}) cleared the {field} on [their own]({target_url}) profile.")
|
||||||
else:
|
else:
|
||||||
edit_clear_message = _("[{author}]({author_url}) edited the {field} on [their own]({target_url}) profile. *({desc})*")
|
edit_clear_message = ctx._("[{author}]({author_url}) edited the {field} on [their own]({target_url}) profile. *({desc})*")
|
||||||
content = edit_clear_message.format(author=author, author_url=author_url, target_url=link,
|
content = edit_clear_message.format(author=author, author_url=author_url, target_url=link,
|
||||||
field=profile_field_name(change["logparams"]['4:section'], False), desc=ctx.parsedcomment)
|
field=profile_field_name(change["logparams"]['4:section'], False), desc=ctx.parsedcomment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
@ -79,10 +74,10 @@ def embed_curseprofile_comment_created(ctx: Context, change: dict) -> DiscordMes
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
target_user = change["title"].split(':', 1)[1]
|
target_user = change["title"].split(':', 1)[1]
|
||||||
if target_user != change["user"]:
|
if target_user != change["user"]:
|
||||||
embed["title"] = _("Left a comment on {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
embed["title"] = ctx._("Left a comment on {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
||||||
else:
|
else:
|
||||||
embed["title"] = _("Left a comment on their own profile")
|
embed["title"] = ctx._("Left a comment on their own profile")
|
||||||
if settings["appearance"]["embed"]["show_edit_changes"]:
|
if ctx.settings["appearance"]["embed"]["show_edit_changes"]:
|
||||||
embed["description"] = ctx.client.pull_curseprofile_comment(change["logparams"]["4:comment_id"])
|
embed["description"] = ctx.client.pull_curseprofile_comment(change["logparams"]["4:comment_id"])
|
||||||
embed["url"] = create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]))
|
embed["url"] = create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]))
|
||||||
return embed
|
return embed
|
||||||
|
@ -94,10 +89,10 @@ def compact_curseprofile_comment_created(ctx: Context, change: dict) -> DiscordM
|
||||||
target_user = change["title"].split(':', 1)[1]
|
target_user = change["title"].split(':', 1)[1]
|
||||||
link = clean_link(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"])))
|
link = clean_link(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"])))
|
||||||
if target_user != author:
|
if target_user != author:
|
||||||
content = _("[{author}]({author_url}) left a [comment]({comment}) on {target}'s profile.").format(
|
content = ctx._("[{author}]({author_url}) left a [comment]({comment}) on {target}'s profile.").format(
|
||||||
author=author, author_url=author_url, comment=link, target=sanitize_to_markdown(target_user))
|
author=author, author_url=author_url, comment=link, target=sanitize_to_markdown(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 = ctx._("[{author}]({author_url}) left a [comment]({comment}) on their own profile.").format(author=author, author_url=author_url, comment=link)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,10 +105,10 @@ def embed_curseprofile_comment_edited(ctx: Context, change: dict) -> DiscordMess
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
target_user = change["title"].split(':', 1)[1]
|
target_user = change["title"].split(':', 1)[1]
|
||||||
if target_user != change["user"]:
|
if target_user != change["user"]:
|
||||||
embed["title"] = _("Edited a comment on {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
embed["title"] = ctx._("Edited a comment on {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
||||||
else:
|
else:
|
||||||
embed["title"] = _("Edited a comment on their own profile")
|
embed["title"] = ctx._("Edited a comment on their own profile")
|
||||||
if settings["appearance"]["embed"]["show_edit_changes"]:
|
if ctx.settings["appearance"]["embed"]["show_edit_changes"]:
|
||||||
embed["description"] = ctx.client.pull_curseprofile_comment(change["logparams"]["4:comment_id"])
|
embed["description"] = ctx.client.pull_curseprofile_comment(change["logparams"]["4:comment_id"])
|
||||||
embed["url"] = create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]))
|
embed["url"] = create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]))
|
||||||
return embed
|
return embed
|
||||||
|
@ -125,10 +120,10 @@ def compact_curseprofile_comment_edited(ctx: Context, change: dict) -> DiscordMe
|
||||||
target_user = change["title"].split(':', 1)[1]
|
target_user = change["title"].split(':', 1)[1]
|
||||||
link = clean_link(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"])))
|
link = clean_link(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"])))
|
||||||
if target_user != author:
|
if target_user != author:
|
||||||
content = _("[{author}]({author_url}) edited a [comment]({comment}) on {target}'s profile.").format(
|
content = ctx._("[{author}]({author_url}) edited a [comment]({comment}) on {target}'s profile.").format(
|
||||||
author=author, author_url=author_url, comment=link, target=sanitize_to_markdown(target_user))
|
author=author, author_url=author_url, comment=link, target=sanitize_to_markdown(target_user))
|
||||||
else:
|
else:
|
||||||
content = _("[{author}]({author_url}) edited a [comment]({comment}) on their own profile.").format(author=author, author_url=author_url, comment=link)
|
content = ctx._("[{author}]({author_url}) edited a [comment]({comment}) on their own profile.").format(author=author, author_url=author_url, comment=link)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,10 +136,10 @@ def embed_curseprofile_comment_replied(ctx: Context, change: dict) -> DiscordMes
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
target_user = change["title"].split(':', 1)[1]
|
target_user = change["title"].split(':', 1)[1]
|
||||||
if target_user != change["user"]:
|
if target_user != change["user"]:
|
||||||
embed["title"] = _("Replied to a comment on {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
embed["title"] = ctx._("Replied to a comment on {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
||||||
else:
|
else:
|
||||||
embed["title"] = _("Replied to a comment on their own profile")
|
embed["title"] = ctx._("Replied to a comment on their own profile")
|
||||||
if settings["appearance"]["embed"]["show_edit_changes"]:
|
if ctx.settings["appearance"]["embed"]["show_edit_changes"]:
|
||||||
embed["description"] = ctx.client.pull_curseprofile_comment(change["logparams"]["4:comment_id"])
|
embed["description"] = ctx.client.pull_curseprofile_comment(change["logparams"]["4:comment_id"])
|
||||||
embed["url"] = create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]))
|
embed["url"] = create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"]))
|
||||||
return embed
|
return embed
|
||||||
|
@ -156,10 +151,10 @@ def compact_curseprofile_comment_replied(ctx: Context, change: dict) -> DiscordM
|
||||||
target_user = change["title"].split(':', 1)[1]
|
target_user = change["title"].split(':', 1)[1]
|
||||||
link = clean_link(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"])))
|
link = clean_link(create_article_path("Special:CommentPermalink/{commentid}".format(commentid=change["logparams"]["4:comment_id"])))
|
||||||
if target_user != author:
|
if target_user != author:
|
||||||
content = _("[{author}]({author_url}) replied to a [comment]({comment}) on {target}'s profile.").format(
|
content = ctx._("[{author}]({author_url}) replied to a [comment]({comment}) on {target}'s profile.").format(
|
||||||
author=author, author_url=author_url, comment=link, target=sanitize_to_markdown(target_user))
|
author=author, author_url=author_url, comment=link, target=sanitize_to_markdown(target_user))
|
||||||
else:
|
else:
|
||||||
content = _("[{author}]({author_url}) replied to a [comment]({comment}) on their own profile.").format(author=author, author_url=author_url, comment=link)
|
content = ctx._("[{author}]({author_url}) replied to a [comment]({comment}) on their own profile.").format(author=author, author_url=author_url, comment=link)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,9 +167,9 @@ def embed_curseprofile_comment_deleted(ctx: Context, change: dict) -> DiscordMes
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
target_user = change["title"].split(':', 1)[1]
|
target_user = change["title"].split(':', 1)[1]
|
||||||
if target_user != change["user"]:
|
if target_user != change["user"]:
|
||||||
embed["title"] = _("Deleted a comment on {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
embed["title"] = ctx._("Deleted a comment on {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
||||||
else:
|
else:
|
||||||
embed["title"] = _("Deleted a comment on their own profile")
|
embed["title"] = ctx._("Deleted a comment on their own profile")
|
||||||
if ctx.parsedcomment is not None:
|
if ctx.parsedcomment is not None:
|
||||||
embed["description"] = ctx.parsedcomment
|
embed["description"] = ctx.parsedcomment
|
||||||
if "4:comment_id" in change["logparams"]:
|
if "4:comment_id" in change["logparams"]:
|
||||||
|
@ -194,10 +189,10 @@ def compact_curseprofile_comment_deleted(ctx: Context, change: dict) -> DiscordM
|
||||||
link = clean_link(create_article_path("UserProfile:" + sanitize_to_url(target_user)))
|
link = clean_link(create_article_path("UserProfile:" + sanitize_to_url(target_user)))
|
||||||
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
||||||
if target_user != author:
|
if target_user != author:
|
||||||
content = _("[{author}]({author_url}) deleted a [comment]({comment}) on {target}'s profile.{reason}").format(
|
content = ctx._("[{author}]({author_url}) deleted a [comment]({comment}) on {target}'s profile.{reason}").format(
|
||||||
author=author, author_url=author_url, comment=link, target=sanitize_to_markdown(target_user), reason=parsed_comment)
|
author=author, author_url=author_url, comment=link, target=sanitize_to_markdown(target_user), reason=parsed_comment)
|
||||||
else:
|
else:
|
||||||
content = _("[{author}]({author_url}) deleted a [comment]({comment}) on their own profile.{reason}").format(
|
content = ctx._("[{author}]({author_url}) deleted a [comment]({comment}) on their own profile.{reason}").format(
|
||||||
author=author, author_url=author_url, comment=link, reason=parsed_comment)
|
author=author, author_url=author_url, comment=link, reason=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
@ -211,9 +206,9 @@ def embed_curseprofile_comment_purged(ctx: Context, change: dict) -> DiscordMess
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
target_user = change["title"].split(':', 1)[1]
|
target_user = change["title"].split(':', 1)[1]
|
||||||
if target_user != change["user"]:
|
if target_user != change["user"]:
|
||||||
embed["title"] = _("Purged a comment on {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
embed["title"] = ctx._("Purged a comment on {target}'s profile").format(target=sanitize_to_markdown(target_user))
|
||||||
else:
|
else:
|
||||||
embed["title"] = _("Purged a comment on their own profile")
|
embed["title"] = ctx._("Purged a comment on their own profile")
|
||||||
if ctx.parsedcomment is not None:
|
if ctx.parsedcomment is not None:
|
||||||
embed["description"] = ctx.parsedcomment
|
embed["description"] = ctx.parsedcomment
|
||||||
embed["url"] = create_article_path("UserProfile:" + sanitize_to_url(target_user))
|
embed["url"] = create_article_path("UserProfile:" + sanitize_to_url(target_user))
|
||||||
|
@ -227,8 +222,8 @@ def compact_curseprofile_comment_purged(ctx: Context, change: dict) -> DiscordMe
|
||||||
link = clean_link(create_article_path("UserProfile:" + sanitize_to_url(target_user)))
|
link = clean_link(create_article_path("UserProfile:" + sanitize_to_url(target_user)))
|
||||||
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
||||||
if target_user != author:
|
if target_user != author:
|
||||||
content = _("[{author}]({author_url}) purged a comment on [{target}]({link})'s profile.{reason}").format(
|
content = ctx._("[{author}]({author_url}) purged a comment on [{target}]({link})'s profile.{reason}").format(
|
||||||
author=author, author_url=author_url, link=link, target=sanitize_to_markdown(target_user), reason=parsed_comment)
|
author=author, author_url=author_url, link=link, target=sanitize_to_markdown(target_user), reason=parsed_comment)
|
||||||
else:
|
else:
|
||||||
content = _("[{author}]({author_url}) purged a comment on [their own]({link}) profile.{reason}").format(author=author, author_url=author_url, link=link)
|
content = ctx._("[{author}]({author_url}) purged a comment on [their own]({link}) profile.{reason}").format(author=author, author_url=author_url, link=link)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content, reason=parsed_comment)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content, reason=parsed_comment)
|
||||||
|
|
|
@ -17,13 +17,9 @@
|
||||||
import logging
|
import logging
|
||||||
from src.discord.message import DiscordMessage
|
from src.discord.message import DiscordMessage
|
||||||
from src.api import formatter
|
from src.api import formatter
|
||||||
from src.i18n import formatters_i18n
|
|
||||||
from src.api.context import Context
|
from src.api.context import Context
|
||||||
from src.api.util import embed_helper, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url, compact_summary
|
from src.api.util import embed_helper, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url, compact_summary
|
||||||
|
|
||||||
_ = formatters_i18n.gettext
|
|
||||||
ngettext = formatters_i18n.ngettext
|
|
||||||
|
|
||||||
|
|
||||||
# DataDumps - https://www.mediawiki.org/wiki/Extension:DataDump
|
# DataDumps - https://www.mediawiki.org/wiki/Extension:DataDump
|
||||||
# datadump/generate - Generating a dump of wiki
|
# datadump/generate - Generating a dump of wiki
|
||||||
|
@ -33,7 +29,7 @@ ngettext = formatters_i18n.ngettext
|
||||||
def embed_datadump_generate(ctx: Context, change: dict) -> DiscordMessage:
|
def embed_datadump_generate(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["title"] = _("Generated {file} dump").format(file=change["logparams"]["filename"])
|
embed["title"] = ctx._("Generated {file} dump").format(file=change["logparams"]["filename"])
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -42,7 +38,7 @@ def embed_datadump_generate(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
def compact_datadump_generate(ctx: Context, change: dict):
|
def compact_datadump_generate(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) generated *{file}* dump{comment}").format(
|
content = ctx._("[{author}]({author_url}) generated *{file}* dump{comment}").format(
|
||||||
author=author, author_url=author_url, file=sanitize_to_markdown(change["logparams"]["filename"]),
|
author=author, author_url=author_url, file=sanitize_to_markdown(change["logparams"]["filename"]),
|
||||||
comment=parsed_comment
|
comment=parsed_comment
|
||||||
)
|
)
|
||||||
|
@ -55,7 +51,7 @@ def compact_datadump_generate(ctx: Context, change: dict):
|
||||||
def embed_datadump_delete(ctx: Context, change: dict) -> DiscordMessage:
|
def embed_datadump_delete(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["title"] = _("Deleted {file} dump").format(file=sanitize_to_markdown(change["logparams"]["filename"]))
|
embed["title"] = ctx._("Deleted {file} dump").format(file=sanitize_to_markdown(change["logparams"]["filename"]))
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -64,7 +60,7 @@ def embed_datadump_delete(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
def compact_datadump_delete(ctx: Context, change: dict) -> DiscordMessage:
|
def compact_datadump_delete(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) deleted *{file}* dump{comment}").format(
|
content = ctx._("[{author}]({author_url}) deleted *{file}* dump{comment}").format(
|
||||||
author=author, author_url=author_url, file=sanitize_to_markdown(change["logparams"]["filename"]),
|
author=author, author_url=author_url, file=sanitize_to_markdown(change["logparams"]["filename"]),
|
||||||
comment=parsed_comment
|
comment=parsed_comment
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,18 +17,12 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import datetime, logging
|
import datetime, logging
|
||||||
import gettext
|
|
||||||
from urllib.parse import quote_plus
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
from src.configloader import settings
|
|
||||||
from src.api.util import create_article_path, clean_link, sanitize_to_markdown
|
from src.api.util import create_article_path, clean_link, sanitize_to_markdown
|
||||||
from src.api.context import Context
|
from src.api.context import Context
|
||||||
from src.discord.queue import send_to_discord
|
from src.discord.queue import send_to_discord
|
||||||
from src.discord.message import DiscordMessage, DiscordMessageMetadata
|
from src.discord.message import DiscordMessage, DiscordMessageMetadata
|
||||||
from src.api import formatter
|
from src.api import formatter
|
||||||
from src.i18n import formatters_i18n
|
|
||||||
|
|
||||||
_ = formatters_i18n.gettext
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("rcgcdw.discussion_formatter")
|
logger = logging.getLogger("rcgcdw.discussion_formatter")
|
||||||
|
@ -38,12 +32,13 @@ class DiscussionsFromHellParser:
|
||||||
"""This class converts fairly convoluted Fandom jsonModal of a discussion post into Markdown formatted usable thing.
|
"""This class converts fairly convoluted Fandom jsonModal of a discussion post into Markdown formatted usable thing.
|
||||||
Takes string, returns string. Kudos to MarkusRost for allowing me to implement this formatter based on his code in Wiki-Bot."""
|
Takes string, returns string. Kudos to MarkusRost for allowing me to implement this formatter based on his code in Wiki-Bot."""
|
||||||
|
|
||||||
def __init__(self, post):
|
def __init__(self, post, ctx):
|
||||||
self.post = post
|
self.post = post
|
||||||
self.jsonModal = json.loads(post.get("jsonModel", "{}"))
|
self.jsonModal = json.loads(post.get("jsonModel", "{}"))
|
||||||
self.markdown_text = ""
|
self.markdown_text = ""
|
||||||
self.item_num = 1
|
self.item_num = 1
|
||||||
self.image_last = None
|
self.image_last = None
|
||||||
|
self.ctx = ctx
|
||||||
|
|
||||||
def parse(self) -> str:
|
def parse(self) -> str:
|
||||||
"""Main parsing logic"""
|
"""Main parsing logic"""
|
||||||
|
@ -103,14 +98,13 @@ class DiscussionsFromHellParser:
|
||||||
elif item["type"] == "listItem":
|
elif item["type"] == "listItem":
|
||||||
self.parse_content(item["content"], item["type"])
|
self.parse_content(item["content"], item["type"])
|
||||||
|
|
||||||
@staticmethod
|
def convert_marks(self, marks):
|
||||||
def convert_marks(marks):
|
|
||||||
prefix = ""
|
prefix = ""
|
||||||
suffix = ""
|
suffix = ""
|
||||||
for mark in marks:
|
for mark in marks:
|
||||||
if mark["type"] == "mention":
|
if mark["type"] == "mention":
|
||||||
prefix += "["
|
prefix += "["
|
||||||
suffix = "]({wiki}f/u/{userid}){suffix}".format(wiki=settings["fandom_discussions"]["wiki_url"],
|
suffix = "]({wiki}f/u/{userid}){suffix}".format(wiki=self.ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
userid=mark["attrs"]["userId"], suffix=suffix)
|
userid=mark["attrs"]["userId"], suffix=suffix)
|
||||||
elif mark["type"] == "strong":
|
elif mark["type"] == "strong":
|
||||||
prefix += "**"
|
prefix += "**"
|
||||||
|
@ -124,11 +118,11 @@ class DiscussionsFromHellParser:
|
||||||
return prefix, suffix
|
return prefix, suffix
|
||||||
|
|
||||||
|
|
||||||
def common_discussions(post: dict, embed: DiscordMessage):
|
def common_discussions(post: dict, embed: DiscordMessage, ctx: Context):
|
||||||
"""A method to setup embeds with common info shared between all types of discussion posts"""
|
"""A method to setup embeds with common info shared between all types of discussion posts"""
|
||||||
if settings["fandom_discussions"]["appearance"]["embed"]["show_content"]:
|
if ctx.settings["fandom_discussions"]["appearance"]["embed"]["show_content"]:
|
||||||
if post.get("jsonModel") is not None:
|
if post.get("jsonModel") is not None:
|
||||||
npost = DiscussionsFromHellParser(post)
|
npost = DiscussionsFromHellParser(post, ctx)
|
||||||
embed["description"] = npost.parse()
|
embed["description"] = npost.parse()
|
||||||
if npost.image_last:
|
if npost.image_last:
|
||||||
embed["image"]["url"] = npost.image_last
|
embed["image"]["url"] = npost.image_last
|
||||||
|
@ -143,36 +137,36 @@ def common_discussions(post: dict, embed: DiscordMessage):
|
||||||
|
|
||||||
@formatter.embed(event="discussion/forum")
|
@formatter.embed(event="discussion/forum")
|
||||||
def embed_discussion_forum(ctx: Context, post: dict):
|
def embed_discussion_forum(ctx: Context, post: dict):
|
||||||
embed = DiscordMessage("embed", "discussion", settings["fandom_discussions"]["webhookURL"])
|
embed = DiscordMessage("embed", "discussion", ctx.settings["fandom_discussions"]["webhookURL"])
|
||||||
common_discussions(post, embed)
|
common_discussions(post, embed, ctx)
|
||||||
author = _("unknown") # Fail safe
|
author = ctx._("unknown") # Fail safe
|
||||||
if post["createdBy"]["name"]:
|
if post["createdBy"]["name"]:
|
||||||
author = post["createdBy"]["name"]
|
author = post["createdBy"]["name"]
|
||||||
embed.set_author(author, "{url}f/u/{creatorId}".format(url=settings["fandom_discussions"]["wiki_url"],
|
embed.set_author(author, "{url}f/u/{creatorId}".format(url=ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
creatorId=post["creatorId"]),
|
creatorId=post["creatorId"]),
|
||||||
icon_url=post["createdBy"]["avatarUrl"])
|
icon_url=post["createdBy"]["avatarUrl"])
|
||||||
if not post["isReply"]:
|
if not post["isReply"]:
|
||||||
embed["url"] = "{url}f/p/{threadId}".format(url=settings["fandom_discussions"]["wiki_url"],
|
embed["url"] = "{url}f/p/{threadId}".format(url=ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
threadId=post["threadId"])
|
threadId=post["threadId"])
|
||||||
embed["title"] = _("Created \"{title}\"").format(title=post["title"])
|
embed["title"] = ctx._("Created \"{title}\"").format(title=post["title"])
|
||||||
thread_funnel = post.get("funnel")
|
thread_funnel = post.get("funnel")
|
||||||
if thread_funnel == "POLL":
|
if thread_funnel == "POLL":
|
||||||
embed.event_type = "discussion/forum/poll"
|
embed.event_type = "discussion/forum/poll"
|
||||||
embed["title"] = _("Created a poll \"{title}\"").format(title=post["title"])
|
embed["title"] = ctx._("Created a poll \"{title}\"").format(title=post["title"])
|
||||||
if settings["fandom_discussions"]["appearance"]["embed"]["show_content"]:
|
if ctx.settings["fandom_discussions"]["appearance"]["embed"]["show_content"]:
|
||||||
poll = post["poll"]
|
poll = post["poll"]
|
||||||
image_type = False
|
image_type = False
|
||||||
if poll["answers"][0]["image"] is not None:
|
if poll["answers"][0]["image"] is not None:
|
||||||
image_type = True
|
image_type = True
|
||||||
for num, option in enumerate(poll["answers"]):
|
for num, option in enumerate(poll["answers"]):
|
||||||
embed.add_field(option["text"] if image_type is True else _("Option {}").format(num + 1),
|
embed.add_field(option["text"] if image_type is True else ctx._("Option {}").format(num + 1),
|
||||||
option["text"] if image_type is False else _(
|
option["text"] if image_type is False else ctx._(
|
||||||
"__[View image]({image_url})__").format(image_url=option["image"]["url"]),
|
"__[View image]({image_url})__").format(image_url=option["image"]["url"]),
|
||||||
inline=True)
|
inline=True)
|
||||||
elif thread_funnel == "QUIZ":
|
elif thread_funnel == "QUIZ":
|
||||||
embed.event_type = "discussion/forum/quiz"
|
embed.event_type = "discussion/forum/quiz"
|
||||||
embed["title"] = _("Created a quiz \"{title}\"").format(title=post["title"])
|
embed["title"] = ctx._("Created a quiz \"{title}\"").format(title=post["title"])
|
||||||
if settings["fandom_discussions"]["appearance"]["embed"]["show_content"]:
|
if ctx.settings["fandom_discussions"]["appearance"]["embed"]["show_content"]:
|
||||||
quiz = post["_embedded"]["quizzes"][0]
|
quiz = post["_embedded"]["quizzes"][0]
|
||||||
embed["description"] = quiz["title"]
|
embed["description"] = quiz["title"]
|
||||||
if quiz["image"] is not None:
|
if quiz["image"] is not None:
|
||||||
|
@ -190,13 +184,13 @@ def embed_discussion_forum(ctx: Context, post: dict):
|
||||||
tag_displayname.append("[{title}]({url})".format(title=tag["articleTitle"], url=create_article_path(
|
tag_displayname.append("[{title}]({url})".format(title=tag["articleTitle"], url=create_article_path(
|
||||||
quote_plus(tag["articleTitle"].replace(" ", "_"), "/:?=&"))))
|
quote_plus(tag["articleTitle"].replace(" ", "_"), "/:?=&"))))
|
||||||
if len(", ".join(tag_displayname)) > 1000:
|
if len(", ".join(tag_displayname)) > 1000:
|
||||||
embed.add_field(formatters_i18n.pgettext("Fandom discussions Tags/Forums", "Tags"), formatters_i18n.pgettext("Fandom discussions amount of Tags/Forums", "{} tags").format(len(post["_embedded"]["thread"][0]["tags"])))
|
embed.add_field(ctx.pgettext("Fandom discussions Tags/Forums", "Tags"), ctx.pgettext("Fandom discussions amount of Tags/Forums", "{} tags").format(len(post["_embedded"]["thread"][0]["tags"])))
|
||||||
else:
|
else:
|
||||||
embed.add_field(formatters_i18n.pgettext("Fandom discussions Tags/Forums", "Tags"), ", ".join(tag_displayname))
|
embed.add_field(ctx.pgettext("Fandom discussions Tags/Forums", "Tags"), ", ".join(tag_displayname))
|
||||||
else:
|
else:
|
||||||
embed.event_type = "discussion/forum/reply"
|
embed.event_type = "discussion/forum/reply"
|
||||||
embed["title"] = _("Replied to \"{title}\"").format(title=post["_embedded"]["thread"][0]["title"])
|
embed["title"] = ctx._("Replied to \"{title}\"").format(title=post["_embedded"]["thread"][0]["title"])
|
||||||
embed["url"] = "{url}f/p/{threadId}/r/{postId}".format(url=settings["fandom_discussions"]["wiki_url"],
|
embed["url"] = "{url}f/p/{threadId}/r/{postId}".format(url=ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
threadId=post["threadId"], postId=post["id"])
|
threadId=post["threadId"], postId=post["id"])
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -204,20 +198,20 @@ def embed_discussion_forum(ctx: Context, post: dict):
|
||||||
@formatter.compact(event="discussion/forum")
|
@formatter.compact(event="discussion/forum")
|
||||||
def compact_discussion_forum(ctx: Context, post: dict):
|
def compact_discussion_forum(ctx: Context, post: dict):
|
||||||
message = None
|
message = None
|
||||||
author = _("unknown") # Fail safe
|
author = ctx._("unknown") # Fail safe
|
||||||
if post["createdBy"]["name"]:
|
if post["createdBy"]["name"]:
|
||||||
author = post["createdBy"]["name"]
|
author = post["createdBy"]["name"]
|
||||||
author_url = "<{url}f/u/{creatorId}>".format(url=settings["fandom_discussions"]["wiki_url"],
|
author_url = "<{url}f/u/{creatorId}>".format(url=ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
creatorId=post["creatorId"])
|
creatorId=post["creatorId"])
|
||||||
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 = ctx._("[{author}]({author_url}) created [{title}](<{url}f/p/{threadId}>) in {forumName}")
|
||||||
if thread_funnel == "POLL":
|
if thread_funnel == "POLL":
|
||||||
event_type = "discussion/forum/poll"
|
event_type = "discussion/forum/poll"
|
||||||
msg_text = _("[{author}]({author_url}) created a poll [{title}](<{url}f/p/{threadId}>) in {forumName}")
|
msg_text = ctx._("[{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"
|
event_type = "discussion/forum/quiz"
|
||||||
msg_text = _("[{author}]({author_url}) created a quiz [{title}](<{url}f/p/{threadId}>) in {forumName}")
|
msg_text = ctx._("[{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"
|
event_type = "discussion/forum/post"
|
||||||
else:
|
else:
|
||||||
|
@ -226,13 +220,13 @@ def compact_discussion_forum(ctx: Context, post: dict):
|
||||||
thread_funnel))
|
thread_funnel))
|
||||||
event_type = "unknown"
|
event_type = "unknown"
|
||||||
message = msg_text.format(author=author, author_url=author_url, title=post["title"],
|
message = msg_text.format(author=author, author_url=author_url, title=post["title"],
|
||||||
url=settings["fandom_discussions"]["wiki_url"], threadId=post["threadId"],
|
url=ctx.settings["fandom_discussions"]["wiki_url"], threadId=post["threadId"],
|
||||||
forumName=post["forumName"])
|
forumName=post["forumName"])
|
||||||
else:
|
else:
|
||||||
event_type = "discussion/forum/reply"
|
event_type = "discussion/forum/reply"
|
||||||
message = _(
|
message = ctx._(
|
||||||
"[{author}]({author_url}) created a [reply](<{url}f/p/{threadId}/r/{postId}>) to [{title}](<{url}f/p/{threadId}>) in {forumName}").format(
|
"[{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"],
|
author=author, author_url=author_url, url=ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
threadId=post["threadId"], postId=post["id"], title=post["_embedded"]["thread"][0]["title"],
|
threadId=post["threadId"], postId=post["id"], title=post["_embedded"]["thread"][0]["title"],
|
||||||
forumName=post["forumName"])
|
forumName=post["forumName"])
|
||||||
return DiscordMessage("compact", event_type, ctx.webhook_url, content=message)
|
return DiscordMessage("compact", event_type, ctx.webhook_url, content=message)
|
||||||
|
@ -240,83 +234,83 @@ def compact_discussion_forum(ctx: Context, post: dict):
|
||||||
# discussion/wall - Wall posts/replies
|
# discussion/wall - Wall posts/replies
|
||||||
|
|
||||||
|
|
||||||
def compact_author_discussions(post: dict):
|
def compact_author_discussions(post: dict, ctx: Context):
|
||||||
"""A common function for a few discussion related foramtters, it's formatting author's name and URL to their profile"""
|
"""A common function for a few discussion related foramtters, it's formatting author's name and URL to their profile"""
|
||||||
author = _("unknown") # Fail safe
|
author = ctx._("unknown") # Fail safe
|
||||||
if post["creatorIp"]:
|
if post["creatorIp"]:
|
||||||
author = post["creatorIp"][1:] if settings.get("hide_ips", False) is False else _("Unregistered user")
|
author = post["creatorIp"][1:] if ctx.settings.get("hide_ips", False) is False else ctx._("Unregistered user")
|
||||||
author_url = "<{url}wiki/Special:Contributions{creatorIp}>".format(url=settings["fandom_discussions"]["wiki_url"],
|
author_url = "<{url}wiki/Special:Contributions{creatorIp}>".format(url=ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
creatorIp=post["creatorIp"])
|
creatorIp=post["creatorIp"])
|
||||||
else:
|
else:
|
||||||
if post["createdBy"]["name"]:
|
if post["createdBy"]["name"]:
|
||||||
author = post["createdBy"]["name"]
|
author = post["createdBy"]["name"]
|
||||||
author_url = clean_link(create_article_path("User:{user}".format(user=author)))
|
author_url = clean_link(create_article_path("User:{user}".format(user=author)))
|
||||||
else:
|
else:
|
||||||
author_url = "<{url}f/u/{creatorId}>".format(url=settings["fandom_discussions"]["wiki_url"],
|
author_url = "<{url}f/u/{creatorId}>".format(url=ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
creatorId=post["creatorId"])
|
creatorId=post["creatorId"])
|
||||||
return author, author_url
|
return author, author_url
|
||||||
|
|
||||||
|
|
||||||
def embed_author_discussions(post: dict, embed: DiscordMessage):
|
def embed_author_discussions(post: dict, embed: DiscordMessage, ctx: Context):
|
||||||
author = _("unknown") # Fail safe
|
author = ctx._("unknown") # Fail safe
|
||||||
if post["creatorIp"]:
|
if post["creatorIp"]:
|
||||||
author = post["creatorIp"][1:]
|
author = post["creatorIp"][1:]
|
||||||
embed.set_author(author if settings.get("hide_ips", False) is False else _("Unregistered user"),
|
embed.set_author(author if ctx.settings.get("hide_ips", False) is False else ctx._("Unregistered user"),
|
||||||
"{url}wiki/Special:Contributions{creatorIp}".format(
|
"{url}wiki/Special:Contributions{creatorIp}".format(
|
||||||
url=settings["fandom_discussions"]["wiki_url"], creatorIp=post["creatorIp"]))
|
url=ctx.settings["fandom_discussions"]["wiki_url"], creatorIp=post["creatorIp"]))
|
||||||
else:
|
else:
|
||||||
if post["createdBy"]["name"]:
|
if post["createdBy"]["name"]:
|
||||||
author = post["createdBy"]["name"]
|
author = post["createdBy"]["name"]
|
||||||
embed.set_author(author, "{url}wiki/User:{creator}".format(url=settings["fandom_discussions"]["wiki_url"],
|
embed.set_author(author, "{url}wiki/User:{creator}".format(url=ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
creator=author.replace(" ", "_")),
|
creator=author.replace(" ", "_")),
|
||||||
icon_url=post["createdBy"]["avatarUrl"])
|
icon_url=post["createdBy"]["avatarUrl"])
|
||||||
else:
|
else:
|
||||||
embed.set_author(author, "{url}f/u/{creatorId}".format(url=settings["fandom_discussions"]["wiki_url"],
|
embed.set_author(author, "{url}f/u/{creatorId}".format(url=ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
creatorId=post["creatorId"]),
|
creatorId=post["creatorId"]),
|
||||||
icon_url=post["createdBy"]["avatarUrl"])
|
icon_url=post["createdBy"]["avatarUrl"])
|
||||||
|
|
||||||
|
|
||||||
@formatter.embed(event="discussion/wall")
|
@formatter.embed(event="discussion/wall")
|
||||||
def embed_discussion_wall(ctx: Context, post: dict):
|
def embed_discussion_wall(ctx: Context, post: dict):
|
||||||
embed = DiscordMessage("embed", "discussion", settings["fandom_discussions"]["webhookURL"])
|
embed = DiscordMessage("embed", "discussion", ctx.settings["fandom_discussions"]["webhookURL"])
|
||||||
common_discussions(post, embed)
|
common_discussions(post, embed)
|
||||||
embed_author_discussions(post, embed)
|
embed_author_discussions(post, embed, ctx)
|
||||||
user_wall = _("unknown") # Fail safe
|
user_wall = ctx._("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"]:
|
||||||
embed.event_type = "discussion/wall/post"
|
embed.event_type = "discussion/wall/post"
|
||||||
embed["url"] = "{url}wiki/Message_Wall:{user_wall}?threadId={threadId}".format(
|
embed["url"] = "{url}wiki/Message_Wall:{user_wall}?threadId={threadId}".format(
|
||||||
url=settings["fandom_discussions"]["wiki_url"], user_wall=quote_plus(user_wall.replace(" ", "_")),
|
url=ctx.settings["fandom_discussions"]["wiki_url"], user_wall=quote_plus(user_wall.replace(" ", "_")),
|
||||||
threadId=post["threadId"])
|
threadId=post["threadId"])
|
||||||
embed["title"] = _("Created \"{title}\" on {user}'s Message Wall").format(title=post["title"], user=user_wall)
|
embed["title"] = ctx._("Created \"{title}\" on {user}'s Message Wall").format(title=post["title"], user=user_wall)
|
||||||
else:
|
else:
|
||||||
embed.event_type = "discussion/wall/reply"
|
embed.event_type = "discussion/wall/reply"
|
||||||
embed["url"] = "{url}wiki/Message_Wall:{user_wall}?threadId={threadId}#{replyId}".format(
|
embed["url"] = "{url}wiki/Message_Wall:{user_wall}?threadId={threadId}#{replyId}".format(
|
||||||
url=settings["fandom_discussions"]["wiki_url"], user_wall=quote_plus(user_wall.replace(" ", "_")),
|
url=ctx.settings["fandom_discussions"]["wiki_url"], user_wall=quote_plus(user_wall.replace(" ", "_")),
|
||||||
threadId=post["threadId"], replyId=post["id"])
|
threadId=post["threadId"], replyId=post["id"])
|
||||||
embed["title"] = _("Replied to \"{title}\" on {user}'s Message Wall").format(
|
embed["title"] = ctx._("Replied to \"{title}\" on {user}'s Message Wall").format(
|
||||||
title=post["_embedded"]["thread"][0]["title"], user=user_wall)
|
title=post["_embedded"]["thread"][0]["title"], user=user_wall)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="discussion/wall")
|
@formatter.compact(event="discussion/wall")
|
||||||
def compact_discussion_wall(ctx: Context, post: dict):
|
def compact_discussion_wall(ctx: Context, post: dict):
|
||||||
author, author_url = compact_author_discussions(post)
|
author, author_url = compact_author_discussions(post, ctx)
|
||||||
user_wall = _("unknown") # Fail safe
|
user_wall = ctx._("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"]:
|
||||||
event_type = "discussion/wall/post"
|
event_type = "discussion/wall/post"
|
||||||
message = _(
|
message = ctx._(
|
||||||
"[{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_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"],
|
author=author, author_url=author_url, title=post["title"], url=ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
user=user_wall, user_wall=quote_plus(user_wall.replace(" ", "_")), threadId=post["threadId"])
|
user=user_wall, user_wall=quote_plus(user_wall.replace(" ", "_")), threadId=post["threadId"])
|
||||||
else:
|
else:
|
||||||
event_type = "discussion/wall/reply"
|
event_type = "discussion/wall/reply"
|
||||||
message = _(
|
message = ctx._(
|
||||||
"[{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_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"],
|
author=author, author_url=author_url, url=ctx.settings["fandom_discussions"]["wiki_url"],
|
||||||
title=post["_embedded"]["thread"][0]["title"], user=user_wall,
|
title=post["_embedded"]["thread"][0]["title"], user=user_wall,
|
||||||
user_wall=quote_plus(user_wall.replace(" ", "_")), threadId=post["threadId"], replyId=post["id"])
|
user_wall=quote_plus(user_wall.replace(" ", "_")), threadId=post["threadId"], replyId=post["id"])
|
||||||
return DiscordMessage("compact", event_type, ctx.webhook_url, content=message)
|
return DiscordMessage("compact", event_type, ctx.webhook_url, content=message)
|
||||||
|
@ -326,42 +320,42 @@ def compact_discussion_wall(ctx: Context, post: dict):
|
||||||
|
|
||||||
@formatter.embed(event="discussion/article_comment")
|
@formatter.embed(event="discussion/article_comment")
|
||||||
def embed_discussion_article_comment(ctx: Context, post: dict):
|
def embed_discussion_article_comment(ctx: Context, post: dict):
|
||||||
embed = DiscordMessage("embed", "discussion", settings["fandom_discussions"]["webhookURL"])
|
embed = DiscordMessage("embed", "discussion", ctx.settings["fandom_discussions"]["webhookURL"])
|
||||||
common_discussions(post, embed)
|
common_discussions(post, embed)
|
||||||
embed_author_discussions(post, embed)
|
embed_author_discussions(post, embed, ctx)
|
||||||
article_paths = ctx.comment_page
|
article_paths = ctx.comment_page
|
||||||
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": ctx._("unknown"), "fullUrl": ctx.settings["fandom_discussions"]["wiki_url"]} # No page known
|
||||||
if not post["isReply"]:
|
if not post["isReply"]:
|
||||||
embed.event_type = "discussion/comment/post"
|
embed.event_type = "discussion/comment/post"
|
||||||
embed["url"] = "{url}?commentId={commentId}".format(url=article_paths["fullUrl"], commentId=post["threadId"])
|
embed["url"] = "{url}?commentId={commentId}".format(url=article_paths["fullUrl"], commentId=post["threadId"])
|
||||||
embed["title"] = _("Commented on {article}").format(article=article_paths["title"])
|
embed["title"] = ctx._("Commented on {article}").format(article=article_paths["title"])
|
||||||
else:
|
else:
|
||||||
embed.event_type = "discussion/comment/reply"
|
embed.event_type = "discussion/comment/reply"
|
||||||
embed["url"] = "{url}?commentId={commentId}&replyId={replyId}".format(url=article_paths["fullUrl"],
|
embed["url"] = "{url}?commentId={commentId}&replyId={replyId}".format(url=article_paths["fullUrl"],
|
||||||
commentId=post["threadId"],
|
commentId=post["threadId"],
|
||||||
replyId=post["id"])
|
replyId=post["id"])
|
||||||
embed["title"] = _("Replied to a comment on {article}").format(article=article_paths["title"])
|
embed["title"] = ctx._("Replied to a comment on {article}").format(article=article_paths["title"])
|
||||||
embed["footer"]["text"] = article_paths["title"]
|
embed["footer"]["text"] = article_paths["title"]
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="discussion/article_comment")
|
@formatter.compact(event="discussion/article_comment")
|
||||||
def compact_discussion_article_comment(ctx: Context, post: dict):
|
def compact_discussion_article_comment(ctx: Context, post: dict):
|
||||||
author, author_url = compact_author_discussions(post)
|
author, author_url = compact_author_discussions(post, ctx)
|
||||||
article_paths = ctx.comment_page
|
article_paths = ctx.comment_page
|
||||||
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": ctx._("unknown"), "fullUrl": ctx.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"]:
|
||||||
event_type = "discussion/comment/post"
|
event_type = "discussion/comment/post"
|
||||||
message = _(
|
message = ctx._(
|
||||||
"[{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:
|
||||||
event_type = "discussion/comment/reply"
|
event_type = "discussion/comment/reply"
|
||||||
message = _(
|
message = ctx._(
|
||||||
"[{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"])
|
||||||
|
|
|
@ -17,14 +17,9 @@
|
||||||
import logging
|
import logging
|
||||||
from src.discord.message import DiscordMessage
|
from src.discord.message import DiscordMessage
|
||||||
from src.api import formatter
|
from src.api import formatter
|
||||||
from src.i18n import formatters_i18n
|
|
||||||
from src.api.context import Context
|
from src.api.context import Context
|
||||||
from src.api.util import embed_helper, clean_link, compact_author, create_article_path, sanitize_to_url, compact_summary
|
from src.api.util import embed_helper, clean_link, compact_author, create_article_path, sanitize_to_url, compact_summary
|
||||||
|
|
||||||
_ = formatters_i18n.gettext
|
|
||||||
ngettext = formatters_i18n.ngettext
|
|
||||||
|
|
||||||
|
|
||||||
# Interwiki - https://www.mediawiki.org/wiki/Extension:Interwiki
|
# Interwiki - https://www.mediawiki.org/wiki/Extension:Interwiki
|
||||||
# interwiki/iw_add - Added entry to interwiki table
|
# interwiki/iw_add - Added entry to interwiki table
|
||||||
|
|
||||||
|
@ -34,8 +29,8 @@ def embed_interwiki_iw_add(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
embed["url"] = create_article_path("Special:Interwiki")
|
embed["url"] = create_article_path("Special:Interwiki")
|
||||||
embed["title"] = _("Added an entry to the interwiki table")
|
embed["title"] = ctx._("Added an entry to the interwiki table")
|
||||||
embed["description"] = _("Prefix: {prefix}, website: {website} | {desc}").format(desc=ctx.parsedcomment,
|
embed["description"] = ctx._("Prefix: {prefix}, website: {website} | {desc}").format(desc=ctx.parsedcomment,
|
||||||
prefix=change["logparams"]['0'],
|
prefix=change["logparams"]['0'],
|
||||||
website=change["logparams"]['1'])
|
website=change["logparams"]['1'])
|
||||||
return embed
|
return embed
|
||||||
|
@ -46,7 +41,7 @@ def compact_interwiki_iw_add(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path("Special:Interwiki"))
|
link = clean_link(create_article_path("Special:Interwiki"))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) added an entry to the [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(
|
"[{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'],
|
author=author, author_url=author_url, desc=parsed_comment, prefix=change["logparams"]['0'],
|
||||||
website=change["logparams"]['1'], table_url=link)
|
website=change["logparams"]['1'], table_url=link)
|
||||||
|
@ -61,8 +56,8 @@ def embed_interwiki_iw_edit(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
embed["url"] = create_article_path("Special:Interwiki")
|
embed["url"] = create_article_path("Special:Interwiki")
|
||||||
embed["title"] = _("Edited an entry in interwiki table")
|
embed["title"] = ctx._("Edited an entry in interwiki table")
|
||||||
embed["description"] = _("Prefix: {prefix}, website: {website} | {desc}").format(desc=ctx.parsedcomment,
|
embed["description"] = ctx._("Prefix: {prefix}, website: {website} | {desc}").format(desc=ctx.parsedcomment,
|
||||||
prefix=change["logparams"]['0'],
|
prefix=change["logparams"]['0'],
|
||||||
website=change["logparams"]['1'])
|
website=change["logparams"]['1'])
|
||||||
return embed
|
return embed
|
||||||
|
@ -73,7 +68,7 @@ def compact_interwiki_iw_edit(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path("Special:Interwiki"))
|
link = clean_link(create_article_path("Special:Interwiki"))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) edited an entry in [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(
|
"[{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'],
|
author=author, author_url=author_url, desc=parsed_comment, prefix=change["logparams"]['0'],
|
||||||
website=change["logparams"]['1'], table_url=link)
|
website=change["logparams"]['1'], table_url=link)
|
||||||
|
@ -88,8 +83,8 @@ def embed_interwiki_iw_delete(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
embed["url"] = create_article_path("Special:Interwiki")
|
embed["url"] = create_article_path("Special:Interwiki")
|
||||||
embed["title"] = _("Deleted an entry in interwiki table")
|
embed["title"] = ctx._("Deleted an entry in interwiki table")
|
||||||
embed["description"] = _("Prefix: {prefix} | {desc}").format(desc=ctx.parsedcomment,
|
embed["description"] = ctx._("Prefix: {prefix} | {desc}").format(desc=ctx.parsedcomment,
|
||||||
prefix=change["logparams"]['0'])
|
prefix=change["logparams"]['0'])
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -99,7 +94,7 @@ def compact_interwiki_iw_delete(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path("Special:Interwiki"))
|
link = clean_link(create_article_path("Special:Interwiki"))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) deleted an entry in [interwiki table]({table_url}){desc}").format(
|
content = ctx._("[{author}]({author_url}) deleted an entry in [interwiki table]({table_url}){desc}").format(
|
||||||
author=author,
|
author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
table_url=link,
|
table_url=link,
|
||||||
|
|
|
@ -15,13 +15,9 @@
|
||||||
|
|
||||||
from src.discord.message import DiscordMessage
|
from src.discord.message import DiscordMessage
|
||||||
from src.api import formatter
|
from src.api import formatter
|
||||||
from src.i18n import formatters_i18n
|
|
||||||
from src.api.context import Context
|
from src.api.context import Context
|
||||||
from src.api.util import embed_helper, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url, compact_summary
|
from src.api.util import embed_helper, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url, compact_summary
|
||||||
|
|
||||||
_ = formatters_i18n.gettext
|
|
||||||
ngettext = formatters_i18n.ngettext
|
|
||||||
|
|
||||||
|
|
||||||
# ManageWiki - https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:ManageWiki
|
# ManageWiki - https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:ManageWiki
|
||||||
# managewiki/settings - Changing wiki settings
|
# managewiki/settings - Changing wiki settings
|
||||||
|
@ -31,7 +27,7 @@ def embed_managewiki_settings(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Changed wiki settings")
|
embed["title"] = ctx._("Changed wiki settings")
|
||||||
if change["logparams"].get("changes", ""):
|
if change["logparams"].get("changes", ""):
|
||||||
embed.add_field("Setting", sanitize_to_markdown(change["logparams"].get("changes")))
|
embed.add_field("Setting", sanitize_to_markdown(change["logparams"].get("changes")))
|
||||||
return embed
|
return embed
|
||||||
|
@ -41,7 +37,7 @@ def embed_managewiki_settings(ctx: Context, change: dict):
|
||||||
def compact_managewiki_settings(ctx: Context, change: dict):
|
def compact_managewiki_settings(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) changed wiki settings{reason}".format(author=author, author_url=author_url, reason=parsed_comment))
|
content = ctx._("[{author}]({author_url}) changed wiki settings{reason}".format(author=author, author_url=author_url, reason=parsed_comment))
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
# managewiki/delete - Deleting a wiki
|
# managewiki/delete - Deleting a wiki
|
||||||
|
@ -52,7 +48,7 @@ def embed_managewiki_delete(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Deleted a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", _("Unknown")))
|
embed["title"] = ctx._("Deleted a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", ctx._("Unknown")))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,11 +56,11 @@ def embed_managewiki_delete(ctx: Context, change: dict):
|
||||||
def compact_managewiki_delete(ctx: Context, change: dict):
|
def compact_managewiki_delete(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) deleted a wiki *{wiki_name}*{comment}").format(author=author,
|
content = ctx._("[{author}]({author_url}) deleted a wiki *{wiki_name}*{comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
wiki_name=change[
|
wiki_name=change[
|
||||||
"logparams"].get("wiki",
|
"logparams"].get("wiki",
|
||||||
_("Unknown")),
|
ctx._("Unknown")),
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
@ -77,7 +73,7 @@ def embed_managewiki_delete_group(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
group = change["title"].split("/")[-1]
|
group = change["title"].split("/")[-1]
|
||||||
embed["title"] = _("Deleted a \"{group}\" user group").format(wiki=group)
|
embed["title"] = ctx._("Deleted a \"{group}\" user group").format(wiki=group)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,7 +82,7 @@ def compact_managewiki_delete_group(ctx: Context, change: dict) -> DiscordMessag
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
group = change["title"].split("/")[-1]
|
group = change["title"].split("/")[-1]
|
||||||
content = _("[{author}]({author_url}) deleted a usergroup *{group}*{comment}").format(author=author,
|
content = ctx._("[{author}]({author_url}) deleted a usergroup *{group}*{comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
group=group,
|
group=group,
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
|
@ -100,7 +96,7 @@ def embed_managewiki_lock(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Locked a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", _("Unknown")))
|
embed["title"] = ctx._("Locked a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", ctx._("Unknown")))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,8 +104,8 @@ def embed_managewiki_lock(ctx: Context, change: dict):
|
||||||
def compact_managewiki_lock(ctx: Context, change: dict):
|
def compact_managewiki_lock(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) locked a wiki *{wiki_name}*{comment}").format(
|
content = ctx._("[{author}]({author_url}) locked 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", ctx._("Unknown")),
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
@ -121,9 +117,9 @@ def embed_managewiki_namespaces(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Modified \"{namespace_name}\" namespace").format(
|
embed["title"] = ctx._("Modified \"{namespace_name}\" namespace").format(
|
||||||
namespace_name=change["logparams"].get("namespace", _("Unknown")))
|
namespace_name=change["logparams"].get("namespace", ctx._("Unknown")))
|
||||||
embed.add_field(_('Wiki'), change["logparams"].get("wiki", _("Unknown")))
|
embed.add_field(ctx._('Wiki'), change["logparams"].get("wiki", ctx._("Unknown")))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,9 +127,9 @@ def embed_managewiki_namespaces(ctx: Context, change: dict):
|
||||||
def compact_managewiki_namespaces(ctx: Context, change: dict):
|
def compact_managewiki_namespaces(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) modified namespace *{namespace_name}* on *{wiki_name}*{comment}").format(
|
content = ctx._("[{author}]({author_url}) modified 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", ctx._("Unknown")),
|
||||||
wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment)
|
wiki_name=change["logparams"].get("wiki", ctx._("Unknown")), comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
# managewiki/namespaces-delete - Deleteing a namespace
|
# managewiki/namespaces-delete - Deleteing a namespace
|
||||||
|
@ -144,9 +140,9 @@ def embed_managewiki_namespaces_delete(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Deleted a \"{namespace_name}\" namespace").format(
|
embed["title"] = ctx._("Deleted a \"{namespace_name}\" namespace").format(
|
||||||
namespace_name=change["logparams"].get("namespace", _("Unknown")))
|
namespace_name=change["logparams"].get("namespace", ctx._("Unknown")))
|
||||||
embed.add_field(_('Wiki'), change["logparams"].get("wiki", _("Unknown")))
|
embed.add_field(ctx._('Wiki'), change["logparams"].get("wiki", ctx._("Unknown")))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,11 +150,11 @@ def embed_managewiki_namespaces_delete(ctx: Context, change: dict):
|
||||||
def compact_managewiki_namespaces_delete(ctx: Context, change: dict):
|
def compact_managewiki_namespaces_delete(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{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", ctx._("Unknown")),
|
||||||
wiki_name=change["logparams"].get("wiki", _("Unknown")), comment=parsed_comment)
|
wiki_name=change["logparams"].get("wiki", ctx._("Unknown")), comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
# managewiki/rights - Modifying user groups
|
# managewiki/rights - Modifying user groups
|
||||||
|
@ -170,7 +166,7 @@ def embed_managewiki_rights(ctx: Context, change: dict):
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
group_name = change["title"].split("/permissions/", 1)[1]
|
group_name = change["title"].split("/permissions/", 1)[1]
|
||||||
embed["title"] = _("Modified \"{usergroup_name}\" usergroup").format(usergroup_name=group_name)
|
embed["title"] = ctx._("Modified \"{usergroup_name}\" usergroup").format(usergroup_name=group_name)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,7 +175,7 @@ def compact_managewiki_rights(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
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 = ctx._("[{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
|
||||||
)
|
)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
@ -192,7 +188,7 @@ def embed_managewiki_undelete(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Undeleted a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", _("Unknown")))
|
embed["title"] = ctx._("Undeleted a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", ctx._("Unknown")))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,8 +196,8 @@ def embed_managewiki_undelete(ctx: Context, change: dict):
|
||||||
def compact_managewiki_undelete(ctx: Context, change: dict):
|
def compact_managewiki_undelete(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) undeleted a wiki *{wiki_name}*{comment}").format(
|
content = ctx._("[{author}]({author_url}) undeleted 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", ctx._("Unknown")),
|
||||||
comment=parsed_comment
|
comment=parsed_comment
|
||||||
)
|
)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
@ -214,7 +210,7 @@ def embed_managewiki_unlock(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Unlocked a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", _("Unknown")))
|
embed["title"] = ctx._("Unlocked a \"{wiki}\" wiki").format(wiki=change["logparams"].get("wiki", ctx._("Unknown")))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,8 +218,8 @@ def embed_managewiki_unlock(ctx: Context, change: dict):
|
||||||
def compact_managewiki_unlock(ctx: Context, change: dict):
|
def compact_managewiki_unlock(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) unlocked a wiki *{wiki_name}*{comment}").format(
|
content = ctx._("[{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", ctx._("Unknown")),
|
||||||
comment=parsed_comment
|
comment=parsed_comment
|
||||||
)
|
)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
|
@ -21,19 +21,15 @@ import datetime
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from src.discord.message import DiscordMessage
|
from src.discord.message import DiscordMessage
|
||||||
from src.api import formatter
|
from src.api import formatter
|
||||||
from src.i18n import formatters_i18n
|
|
||||||
from src.api.context import Context
|
from src.api.context import Context
|
||||||
from src.api.util import embed_helper, sanitize_to_url, parse_mediawiki_changes, clean_link, compact_author, \
|
from src.api.util import embed_helper, sanitize_to_url, parse_mediawiki_changes, clean_link, compact_author, \
|
||||||
create_article_path, sanitize_to_markdown, compact_summary
|
create_article_path, sanitize_to_markdown, compact_summary
|
||||||
from src.configloader import settings
|
|
||||||
from src.exceptions import *
|
from src.exceptions import *
|
||||||
|
|
||||||
_ = formatters_i18n.gettext
|
|
||||||
ngettext = formatters_i18n.ngettext
|
|
||||||
|
|
||||||
logger = logging.getLogger("extensions.base")
|
logger = logging.getLogger("extensions.base")
|
||||||
|
|
||||||
if 1 == 2: # additional translation strings in unreachable code
|
if 1 == 2: # additional translation strings in unreachable code
|
||||||
|
_ = lambda a: a
|
||||||
print(_("director"), _("bot"), _("editor"), _("directors"), _("sysop"), _("bureaucrat"), _("reviewer"),
|
print(_("director"), _("bot"), _("editor"), _("directors"), _("sysop"), _("bureaucrat"), _("reviewer"),
|
||||||
_("autoreview"), _("autopatrol"), _("wiki_guardian"))
|
_("autoreview"), _("autopatrol"), _("wiki_guardian"))
|
||||||
|
|
||||||
|
@ -67,11 +63,11 @@ def embed_edit(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
redirect="⤷ " if "redirect" in change else "",
|
redirect="⤷ " if "redirect" in change else "",
|
||||||
article=sanitize_to_markdown(change["title"]),
|
article=sanitize_to_markdown(change["title"]),
|
||||||
editsize="+" + str(editsize) if editsize > 0 else editsize,
|
editsize="+" + str(editsize) if editsize > 0 else editsize,
|
||||||
new=_("(N!) ") if action == "new" else "",
|
new=ctx._("(N!) ") if action == "new" else "",
|
||||||
minor=_("m") if action == "edit" and "minor" in change else "",
|
minor=ctx._("m") if action == "edit" and "minor" in change else "",
|
||||||
bot=_('b') if "bot" in change else "",
|
bot=ctx._('b') if "bot" in change else "",
|
||||||
space=" " if "bot" in change or (action == "edit" and "minor" in change) or action == "new" else "")
|
space=" " if "bot" in change or (action == "edit" and "minor" in change) or action == "new" else "")
|
||||||
if settings["appearance"]["embed"]["show_edit_changes"]:
|
if ctx.settings["appearance"]["embed"]["show_edit_changes"]:
|
||||||
try:
|
try:
|
||||||
if action == "new":
|
if action == "new":
|
||||||
changed_content = ctx.client.make_api_request(
|
changed_content = ctx.client.make_api_request(
|
||||||
|
@ -108,12 +104,12 @@ def compact_edit(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
if abs(edit_size) > 500:
|
if abs(edit_size) > 500:
|
||||||
bold = "**"
|
bold = "**"
|
||||||
if action == "edit":
|
if action == "edit":
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) edited [{article}]({edit_link}){comment} {bold}({sign}{edit_size}){bold}").format(
|
"[{author}]({author_url}) edited [{article}]({edit_link}){comment} {bold}({sign}{edit_size}){bold}").format(
|
||||||
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), edit_link=edit_link, comment=parsed_comment,
|
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), edit_link=edit_link, comment=parsed_comment,
|
||||||
edit_size=edit_size, sign=sign, bold=bold)
|
edit_size=edit_size, sign=sign, bold=bold)
|
||||||
else:
|
else:
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) created [{article}]({edit_link}){comment} {bold}({sign}{edit_size}){bold}").format(
|
"[{author}]({author_url}) created [{article}]({edit_link}){comment} {bold}({sign}{edit_size}){bold}").format(
|
||||||
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), edit_link=edit_link, comment=parsed_comment,
|
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), edit_link=edit_link, comment=parsed_comment,
|
||||||
edit_size=edit_size, sign=sign, bold=bold)
|
edit_size=edit_size, sign=sign, bold=bold)
|
||||||
|
@ -132,7 +128,7 @@ def embed_upload_upload(ctx, change) -> DiscordMessage:
|
||||||
params = OrderedDict()
|
params = OrderedDict()
|
||||||
params["action"] = "query"
|
params["action"] = "query"
|
||||||
params["format"] = "json"
|
params["format"] = "json"
|
||||||
if settings["license_detection"] and action == "upload/upload":
|
if ctx.settings["license_detection"] and action == "upload/upload":
|
||||||
params["prop"] = "imageinfo|revisions"
|
params["prop"] = "imageinfo|revisions"
|
||||||
params["rvprop"] = "content"
|
params["rvprop"] = "content"
|
||||||
params["rvslots"] = "main"
|
params["rvslots"] = "main"
|
||||||
|
@ -187,25 +183,25 @@ def embed_upload_upload(ctx, change) -> DiscordMessage:
|
||||||
undolink = "{wiki}index.php?title={filename}&action=revert&oldimage={archiveid}".format(
|
undolink = "{wiki}index.php?title={filename}&action=revert&oldimage={archiveid}".format(
|
||||||
wiki=ctx.client.WIKI_SCRIPT_PATH, filename=sanitize_to_url(change["title"]),
|
wiki=ctx.client.WIKI_SCRIPT_PATH, filename=sanitize_to_url(change["title"]),
|
||||||
archiveid=revision["archivename"])
|
archiveid=revision["archivename"])
|
||||||
embed.add_field(_("Options"), _("([preview]({link}) | [undo]({undolink}))").format(
|
embed.add_field(ctx._("Options"), ctx._("([preview]({link}) | [undo]({undolink}))").format(
|
||||||
link=image_direct_url, undolink=undolink))
|
link=image_direct_url, undolink=undolink))
|
||||||
if settings["appearance"]["embed"]["embed_images"]:
|
if ctx.settings["appearance"]["embed"]["embed_images"]:
|
||||||
embed["image"]["url"] = image_direct_url
|
embed["image"]["url"] = image_direct_url
|
||||||
if action == "upload/overwrite":
|
if action == "upload/overwrite":
|
||||||
embed["title"] = _("Uploaded a new version of {name}").format(name=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Uploaded a new version of {name}").format(name=sanitize_to_markdown(change["title"]))
|
||||||
elif action == "upload/revert":
|
elif action == "upload/revert":
|
||||||
embed["title"] = _("Reverted a version of {name}").format(name=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Reverted a version of {name}").format(name=sanitize_to_markdown(change["title"]))
|
||||||
else:
|
else:
|
||||||
embed["title"] = _("Uploaded {name}").format(name=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Uploaded {name}").format(name=sanitize_to_markdown(change["title"]))
|
||||||
if settings["license_detection"] and image_direct_url:
|
if ctx.settings["license_detection"] and image_direct_url:
|
||||||
try:
|
try:
|
||||||
content = image_data['revisions'][0]["slots"]["main"]['*']
|
content = image_data['revisions'][0]["slots"]["main"]['*']
|
||||||
matches = re.search(re.compile(settings["license_regex"], re.IGNORECASE), content)
|
matches = re.search(re.compile(ctx.settings["license_regex"], re.IGNORECASE), content)
|
||||||
if matches is not None:
|
if matches is not None:
|
||||||
license = matches.group("license")
|
license = matches.group("license")
|
||||||
else:
|
else:
|
||||||
if re.search(re.compile(settings["license_regex_detect"], re.IGNORECASE), content) is None:
|
if re.search(re.compile(ctx.settings["license_regex_detect"], re.IGNORECASE), content) is None:
|
||||||
license = _("**No license!**")
|
license = ctx._("**No license!**")
|
||||||
else:
|
else:
|
||||||
license = "?"
|
license = "?"
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
@ -220,12 +216,12 @@ def embed_upload_upload(ctx, change) -> DiscordMessage:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
"Unknown error when retriefing the image data for a license, full content: {}".format(image_data))
|
"Unknown error when retriefing the image data for a license, full content: {}".format(image_data))
|
||||||
if image_direct_url:
|
if image_direct_url:
|
||||||
embed.add_field(_("Options"), _("([preview]({link}))").format(link=image_direct_url))
|
embed.add_field(ctx._("Options"), ctx._("([preview]({link}))").format(link=image_direct_url))
|
||||||
if settings["appearance"]["embed"]["embed_images"]:
|
if ctx.settings["appearance"]["embed"]["embed_images"]:
|
||||||
embed["image"]["url"] = image_direct_url
|
embed["image"]["url"] = image_direct_url
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
if license is not None:
|
if license is not None:
|
||||||
embed["description"] += _("\nLicense: {}").format(license)
|
embed["description"] += ctx._("\nLicense: {}").format(license)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -234,7 +230,7 @@ def compact_upload_revert(ctx, change) -> DiscordMessage:
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
file_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
file_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) reverted a version of [{file}]({file_link}){comment}").format(
|
content = ctx._("[{author}]({author_url}) reverted a version of [{file}]({file_link}){comment}").format(
|
||||||
author=author, author_url=author_url, file=sanitize_to_markdown(change["title"]), file_link=file_link,
|
author=author, author_url=author_url, file=sanitize_to_markdown(change["title"]), file_link=file_link,
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
@ -245,7 +241,7 @@ def compact_upload_overwrite(ctx, change) -> DiscordMessage:
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
file_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
file_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) uploaded a new version of [{file}]({file_link}){comment}").format(
|
content = ctx._("[{author}]({author_url}) uploaded a new version of [{file}]({file_link}){comment}").format(
|
||||||
author=author, author_url=author_url, file=sanitize_to_markdown(change["title"]), file_link=file_link,
|
author=author, author_url=author_url, file=sanitize_to_markdown(change["title"]), file_link=file_link,
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
@ -256,7 +252,7 @@ def compact_upload_upload(ctx, change) -> DiscordMessage:
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
file_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
file_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) uploaded [{file}]({file_link}){comment}").format(author=author,
|
content = ctx._("[{author}]({author_url}) uploaded [{file}]({file_link}){comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
file=sanitize_to_markdown(
|
file=sanitize_to_markdown(
|
||||||
change["title"]),
|
change["title"]),
|
||||||
|
@ -271,7 +267,7 @@ def embed_delete_delete(ctx, change) -> DiscordMessage:
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed['url'] = create_article_path(sanitize_to_url(change["title"]))
|
embed['url'] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Deleted page {article}").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Deleted page {article}").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -280,7 +276,7 @@ def compact_delete_delete(ctx, change) -> DiscordMessage:
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
page_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
page_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _("[{author}]({author_url}) deleted [{page}]({page_link}){comment}").format(author=author,
|
content = ctx._("[{author}]({author_url}) deleted [{page}]({page_link}){comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
page=sanitize_to_markdown(
|
page=sanitize_to_markdown(
|
||||||
change["title"]),
|
change["title"]),
|
||||||
|
@ -295,7 +291,7 @@ def embed_delete_delete_redir(ctx, change) -> DiscordMessage:
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed['url'] = create_article_path(sanitize_to_url(change["title"]))
|
embed['url'] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Deleted redirect {article} by overwriting").format(
|
embed["title"] = ctx._("Deleted redirect {article} by overwriting").format(
|
||||||
article=sanitize_to_markdown(change["title"]))
|
article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -305,7 +301,7 @@ def compact_delete_delete_redir(ctx, change) -> DiscordMessage:
|
||||||
page_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
page_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) deleted redirect by overwriting [{page}]({page_link}){comment}").format(
|
content = ctx._("[{author}]({author_url}) deleted redirect by overwriting [{page}]({page_link}){comment}").format(
|
||||||
author=author, author_url=author_url, page=sanitize_to_markdown(change["title"]), page_link=page_link,
|
author=author, author_url=author_url, page=sanitize_to_markdown(change["title"]), page_link=page_link,
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
@ -319,7 +315,7 @@ def embed_delete_restore(ctx, change) -> DiscordMessage:
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed['url'] = create_article_path(sanitize_to_url(change["title"]))
|
embed['url'] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Restored {article}").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Restored {article}").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -328,7 +324,7 @@ def compact_delete_restore(ctx, change) -> DiscordMessage:
|
||||||
page_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
page_link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) restored [{article}]({article_url}){comment}").format(author=author,
|
content = ctx._("[{author}]({author_url}) restored [{article}]({article_url}){comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
article=sanitize_to_markdown(
|
article=sanitize_to_markdown(
|
||||||
change["title"]),
|
change["title"]),
|
||||||
|
@ -345,7 +341,7 @@ def embed_delete_event(ctx, change) -> DiscordMessage:
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed['url'] = create_article_path("Special:RecentChanges")
|
embed['url'] = create_article_path("Special:RecentChanges")
|
||||||
embed["title"] = _("Changed visibility of log events")
|
embed["title"] = ctx._("Changed visibility of log events")
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -353,7 +349,7 @@ def embed_delete_event(ctx, change) -> DiscordMessage:
|
||||||
def compact_delete_event(ctx, change) -> DiscordMessage:
|
def compact_delete_event(ctx, change) -> DiscordMessage:
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) changed visibility of log events{comment}").format(author=author,
|
content = ctx._("[{author}]({author_url}) changed visibility of log events{comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
@ -367,7 +363,7 @@ def embed_delete_revision(ctx, change) -> DiscordMessage:
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
amount = len(change["logparams"]["ids"])
|
amount = len(change["logparams"]["ids"])
|
||||||
embed['url'] = create_article_path(sanitize_to_url(change["title"]))
|
embed['url'] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = ngettext("Changed visibility of revision on page {article} ",
|
embed["title"] = ctx.ngettext("Changed visibility of revision on page {article} ",
|
||||||
"Changed visibility of {amount} revisions on page {article} ", amount).format(
|
"Changed visibility of {amount} revisions on page {article} ", amount).format(
|
||||||
article=sanitize_to_markdown(change["title"]), amount=amount)
|
article=sanitize_to_markdown(change["title"]), amount=amount)
|
||||||
return embed
|
return embed
|
||||||
|
@ -379,7 +375,7 @@ def compact_delete_revision(ctx, change) -> DiscordMessage:
|
||||||
amount = len(change["logparams"]["ids"])
|
amount = len(change["logparams"]["ids"])
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = ngettext(
|
content = ctx.ngettext(
|
||||||
"[{author}]({author_url}) changed visibility of revision on page [{article}]({article_url}){comment}",
|
"[{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}",
|
"[{author}]({author_url}) changed visibility of {amount} revisions on page [{article}]({article_url}){comment}",
|
||||||
amount).format(author=author, author_url=author_url,
|
amount).format(author=author, author_url=author_url,
|
||||||
|
@ -396,9 +392,9 @@ def embed_move_move(ctx, change) -> DiscordMessage:
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["logparams"]['target_title']))
|
embed["url"] = create_article_path(sanitize_to_url(change["logparams"]['target_title']))
|
||||||
embed["description"] = "{supress}. {desc}".format(desc=ctx.parsedcomment,
|
embed["description"] = "{supress}. {desc}".format(desc=ctx.parsedcomment,
|
||||||
supress=_("No redirect has been made") if "suppressredirect" in
|
supress=ctx._("No redirect has been made") if "suppressredirect" in
|
||||||
change["logparams"] else _("A redirect has been made"))
|
change["logparams"] else ctx._("A redirect has been made"))
|
||||||
embed["title"] = _("Moved {redirect}{article} to {target}").format(redirect="⤷ " if "redirect" in change else "",
|
embed["title"] = ctx._("Moved {redirect}{article} to {target}").format(redirect="⤷ " if "redirect" in change else "",
|
||||||
article=sanitize_to_markdown(change["title"]),
|
article=sanitize_to_markdown(change["title"]),
|
||||||
target=sanitize_to_markdown(
|
target=sanitize_to_markdown(
|
||||||
change["logparams"]['target_title']))
|
change["logparams"]['target_title']))
|
||||||
|
@ -409,10 +405,10 @@ def embed_move_move(ctx, change) -> DiscordMessage:
|
||||||
def compact_move_move(ctx, change) -> DiscordMessage:
|
def compact_move_move(ctx, change) -> DiscordMessage:
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["logparams"]['target_title'])))
|
link = clean_link(create_article_path(sanitize_to_url(change["logparams"]['target_title'])))
|
||||||
redirect_status = _("without making a redirect") if "suppressredirect" in change["logparams"] else _(
|
redirect_status = ctx._("without making a redirect") if "suppressredirect" in change["logparams"] else ctx._(
|
||||||
"with a redirect")
|
"with a redirect")
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) moved {redirect}*{article}* to [{target}]({target_url}) {made_a_redirect}{comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]),
|
author=author, author_url=author_url, redirect="⤷ " if "redirect" in change else "", article=sanitize_to_markdown(change["title"]),
|
||||||
target=sanitize_to_markdown(change["logparams"]['target_title']), target_url=link, comment=parsed_comment,
|
target=sanitize_to_markdown(change["logparams"]['target_title']), target_url=link, comment=parsed_comment,
|
||||||
|
@ -429,9 +425,9 @@ def embed_move_move_redir(ctx, change) -> DiscordMessage:
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["logparams"]['target_title']))
|
embed["url"] = create_article_path(sanitize_to_url(change["logparams"]['target_title']))
|
||||||
embed["description"] = "{supress}. {desc}".format(desc=ctx.parsedcomment,
|
embed["description"] = "{supress}. {desc}".format(desc=ctx.parsedcomment,
|
||||||
supress=_("No redirect has been made") if "suppressredirect" in
|
supress=ctx._("No redirect has been made") if "suppressredirect" in
|
||||||
change["logparams"] else _("A redirect has been made"))
|
change["logparams"] else ctx._("A redirect has been made"))
|
||||||
embed["title"] = _("Moved {redirect}{article} to {title} over redirect").format(
|
embed["title"] = ctx._("Moved {redirect}{article} to {title} over redirect").format(
|
||||||
redirect="⤷ " if "redirect" in change else "", article=sanitize_to_markdown(change["title"]),
|
redirect="⤷ " if "redirect" in change else "", article=sanitize_to_markdown(change["title"]),
|
||||||
title=sanitize_to_markdown(change["logparams"]["target_title"]))
|
title=sanitize_to_markdown(change["logparams"]["target_title"]))
|
||||||
return embed
|
return embed
|
||||||
|
@ -441,10 +437,10 @@ def embed_move_move_redir(ctx, change) -> DiscordMessage:
|
||||||
def compact_move_move_redir(ctx, change) -> DiscordMessage:
|
def compact_move_move_redir(ctx, change) -> DiscordMessage:
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["logparams"]['target_title'])))
|
link = clean_link(create_article_path(sanitize_to_url(change["logparams"]['target_title'])))
|
||||||
redirect_status = _("without making a redirect") if "suppressredirect" in change["logparams"] else _(
|
redirect_status = ctx._("without making a redirect") if "suppressredirect" in change["logparams"] else ctx._(
|
||||||
"with a redirect")
|
"with a redirect")
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) moved {redirect}*{article}* over redirect to [{target}]({target_url}) {made_a_redirect}{comment}").format(
|
"[{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 "",
|
author=author, author_url=author_url, redirect="⤷ " if "redirect" in change else "",
|
||||||
article=sanitize_to_markdown(change["title"]),
|
article=sanitize_to_markdown(change["title"]),
|
||||||
|
@ -461,7 +457,7 @@ def embed_protect_move_prot(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["logparams"]["oldtitle_title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["logparams"]["oldtitle_title"]))
|
||||||
embed["title"] = _("Moved protection settings from {redirect}{article} to {title}").format(
|
embed["title"] = ctx._("Moved protection settings from {redirect}{article} to {title}").format(
|
||||||
redirect="⤷ " if "redirect" in change else "",
|
redirect="⤷ " if "redirect" in change else "",
|
||||||
article=sanitize_to_markdown(change["logparams"]["oldtitle_title"]),
|
article=sanitize_to_markdown(change["logparams"]["oldtitle_title"]),
|
||||||
title=sanitize_to_markdown(change["title"]))
|
title=sanitize_to_markdown(change["title"]))
|
||||||
|
@ -473,7 +469,7 @@ def compact_protect_move_prot(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["logparams"]["oldtitle_title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["logparams"]["oldtitle_title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) moved protection settings from {redirect}*{article}* to [{target}]({target_url}){comment}").format(
|
"[{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 "",
|
author=author, author_url=author_url, redirect="⤷ " if "redirect" in change else "",
|
||||||
article=sanitize_to_markdown(change["logparams"]["oldtitle_title"]),
|
article=sanitize_to_markdown(change["logparams"]["oldtitle_title"]),
|
||||||
|
@ -489,10 +485,10 @@ def embed_protect_protect(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Protected {target}").format(target=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Protected {target}").format(target=sanitize_to_markdown(change["title"]))
|
||||||
embed["description"] = "{settings}{cascade} | {reason}".format(
|
embed["description"] = "{settings}{cascade} | {reason}".format(
|
||||||
settings=sanitize_to_markdown(change["logparams"].get("description", "")),
|
settings=sanitize_to_markdown(change["logparams"].get("description", "")),
|
||||||
cascade=_(" [cascading]") if "cascade" in change["logparams"] else "",
|
cascade=ctx._(" [cascading]") if "cascade" in change["logparams"] else "",
|
||||||
reason=ctx.parsedcomment)
|
reason=ctx.parsedcomment)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -502,12 +498,12 @@ def compact_protect_protect(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) protected [{article}]({article_url}) with the following settings: {settings}{comment}").format(
|
"[{author}]({author_url}) protected [{article}]({article_url}) with the following settings: {settings}{comment}").format(
|
||||||
author=author, author_url=author_url,
|
author=author, author_url=author_url,
|
||||||
article=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
settings=change["logparams"].get("description", "") + (
|
settings=change["logparams"].get("description", "") + (
|
||||||
_(" [cascading]") if "cascade" in change["logparams"] else ""),
|
ctx._(" [cascading]") if "cascade" in change["logparams"] else ""),
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
@ -520,10 +516,10 @@ def embed_protect_modify(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Changed protection level for {article}").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Changed protection level for {article}").format(article=sanitize_to_markdown(change["title"]))
|
||||||
embed["description"] = "{settings}{cascade} | {reason}".format(
|
embed["description"] = "{settings}{cascade} | {reason}".format(
|
||||||
settings=sanitize_to_markdown(change["logparams"].get("description", "")),
|
settings=sanitize_to_markdown(change["logparams"].get("description", "")),
|
||||||
cascade=_(" [cascading]") if "cascade" in change["logparams"] else "",
|
cascade=ctx._(" [cascading]") if "cascade" in change["logparams"] else "",
|
||||||
reason=ctx.parsedcomment)
|
reason=ctx.parsedcomment)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -533,12 +529,12 @@ def compact_protect_modify(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
settings=sanitize_to_markdown(change["logparams"].get("description", "")) + (
|
settings=sanitize_to_markdown(change["logparams"].get("description", "")) + (
|
||||||
_(" [cascading]") if "cascade" in change["logparams"] else ""),
|
ctx._(" [cascading]") if "cascade" in change["logparams"] else ""),
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
@ -551,7 +547,7 @@ def embed_protect_unprotect(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Removed protection from {article}").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Removed protection from {article}").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -560,16 +556,16 @@ def compact_protect_unprotect(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) removed protection from [{article}]({article_url}){comment}").format(
|
content = ctx._("[{author}]({author_url}) removed protection from [{article}]({article_url}){comment}").format(
|
||||||
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link,
|
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
# block/block - Blocking an user
|
# block/block - Blocking an user
|
||||||
def block_expiry(change: dict) -> str:
|
def block_expiry(change: dict, ctx: Context) -> str:
|
||||||
if change["logparams"]["duration"] in ["infinite", "indefinite", "infinity", "never"]:
|
if change["logparams"]["duration"] in ["infinite", "indefinite", "infinity", "never"]:
|
||||||
return _("for infinity and beyond")
|
return ctx._("for infinity and beyond")
|
||||||
else:
|
else:
|
||||||
if "expiry" in change["logparams"]:
|
if "expiry" in change["logparams"]:
|
||||||
expiry_date_time_obj = datetime.datetime.strptime(change["logparams"]["expiry"], '%Y-%m-%dT%H:%M:%SZ')
|
expiry_date_time_obj = datetime.datetime.strptime(change["logparams"]["expiry"], '%Y-%m-%dT%H:%M:%SZ')
|
||||||
|
@ -578,15 +574,15 @@ def block_expiry(change: dict) -> str:
|
||||||
years, days, hours, minutes = timedelta_for_expiry // 31557600, timedelta_for_expiry % 31557600 // 86400, \
|
years, days, hours, minutes = timedelta_for_expiry // 31557600, timedelta_for_expiry % 31557600 // 86400, \
|
||||||
timedelta_for_expiry % 86400 // 3600, timedelta_for_expiry % 3600 // 60
|
timedelta_for_expiry % 86400 // 3600, timedelta_for_expiry % 3600 // 60
|
||||||
if not any([years, days, hours, minutes]):
|
if not any([years, days, hours, minutes]):
|
||||||
return _("for less than a minute")
|
return ctx._("for less than a minute")
|
||||||
time_names = (
|
time_names = (
|
||||||
ngettext("year", "years", years), ngettext("day", "days", days), ngettext("hour", "hours", hours),
|
ctx.ngettext("year", "years", years), ctx.ngettext("day", "days", days), ctx.ngettext("hour", "hours", hours),
|
||||||
ngettext("minute", "minutes", minutes))
|
ctx.ngettext("minute", "minutes", minutes))
|
||||||
final_time = []
|
final_time = []
|
||||||
for num, timev in enumerate([years, days, hours, minutes]):
|
for num, timev in enumerate([years, days, hours, minutes]):
|
||||||
if timev:
|
if timev:
|
||||||
final_time.append(
|
final_time.append(
|
||||||
_("for {time_number} {time_unit}").format(time_unit=time_names[num], time_number=int(timev)))
|
ctx._("for {time_number} {time_unit}").format(time_unit=time_names[num], time_number=int(timev)))
|
||||||
return ", ".join(final_time)
|
return ", ".join(final_time)
|
||||||
else:
|
else:
|
||||||
return change["logparams"]["duration"] # Temporary? Should be rare? We will see in testing
|
return change["logparams"]["duration"] # Temporary? Should be rare? We will see in testing
|
||||||
|
@ -605,16 +601,16 @@ def embed_block_block(ctx, change):
|
||||||
restriction_description = ""
|
restriction_description = ""
|
||||||
if "restrictions" in change["logparams"]:
|
if "restrictions" in change["logparams"]:
|
||||||
if "pages" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"]["pages"]:
|
if "pages" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"]["pages"]:
|
||||||
restriction_description = _("Blocked from editing the following pages: ")
|
restriction_description = ctx._("Blocked from editing the following pages: ")
|
||||||
restricted_pages = ["*" + i["page_title"] + "*" for i in change["logparams"]["restrictions"]["pages"]]
|
restricted_pages = ["*" + i["page_title"] + "*" for i in change["logparams"]["restrictions"]["pages"]]
|
||||||
restriction_description = restriction_description + ", ".join(restricted_pages)
|
restriction_description = restriction_description + ", ".join(restricted_pages)
|
||||||
if "namespaces" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"][
|
if "namespaces" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"][
|
||||||
"namespaces"]:
|
"namespaces"]:
|
||||||
namespaces = []
|
namespaces = []
|
||||||
if restriction_description:
|
if restriction_description:
|
||||||
restriction_description = restriction_description + _(" and namespaces: ")
|
restriction_description = restriction_description + ctx._(" and namespaces: ")
|
||||||
else:
|
else:
|
||||||
restriction_description = _("Blocked from editing pages on following namespaces: ")
|
restriction_description = ctx._("Blocked from editing pages on following namespaces: ")
|
||||||
for namespace in change["logparams"]["restrictions"]["namespaces"]:
|
for namespace in change["logparams"]["restrictions"]["namespaces"]:
|
||||||
if str(namespace) in ctx.client.namespaces: # if we have cached namespace name for given namespace number, add its name to the list
|
if str(namespace) in ctx.client.namespaces: # if we have cached namespace name for given namespace number, add its name to the list
|
||||||
namespaces.append("*{ns}*".format(ns=ctx.client.namespaces[str(namespace)]["*"]))
|
namespaces.append("*{ns}*".format(ns=ctx.client.namespaces[str(namespace)]["*"]))
|
||||||
|
@ -625,12 +621,12 @@ def embed_block_block(ctx, change):
|
||||||
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] + "…"
|
||||||
embed.add_field(_("Partial block details"), restriction_description, inline=True)
|
embed.add_field(ctx._("Partial block details"), restriction_description, inline=True)
|
||||||
block_flags = change["logparams"].get("flags")
|
block_flags = change["logparams"].get("flags")
|
||||||
if block_flags:
|
if block_flags:
|
||||||
embed.add_field(_("Block flags"), ", ".join(
|
embed.add_field(ctx._("Block flags"), ", ".join(
|
||||||
block_flags)) # TODO Translate flags into MW messages, this requires making additional request in init_request since we want to get all messages with prefix (amprefix) block-log-flags- and that parameter is exclusive with ammessages
|
block_flags)) # TODO Translate flags into MW messages, this requires making additional request in init_request since we want to get all messages with prefix (amprefix) block-log-flags- and that parameter is exclusive with ammessages
|
||||||
embed["title"] = _("Blocked {blocked_user} {time}").format(blocked_user=user, time=block_expiry(change))
|
embed["title"] = ctx._("Blocked {blocked_user} {time}").format(blocked_user=user, time=block_expiry(change, ctx))
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -650,7 +646,7 @@ def compact_block_block(ctx, change):
|
||||||
if "sitewide" not in change["logparams"]:
|
if "sitewide" not in change["logparams"]:
|
||||||
if "restrictions" in change["logparams"]:
|
if "restrictions" in change["logparams"]:
|
||||||
if "pages" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"]["pages"]:
|
if "pages" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"]["pages"]:
|
||||||
restriction_description = _(" on pages: ")
|
restriction_description = ctx._(" on pages: ")
|
||||||
restricted_pages = ["*{page}*".format(page=i["page_title"]) for i in
|
restricted_pages = ["*{page}*".format(page=i["page_title"]) for i in
|
||||||
change["logparams"]["restrictions"]["pages"]]
|
change["logparams"]["restrictions"]["pages"]]
|
||||||
restriction_description = restriction_description + ", ".join(restricted_pages)
|
restriction_description = restriction_description + ", ".join(restricted_pages)
|
||||||
|
@ -658,9 +654,9 @@ def compact_block_block(ctx, change):
|
||||||
"namespaces"]:
|
"namespaces"]:
|
||||||
namespaces = []
|
namespaces = []
|
||||||
if restriction_description:
|
if restriction_description:
|
||||||
restriction_description = restriction_description + _(" and namespaces: ")
|
restriction_description = restriction_description + ctx._(" and namespaces: ")
|
||||||
else:
|
else:
|
||||||
restriction_description = _(" on namespaces: ")
|
restriction_description = ctx._(" on namespaces: ")
|
||||||
for namespace in change["logparams"]["restrictions"]["namespaces"]:
|
for namespace in change["logparams"]["restrictions"]["namespaces"]:
|
||||||
if str(namespace) in ctx.client.namespaces: # if we have cached namespace name for given namespace number, add its name to the list
|
if str(namespace) in ctx.client.namespaces: # if we have cached namespace name for given namespace number, add its name to the list
|
||||||
namespaces.append("*{ns}*".format(ns=ctx.client.namespaces[str(namespace)]["*"]))
|
namespaces.append("*{ns}*".format(ns=ctx.client.namespaces[str(namespace)]["*"]))
|
||||||
|
@ -671,12 +667,12 @@ def compact_block_block(ctx, change):
|
||||||
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 = ctx._(
|
||||||
"[{author}]({author_url}) blocked [{user}]({user_url}) {time}{restriction_desc}{comment}").format(author=author,
|
"[{author}]({author_url}) blocked [{user}]({user_url}) {time}{restriction_desc}{comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
user=user,
|
user=user,
|
||||||
time=block_expiry(
|
time=block_expiry(
|
||||||
change),
|
change, ctx),
|
||||||
user_url=link,
|
user_url=link,
|
||||||
restriction_desc=restriction_description,
|
restriction_desc=restriction_description,
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
|
@ -690,7 +686,7 @@ def embed_block_reblock(ctx, change):
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
user = change["title"].split(':', 1)[1]
|
user = change["title"].split(':', 1)[1]
|
||||||
embed["title"] = _("Changed block settings for {blocked_user}").format(blocked_user=sanitize_to_markdown(user))
|
embed["title"] = ctx._("Changed block settings for {blocked_user}").format(blocked_user=sanitize_to_markdown(user))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -700,7 +696,7 @@ def compact_block_reblock(ctx, change):
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
user = change["title"].split(':', 1)[1]
|
user = change["title"].split(':', 1)[1]
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) changed block settings for [{blocked_user}]({user_url}){comment}").format(
|
content = ctx._("[{author}]({author_url}) changed block settings for [{blocked_user}]({user_url}){comment}").format(
|
||||||
author=author, author_url=author_url, blocked_user=sanitize_to_markdown(user), user_url=link, comment=parsed_comment)
|
author=author, author_url=author_url, blocked_user=sanitize_to_markdown(user), user_url=link, comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
@ -713,7 +709,7 @@ def embed_block_unblock(ctx, change):
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
user = change["title"].split(':', 1)[1]
|
user = change["title"].split(':', 1)[1]
|
||||||
embed["title"] = _("Unblocked {blocked_user}").format(blocked_user=sanitize_to_markdown(user))
|
embed["title"] = ctx._("Unblocked {blocked_user}").format(blocked_user=sanitize_to_markdown(user))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -723,7 +719,7 @@ def compact_block_unblock(ctx, change):
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
user = change["title"].split(':', 1)[1]
|
user = change["title"].split(':', 1)[1]
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) unblocked [{blocked_user}]({user_url}){comment}").format(author=author,
|
content = ctx._("[{author}]({author_url}) unblocked [{blocked_user}]({user_url}){comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
blocked_user=sanitize_to_markdown(user),
|
blocked_user=sanitize_to_markdown(user),
|
||||||
user_url=link,
|
user_url=link,
|
||||||
|
@ -739,14 +735,14 @@ def compact_block_unblock(ctx, change):
|
||||||
def embed_suppressed(ctx, change):
|
def embed_suppressed(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed["url"] = create_article_path("")
|
embed["url"] = create_article_path("")
|
||||||
embed["title"] = _("Action has been hidden by administration")
|
embed["title"] = ctx._("Action has been hidden by administration")
|
||||||
embed["author"]["name"] = _("Unknown")
|
embed["author"]["name"] = ctx._("Unknown")
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="suppressed", mode="compact")
|
@formatter.compact(event="suppressed", mode="compact")
|
||||||
def compact_suppressed(ctx, change):
|
def compact_suppressed(ctx, change):
|
||||||
content = _("An action has been hidden by administration.")
|
content = ctx._("An action has been hidden by administration.")
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
|
@ -757,7 +753,7 @@ def embed_import_upload(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = ngettext("Imported {article} with {count} revision",
|
embed["title"] = ctx.ngettext("Imported {article} with {count} revision",
|
||||||
"Imported {article} with {count} revisions", change["logparams"]["count"]).format(
|
"Imported {article} with {count} revisions", change["logparams"]["count"]).format(
|
||||||
article=sanitize_to_markdown(change["title"]), count=change["logparams"]["count"])
|
article=sanitize_to_markdown(change["title"]), count=change["logparams"]["count"])
|
||||||
return embed
|
return embed
|
||||||
|
@ -768,7 +764,7 @@ def compact_import_upload(ctx, change):
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = ngettext("[{author}]({author_url}) imported [{article}]({article_url}) with {count} revision{comment}",
|
content = ctx.ngettext("[{author}]({author_url}) imported [{article}]({article_url}) with {count} revision{comment}",
|
||||||
"[{author}]({author_url}) imported [{article}]({article_url}) with {count} revisions{comment}",
|
"[{author}]({author_url}) imported [{article}]({article_url}) with {count} revisions{comment}",
|
||||||
change["logparams"]["count"]).format(
|
change["logparams"]["count"]).format(
|
||||||
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link,
|
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
|
@ -784,7 +780,7 @@ def embed_import_interwiki(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = ngettext("Imported {article} with {count} revision from \"{source}\"",
|
embed["title"] = ctx.ngettext("Imported {article} with {count} revision from \"{source}\"",
|
||||||
"Imported {article} with {count} revisions from \"{source}\"",
|
"Imported {article} with {count} revisions from \"{source}\"",
|
||||||
change["logparams"]["count"]).format(
|
change["logparams"]["count"]).format(
|
||||||
article=sanitize_to_markdown(change["title"]), count=change["logparams"]["count"],
|
article=sanitize_to_markdown(change["title"]), count=change["logparams"]["count"],
|
||||||
|
@ -798,7 +794,7 @@ def compact_import_interwiki(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
source_link = clean_link(create_article_path(change["logparams"]["interwiki_title"]))
|
source_link = clean_link(create_article_path(change["logparams"]["interwiki_title"]))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = ngettext(
|
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} revision from [{source}]({source_url}){comment}",
|
||||||
"[{author}]({author_url}) imported [{article}]({article_url}) with {count} revisions from [{source}]({source_url}){comment}",
|
"[{author}]({author_url}) imported [{article}]({article_url}) with {count} revisions from [{source}]({source_url}){comment}",
|
||||||
change["logparams"]["count"]).format(
|
change["logparams"]["count"]).format(
|
||||||
|
@ -810,17 +806,17 @@ def compact_import_interwiki(ctx, change):
|
||||||
|
|
||||||
|
|
||||||
# rights/rights - Assigning rights groups
|
# rights/rights - Assigning rights groups
|
||||||
def get_changed_groups(change: dict) -> [[str], [str]]:
|
def get_changed_groups(change: dict, ctx: Context) -> [[str], [str]]:
|
||||||
"""Creates strings comparing the changes between the user groups for the user"""
|
"""Creates strings comparing the changes between the user groups for the user"""
|
||||||
def expiry_parse_time(passed_time):
|
def expiry_parse_time(passed_time):
|
||||||
try:
|
try:
|
||||||
return _(" (until {date_and_time})").format(date_and_time=datetime.datetime.strptime(passed_time, "%Y-%m-%dT%H:%M:%SZ").strftime("%Y-%m-%d %H:%M:%S UTC"))
|
return ctx._(" (until {date_and_time})").format(date_and_time=datetime.datetime.strptime(passed_time, "%Y-%m-%dT%H:%M:%SZ").strftime("%Y-%m-%d %H:%M:%S UTC"))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return ""
|
return ""
|
||||||
new_group_meta = {_(t["group"]): expiry_parse_time(t.get("expiry", "infinity")) for t in change["logparams"].get("newmetadata", [])}
|
new_group_meta = {ctx._(t["group"]): expiry_parse_time(t.get("expiry", "infinity")) for t in change["logparams"].get("newmetadata", [])}
|
||||||
# translate all groups and pull them into a set
|
# translate all groups and pull them into a set
|
||||||
old_groups = {_(x) for x in change["logparams"]["oldgroups"]}
|
old_groups = {ctx._(x) for x in change["logparams"]["oldgroups"]}
|
||||||
new_groups = {_(x) for x in change["logparams"]["newgroups"]}
|
new_groups = {ctx._(x) for x in change["logparams"]["newgroups"]}
|
||||||
added = [x + new_group_meta.get(x, "") for x in new_groups - old_groups]
|
added = [x + new_group_meta.get(x, "") for x in new_groups - old_groups]
|
||||||
removed = [x for x in old_groups - new_groups]
|
removed = [x for x in old_groups - new_groups]
|
||||||
return added, removed
|
return added, removed
|
||||||
|
@ -831,18 +827,18 @@ def embed_rights_rights(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed["url"] = create_article_path(sanitize_to_url("User:{}".format(change["title"].split(":")[1])))
|
embed["url"] = create_article_path(sanitize_to_url("User:{}".format(change["title"].split(":")[1])))
|
||||||
if ctx.event == "rights/rights":
|
if ctx.event == "rights/rights":
|
||||||
embed["title"] = _("Changed group membership for {target}").format(target=sanitize_to_markdown(change["title"].split(":")[1]))
|
embed["title"] = ctx._("Changed group membership for {target}").format(target=sanitize_to_markdown(change["title"].split(":")[1]))
|
||||||
else:
|
else:
|
||||||
embed.set_author(_("System"), "")
|
embed.set_author(ctx._("System"), "")
|
||||||
embed["title"] = _("{target} got autopromoted to a new usergroup").format(
|
embed["title"] = ctx._("{target} got autopromoted to a new usergroup").format(
|
||||||
target=sanitize_to_markdown(change["title"].split(":")[1]))
|
target=sanitize_to_markdown(change["title"].split(":")[1]))
|
||||||
# if len(change["logparams"]["oldgroups"]) < len(change["logparams"]["newgroups"]):
|
# if len(change["logparams"]["oldgroups"]) < len(change["logparams"]["newgroups"]):
|
||||||
# embed["thumbnail"]["url"] = "https://i.imgur.com/WnGhF5g.gif"
|
# embed["thumbnail"]["url"] = "https://i.imgur.com/WnGhF5g.gif"
|
||||||
added, removed = get_changed_groups(change)
|
added, removed = get_changed_groups(change, ctx)
|
||||||
if added:
|
if added:
|
||||||
embed.add_field(ngettext("Added group", "Added groups", len(added)), "\n".join(added), inline=True)
|
embed.add_field(ctx.ngettext("Added group", "Added groups", len(added)), "\n".join(added), inline=True)
|
||||||
if removed:
|
if removed:
|
||||||
embed.add_field(ngettext("Removed group", "Removed groups", len(removed)), "\n".join(removed), inline=True)
|
embed.add_field(ctx.ngettext("Removed group", "Removed groups", len(removed)), "\n".join(removed), inline=True)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -850,25 +846,25 @@ def embed_rights_rights(ctx, change):
|
||||||
@formatter.compact(event="rights/rights", aliases=["rights/autopromote"])
|
@formatter.compact(event="rights/rights", aliases=["rights/autopromote"])
|
||||||
def compact_rights_rights(ctx, change):
|
def compact_rights_rights(ctx, change):
|
||||||
link = clean_link(create_article_path(sanitize_to_url("User:{user}".format(user=change["title"].split(":")[1]))))
|
link = clean_link(create_article_path(sanitize_to_url("User:{user}".format(user=change["title"].split(":")[1]))))
|
||||||
added, removed = get_changed_groups(change)
|
added, removed = get_changed_groups(change, ctx)
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
if ctx.event == "rights/rights":
|
if ctx.event == "rights/rights":
|
||||||
group_changes = "Unknown group changes." # Because I don't know if it can handle time extensions correctly
|
group_changes = "Unknown group changes." # Because I don't know if it can handle time extensions correctly
|
||||||
if added and removed:
|
if added and removed:
|
||||||
group_changes = _("Added to {added} and removed from {removed}.").format(
|
group_changes = ctx._("Added to {added} and removed from {removed}.").format(
|
||||||
added=_(", ").join(added), removed=_(", ").join(removed))
|
added=ctx._(", ").join(added), removed=ctx._(", ").join(removed))
|
||||||
elif added:
|
elif added:
|
||||||
group_changes = _("Added to {added}.").format(added=_(", ").join(added))
|
group_changes = ctx._("Added to {added}.").format(added=ctx._(", ").join(added))
|
||||||
elif removed:
|
elif removed:
|
||||||
group_changes = _("Removed from {removed}.").format(removed=_(", ").join(removed))
|
group_changes = ctx._("Removed from {removed}.").format(removed=ctx._(", ").join(removed))
|
||||||
content = _("[{author}]({author_url}) changed group membership for [{target}]({target_url}): {group_changes}{comment}").format(
|
content = ctx._("[{author}]({author_url}) changed group membership for [{target}]({target_url}): {group_changes}{comment}").format(
|
||||||
author=author, author_url=author_url, target=sanitize_to_markdown(change["title"].split(":")[1]),
|
author=author, author_url=author_url, target=sanitize_to_markdown(change["title"].split(":")[1]),
|
||||||
target_url=link, group_changes=group_changes, comment=parsed_comment)
|
target_url=link, group_changes=group_changes, comment=parsed_comment)
|
||||||
else:
|
else:
|
||||||
content = _("The system autopromoted [{target}]({target_url}) to {added}.{comment}").format(
|
content = ctx._("The system autopromoted [{target}]({target_url}) to {added}.{comment}").format(
|
||||||
target=sanitize_to_markdown(change["title"].split(":")[1]), target_url=link,
|
target=sanitize_to_markdown(change["title"].split(":")[1]), target_url=link,
|
||||||
added=_(", ").join(added), comment=parsed_comment)
|
added=ctx._(", ").join(added), comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
|
@ -879,7 +875,7 @@ def embed_merge_merge(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Merged revision histories of {article} into {dest}").format(
|
embed["title"] = ctx._("Merged revision histories of {article} into {dest}").format(
|
||||||
article=sanitize_to_markdown(change["title"]),
|
article=sanitize_to_markdown(change["title"]),
|
||||||
dest=sanitize_to_markdown(change["logparams"][
|
dest=sanitize_to_markdown(change["logparams"][
|
||||||
"dest_title"]))
|
"dest_title"]))
|
||||||
|
@ -892,7 +888,7 @@ def compact_merge_merge(ctx, change):
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
link_dest = clean_link(create_article_path(sanitize_to_url(change["logparams"]["dest_title"])))
|
link_dest = clean_link(create_article_path(sanitize_to_url(change["logparams"]["dest_title"])))
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) merged revision histories of [{article}]({article_url}) into [{dest}]({dest_url}){comment}").format(
|
"[{author}]({author_url}) merged revision histories of [{article}]({article_url}) into [{dest}]({dest_url}){comment}").format(
|
||||||
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link, dest_url=link_dest,
|
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link, dest_url=link_dest,
|
||||||
dest=sanitize_to_markdown(change["logparams"]["dest_title"]), comment=parsed_comment)
|
dest=sanitize_to_markdown(change["logparams"]["dest_title"]), comment=parsed_comment)
|
||||||
|
@ -907,14 +903,14 @@ def embed_newusers_autocreate(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Created account automatically")
|
embed["title"] = ctx._("Created account automatically")
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="newusers/autocreate")
|
@formatter.compact(event="newusers/autocreate")
|
||||||
def compact_newusers_autocreate(ctx, change):
|
def compact_newusers_autocreate(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
content = _("Account [{author}]({author_url}) was created automatically").format(author=author,
|
content = ctx._("Account [{author}]({author_url}) was created automatically").format(author=author,
|
||||||
author_url=author_url)
|
author_url=author_url)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
@ -927,14 +923,14 @@ def embed_newusers_create(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Created account")
|
embed["title"] = ctx._("Created account")
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="newusers/create")
|
@formatter.compact(event="newusers/create")
|
||||||
def compact_newusers_create(ctx, change):
|
def compact_newusers_create(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
content = _("Account [{author}]({author_url}) was created").format(author=author, author_url=author_url)
|
content = ctx._("Account [{author}]({author_url}) was created").format(author=author, author_url=author_url)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
|
@ -946,7 +942,7 @@ def embed_newusers_create2(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Created account {article}").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Created account {article}").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -955,7 +951,7 @@ def compact_newusers_create2(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _("Account [{article}]({article_url}) was created by [{author}]({author_url}){comment}").format(
|
content = ctx._("Account [{article}]({article_url}) was created by [{author}]({author_url}){comment}").format(
|
||||||
article=sanitize_to_markdown(change["title"]), article_url=link, author=author, author_url=author_url, comment=parsed_comment)
|
article=sanitize_to_markdown(change["title"]), article_url=link, author=author, author_url=author_url, comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
@ -968,7 +964,7 @@ def embed_newusers_byemail(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Created account {article} and password was sent by email").format(
|
embed["title"] = ctx._("Created account {article} and password was sent by email").format(
|
||||||
article=sanitize_to_markdown(change["title"]))
|
article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -978,7 +974,7 @@ def compact_newusers_byemail(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _(
|
content = ctx._(
|
||||||
"Account [{article}]({article_url}) was created by [{author}]({author_url}) and password was sent by email{comment}").format(
|
"Account [{article}]({article_url}) was created by [{author}]({author_url}) and password was sent by email{comment}").format(
|
||||||
article=sanitize_to_markdown(change["title"]), article_url=link, author=author, author_url=author_url, comment=parsed_comment)
|
article=sanitize_to_markdown(change["title"]), article_url=link, author=author, author_url=author_url, comment=parsed_comment)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
@ -992,14 +988,14 @@ def embed_newusers_newusers(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url("User:{}".format(change["user"])))
|
embed["url"] = create_article_path(sanitize_to_url("User:{}".format(change["user"])))
|
||||||
embed["title"] = _("Created account")
|
embed["title"] = ctx._("Created account")
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="newusers/newusers")
|
@formatter.compact(event="newusers/newusers")
|
||||||
def compact_newusers_newusers(ctx, change):
|
def compact_newusers_newusers(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
content = _("Account [{author}]({author_url}) was created").format(author=author, author_url=author_url)
|
content = ctx._("Account [{author}]({author_url}) was created").format(author=author, author_url=author_url)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1011,14 +1007,14 @@ def embed_newusers_reclaim(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url("User:{}".format(change["user"])))
|
embed["url"] = create_article_path(sanitize_to_url("User:{}".format(change["user"])))
|
||||||
embed["title"] = _("Reclaimed account")
|
embed["title"] = ctx._("Reclaimed account")
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="newusers/reclaim")
|
@formatter.compact(event="newusers/reclaim")
|
||||||
def compact_newusers_reclaim(ctx, change):
|
def compact_newusers_reclaim(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
content = _("Account [{author}]({author_url}) was reclaimed").format(author=author, author_url=author_url)
|
content = ctx._("Account [{author}]({author_url}) was reclaimed").format(author=author, author_url=author_url)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1030,9 +1026,9 @@ def embed_contentmodel_change(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Changed the content model of the page {article}").format(
|
embed["title"] = ctx._("Changed the content model of the page {article}").format(
|
||||||
article=sanitize_to_markdown(change["title"]))
|
article=sanitize_to_markdown(change["title"]))
|
||||||
embed["description"] = _("Model changed from {old} to {new}: {reason}").format(old=change["logparams"]["oldmodel"],
|
embed["description"] = ctx._("Model changed from {old} to {new}: {reason}").format(old=change["logparams"]["oldmodel"],
|
||||||
new=change["logparams"]["newmodel"],
|
new=change["logparams"]["newmodel"],
|
||||||
reason=ctx.parsedcomment)
|
reason=ctx.parsedcomment)
|
||||||
return embed
|
return embed
|
||||||
|
@ -1043,7 +1039,7 @@ def compact_contentmodel_change(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) changed the content model of the page [{article}]({article_url}) from {old} to {new}{comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
old=change["logparams"]["oldmodel"],
|
old=change["logparams"]["oldmodel"],
|
||||||
|
@ -1059,9 +1055,9 @@ def embed_contentmodel_new(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Created the page {article} using a non-default content model").format(
|
embed["title"] = ctx._("Created the page {article} using a non-default content model").format(
|
||||||
article=sanitize_to_markdown(change["title"]))
|
article=sanitize_to_markdown(change["title"]))
|
||||||
embed["description"] = _("Created with model {new}: {reason}").format(new=change["logparams"]["newmodel"],
|
embed["description"] = ctx._("Created with model {new}: {reason}").format(new=change["logparams"]["newmodel"],
|
||||||
reason=ctx.parsedcomment)
|
reason=ctx.parsedcomment)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -1071,7 +1067,7 @@ def compact_contentmodel_new(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) created the page [{article}]({article_url}) using a non-default content model {new}{comment}").format(
|
"[{author}]({author_url}) created the page [{article}]({article_url}) using a non-default content model {new}{comment}").format(
|
||||||
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link,
|
author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
new=change["logparams"]["newmodel"], comment=parsed_comment)
|
new=change["logparams"]["newmodel"], comment=parsed_comment)
|
||||||
|
@ -1087,7 +1083,7 @@ def embed_managetags_create(ctx, change):
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
ctx.client.refresh_internal_data()
|
ctx.client.refresh_internal_data()
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Created the tag \"{tag}\"").format(tag=sanitize_to_markdown(change["logparams"]["tag"]))
|
embed["title"] = ctx._("Created the tag \"{tag}\"").format(tag=sanitize_to_markdown(change["logparams"]["tag"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -1097,7 +1093,7 @@ def compact_managetags_create(ctx, change):
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
ctx.client.refresh_internal_data()
|
ctx.client.refresh_internal_data()
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) created the [tag]({tag_url}) \"{tag}\"{comment}").format(author=author,
|
content = ctx._("[{author}]({author_url}) created the [tag]({tag_url}) \"{tag}\"{comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
tag=
|
tag=
|
||||||
sanitize_to_markdown(
|
sanitize_to_markdown(
|
||||||
|
@ -1118,9 +1114,9 @@ def embed_managetags_delete(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
ctx.client.refresh_internal_data()
|
ctx.client.refresh_internal_data()
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Deleted the tag \"{tag}\"").format(tag=sanitize_to_markdown(change["logparams"]["tag"]))
|
embed["title"] = ctx._("Deleted the tag \"{tag}\"").format(tag=sanitize_to_markdown(change["logparams"]["tag"]))
|
||||||
if change["logparams"]["count"] > 0:
|
if change["logparams"]["count"] > 0:
|
||||||
embed.add_field(_('Removed from'), ngettext("{} revision or log entry", "{} revisions and/or log entries",
|
embed.add_field(ctx._('Removed from'), ctx.ngettext("{} revision or log entry", "{} revisions and/or log entries",
|
||||||
change["logparams"]["count"]).format(change["logparams"]["count"]))
|
change["logparams"]["count"]).format(change["logparams"]["count"]))
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
return embed
|
return embed
|
||||||
|
@ -1133,7 +1129,7 @@ def compact_managetags_delete(ctx, change):
|
||||||
ctx.client.refresh_internal_data()
|
ctx.client.refresh_internal_data()
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
if change["logparams"]["count"] == 0:
|
if change["logparams"]["count"] == 0:
|
||||||
content = _("[{author}]({author_url}) deleted the [tag]({tag_url}) \"{tag}\"{comment}").format(author=author,
|
content = ctx._("[{author}]({author_url}) deleted the [tag]({tag_url}) \"{tag}\"{comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
tag=sanitize_to_markdown(
|
tag=sanitize_to_markdown(
|
||||||
change[
|
change[
|
||||||
|
@ -1142,7 +1138,7 @@ def compact_managetags_delete(ctx, change):
|
||||||
tag_url=link,
|
tag_url=link,
|
||||||
comment=parsed_comment)
|
comment=parsed_comment)
|
||||||
else:
|
else:
|
||||||
content = ngettext(
|
content = ctx.ngettext(
|
||||||
"[{author}]({author_url}) deleted the [tag]({tag_url}) \"{tag}\" and removed it from {count} revision or log entry{comment}",
|
"[{author}]({author_url}) deleted the [tag]({tag_url}) \"{tag}\" and removed it from {count} revision or log entry{comment}",
|
||||||
"[{author}]({author_url}) deleted the [tag]({tag_url}) \"{tag}\" and removed it from {count} revisions and/or log entries{comment}",
|
"[{author}]({author_url}) deleted the [tag]({tag_url}) \"{tag}\" and removed it from {count} revisions and/or log entries{comment}",
|
||||||
change["logparams"]["count"]).format(author=author, author_url=author_url,
|
change["logparams"]["count"]).format(author=author, author_url=author_url,
|
||||||
|
@ -1160,7 +1156,7 @@ def embed_managetags_activate(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Activated the tag \"{tag}\"").format(tag=sanitize_to_markdown(change["logparams"]["tag"]))
|
embed["title"] = ctx._("Activated the tag \"{tag}\"").format(tag=sanitize_to_markdown(change["logparams"]["tag"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -1169,7 +1165,7 @@ def compact_managetags_activate(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) activated the [tag]({tag_url}) \"{tag}\"{comment}").format(author=author,
|
content = ctx._("[{author}]({author_url}) activated the [tag]({tag_url}) \"{tag}\"{comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
tag=sanitize_to_markdown(
|
tag=sanitize_to_markdown(
|
||||||
change[
|
change[
|
||||||
|
@ -1188,7 +1184,7 @@ def embed_managetags_deactivate(ctx, change):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Deactivated the tag \"{tag}\"").format(tag=sanitize_to_markdown(change["logparams"]["tag"]))
|
embed["title"] = ctx._("Deactivated the tag \"{tag}\"").format(tag=sanitize_to_markdown(change["logparams"]["tag"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -1197,7 +1193,7 @@ def compact_managetags_deactivate(ctx, change):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) deactivated the [tag]({tag_url}) \"{tag}\"{comment}").format(author=author,
|
content = ctx._("[{author}]({author_url}) deactivated the [tag]({tag_url}) \"{tag}\"{comment}").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
tag=sanitize_to_markdown(
|
tag=sanitize_to_markdown(
|
||||||
change[
|
change[
|
||||||
|
|
|
@ -17,14 +17,9 @@
|
||||||
import logging
|
import logging
|
||||||
from src.discord.message import DiscordMessage
|
from src.discord.message import DiscordMessage
|
||||||
from src.api import formatter
|
from src.api import formatter
|
||||||
from src.i18n import formatters_i18n
|
|
||||||
from src.api.context import Context
|
from src.api.context import Context
|
||||||
from src.api.util import embed_helper, compact_summary, clean_link, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url
|
from src.api.util import embed_helper, compact_summary, clean_link, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url
|
||||||
|
|
||||||
_ = formatters_i18n.gettext
|
|
||||||
ngettext = formatters_i18n.ngettext
|
|
||||||
|
|
||||||
|
|
||||||
# Renameuser - https://www.mediawiki.org/wiki/Extension:Renameuser
|
# Renameuser - https://www.mediawiki.org/wiki/Extension:Renameuser
|
||||||
# renameuser/renameuser - Renaming a user
|
# renameuser/renameuser - Renaming a user
|
||||||
|
|
||||||
|
@ -35,12 +30,12 @@ def embed_renameuser_renameuser(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
edits = change["logparams"]["edits"]
|
edits = change["logparams"]["edits"]
|
||||||
if edits > 0:
|
if edits > 0:
|
||||||
embed["title"] = ngettext("Renamed user \"{old_name}\" with {edits} edit to \"{new_name}\"",
|
embed["title"] = ctx.ngettext("Renamed user \"{old_name}\" with {edits} edit to \"{new_name}\"",
|
||||||
"Renamed user \"{old_name}\" with {edits} edits to \"{new_name}\"", edits).format(
|
"Renamed user \"{old_name}\" with {edits} edits to \"{new_name}\"", edits).format(
|
||||||
old_name=sanitize_to_markdown(change["logparams"]["olduser"]), edits=edits,
|
old_name=sanitize_to_markdown(change["logparams"]["olduser"]), edits=edits,
|
||||||
new_name=sanitize_to_markdown(change["logparams"]["newuser"]))
|
new_name=sanitize_to_markdown(change["logparams"]["newuser"]))
|
||||||
else:
|
else:
|
||||||
embed["title"] = _("Renamed user \"{old_name}\" to \"{new_name}\"").format(
|
embed["title"] = ctx._("Renamed user \"{old_name}\" to \"{new_name}\"").format(
|
||||||
old_name=sanitize_to_markdown(change["logparams"]["olduser"]),
|
old_name=sanitize_to_markdown(change["logparams"]["olduser"]),
|
||||||
new_name=sanitize_to_markdown(change["logparams"]["newuser"]))
|
new_name=sanitize_to_markdown(change["logparams"]["newuser"]))
|
||||||
embed["url"] = create_article_path("User:" + sanitize_to_url(change["logparams"]["newuser"]))
|
embed["url"] = create_article_path("User:" + sanitize_to_url(change["logparams"]["newuser"]))
|
||||||
|
@ -54,7 +49,7 @@ def compact_renameuser_renameuser(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
edits = change["logparams"]["edits"]
|
edits = change["logparams"]["edits"]
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
if edits > 0:
|
if edits > 0:
|
||||||
content = ngettext(
|
content = ctx.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} edit to [{new_name}]({link}){comment}",
|
||||||
"[{author}]({author_url}) renamed user *{old_name}* with {edits} edits to [{new_name}]({link}){comment}",
|
"[{author}]({author_url}) renamed user *{old_name}* with {edits} edits to [{new_name}]({link}){comment}",
|
||||||
edits).format(
|
edits).format(
|
||||||
|
@ -63,7 +58,7 @@ def compact_renameuser_renameuser(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
new_name=sanitize_to_markdown(change["logparams"]["newuser"]), link=link, comment=parsed_comment
|
new_name=sanitize_to_markdown(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 = ctx._("[{author}]({author_url}) renamed user *{old_name}* to [{new_name}]({link}){comment}").format(
|
||||||
author=author, author_url=author_url, old_name=sanitize_to_markdown(change["logparams"]["olduser"]),
|
author=author, author_url=author_url, old_name=sanitize_to_markdown(change["logparams"]["olduser"]),
|
||||||
new_name=sanitize_to_markdown(change["logparams"]["newuser"]), link=link, comment=parsed_comment
|
new_name=sanitize_to_markdown(change["logparams"]["newuser"]), link=link, comment=parsed_comment
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,14 +16,10 @@
|
||||||
import logging
|
import logging
|
||||||
from src.discord.message import DiscordMessage
|
from src.discord.message import DiscordMessage
|
||||||
from src.api import formatter
|
from src.api import formatter
|
||||||
from src.i18n import formatters_i18n
|
|
||||||
from src.api.context import Context
|
from src.api.context import Context
|
||||||
from src.api.util import embed_helper, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url, \
|
from src.api.util import embed_helper, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url, \
|
||||||
clean_link
|
clean_link
|
||||||
|
|
||||||
_ = formatters_i18n.gettext
|
|
||||||
ngettext = formatters_i18n.ngettext
|
|
||||||
|
|
||||||
|
|
||||||
# SpriteSheet - https://www.mediawiki.org/wiki/Extension:SpriteSheet
|
# SpriteSheet - https://www.mediawiki.org/wiki/Extension:SpriteSheet
|
||||||
# sprite/sprite - Editing a sprite
|
# sprite/sprite - Editing a sprite
|
||||||
|
@ -34,7 +30,7 @@ def embed_sprite_sprite(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Edited the sprite for {article}").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Edited the sprite for {article}").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +38,7 @@ def embed_sprite_sprite(ctx: Context, change: dict):
|
||||||
def compact_sprite_sprite(ctx: Context, change: dict):
|
def compact_sprite_sprite(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _("[{author}]({author_url}) edited the sprite for [{article}]({article_url})").format(author=author,
|
content = ctx._("[{author}]({author_url}) edited the sprite for [{article}]({article_url})").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
article=sanitize_to_markdown(change[
|
article=sanitize_to_markdown(change[
|
||||||
"title"]),
|
"title"]),
|
||||||
|
@ -57,7 +53,7 @@ def embed_sprite_sheet(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Created the sprite sheet for {article}").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Created the sprite sheet for {article}").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,7 +61,7 @@ def embed_sprite_sheet(ctx: Context, change: dict):
|
||||||
def compact_sprite_sheet(ctx: Context, change: dict):
|
def compact_sprite_sheet(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _("[{author}]({author_url}) created the sprite sheet for [{article}]({article_url})").format(author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link)
|
content = ctx._("[{author}]({author_url}) created the sprite sheet for [{article}]({article_url})").format(author=author, author_url=author_url, article=sanitize_to_markdown(change["title"]), article_url=link)
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
# sprite/slice - Editing a slice
|
# sprite/slice - Editing a slice
|
||||||
|
@ -76,14 +72,14 @@ def embed_sprite_slice(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Edited the slice for {article}").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Edited the slice for {article}").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
@formatter.compact(event="sprite/slice")
|
@formatter.compact(event="sprite/slice")
|
||||||
def compact_sprite_slice(ctx: Context, change: dict):
|
def compact_sprite_slice(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _("[{author}]({author_url}) edited the slice for [{article}]({article_url})").format(author=author,
|
content = ctx._("[{author}]({author_url}) edited the slice for [{article}]({article_url})").format(author=author,
|
||||||
author_url=author_url,
|
author_url=author_url,
|
||||||
article=sanitize_to_markdown(change[
|
article=sanitize_to_markdown(change[
|
||||||
"title"]),
|
"title"]),
|
||||||
|
|
|
@ -16,14 +16,10 @@
|
||||||
import logging
|
import logging
|
||||||
from src.discord.message import DiscordMessage
|
from src.discord.message import DiscordMessage
|
||||||
from src.api import formatter
|
from src.api import formatter
|
||||||
from src.i18n import formatters_i18n
|
|
||||||
from src.api.context import Context
|
from src.api.context import Context
|
||||||
from src.api.util import embed_helper, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url, \
|
from src.api.util import embed_helper, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url, \
|
||||||
clean_link, compact_summary
|
clean_link, compact_summary
|
||||||
|
|
||||||
_ = formatters_i18n.gettext
|
|
||||||
ngettext = formatters_i18n.ngettext
|
|
||||||
|
|
||||||
# I cried when I realized I have to migrate Translate extension logs, but this way I atone for my countless sins
|
# I cried when I realized I have to migrate Translate extension logs, but this way I atone for my countless sins
|
||||||
# Translate - https://www.mediawiki.org/wiki/Extension:Translate
|
# Translate - https://www.mediawiki.org/wiki/Extension:Translate
|
||||||
# pagetranslation/mark - Marking a page for translation
|
# pagetranslation/mark - Marking a page for translation
|
||||||
|
@ -38,7 +34,7 @@ def embed_pagetranslation_mark(ctx: Context, change: dict):
|
||||||
embed["url"] = link + "&oldid={}".format(change["logparams"]["revision"])
|
embed["url"] = link + "&oldid={}".format(change["logparams"]["revision"])
|
||||||
else:
|
else:
|
||||||
embed["url"] = link + "?oldid={}".format(change["logparams"]["revision"])
|
embed["url"] = link + "?oldid={}".format(change["logparams"]["revision"])
|
||||||
embed["title"] = _("Marked \"{article}\" for translation").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Marked \"{article}\" for translation").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +48,7 @@ def compact_pagetranslation_mark(ctx: Context, change: dict):
|
||||||
link = link + "?oldid={}".format(change["logparams"]["revision"])
|
link = link + "?oldid={}".format(change["logparams"]["revision"])
|
||||||
link = clean_link(link)
|
link = clean_link(link)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
content = _("[{author}]({author_url}) marked [{article}]({article_url}) for translation{comment}").format(
|
content = ctx._("[{author}]({author_url}) marked [{article}]({article_url}) for translation{comment}").format(
|
||||||
author=author, author_url=author_url,
|
author=author, author_url=author_url,
|
||||||
article=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
comment=parsed_comment
|
comment=parsed_comment
|
||||||
|
@ -67,7 +63,7 @@ def embed_pagetranslation_unmark(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Removed \"{article}\" from the translation system").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Removed \"{article}\" from the translation system").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,7 +72,7 @@ def compact_pagetranslation_unmark(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) removed [{article}]({article_url}) from the translation system{comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
|
@ -92,7 +88,7 @@ def embed_pagetranslation_moveok(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["logparams"]["target"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["logparams"]["target"]))
|
||||||
embed["title"] = _("Completed moving translation pages from \"{article}\" to \"{target}\"").format(
|
embed["title"] = ctx._("Completed moving translation pages from \"{article}\" to \"{target}\"").format(
|
||||||
article=sanitize_to_markdown(change["title"]), target=sanitize_to_markdown(change["logparams"]["target"]))
|
article=sanitize_to_markdown(change["title"]), target=sanitize_to_markdown(change["logparams"]["target"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -102,7 +98,7 @@ def compact_pagetranslation_moveok(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["logparams"]["target"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["logparams"]["target"])))
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) completed moving translation pages from *{article}* to [{target}]({target_url}){comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), target=sanitize_to_markdown(change["logparams"]["target"]),
|
article=sanitize_to_markdown(change["title"]), target=sanitize_to_markdown(change["logparams"]["target"]),
|
||||||
|
@ -118,7 +114,7 @@ def embed_pagetranslation_movenok(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Encountered a problem while moving \"{article}\" to \"{target}\"").format(
|
embed["title"] = ctx._("Encountered a problem while moving \"{article}\" to \"{target}\"").format(
|
||||||
article=sanitize_to_markdown(change["title"]), target=sanitize_to_markdown(change["logparams"]["target"]))
|
article=sanitize_to_markdown(change["title"]), target=sanitize_to_markdown(change["logparams"]["target"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -129,7 +125,7 @@ def compact_pagetranslation_movenok(ctx: Context, change: dict):
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
target_url = clean_link(create_article_path(sanitize_to_url(change["logparams"]["target"])))
|
target_url = clean_link(create_article_path(sanitize_to_url(change["logparams"]["target"])))
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) encountered a problem while moving [{article}]({article_url}) to [{target}]({target_url}){comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
|
@ -146,7 +142,7 @@ def embed_pagetranslation_deletefnok(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Failed to delete \"{article}\" which belongs to translatable page \"{target}\"").format(
|
embed["title"] = ctx._("Failed to delete \"{article}\" which belongs to translatable page \"{target}\"").format(
|
||||||
article=sanitize_to_markdown(change["title"]), target=sanitize_to_markdown(change["logparams"]["target"]))
|
article=sanitize_to_markdown(change["title"]), target=sanitize_to_markdown(change["logparams"]["target"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -157,7 +153,7 @@ def compact_pagetranslation_deletefnok(ctx: Context, change: dict):
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
target_url = clean_link(create_article_path(sanitize_to_url(change["logparams"]["target"])))
|
target_url = clean_link(create_article_path(sanitize_to_url(change["logparams"]["target"])))
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) failed to delete [{article}]({article_url}) which belongs to translatable page [{target}]({target_url}){comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
|
@ -174,7 +170,7 @@ def embed_pagetranslation_deletelok(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Completed deletion of translation page \"{article}\"").format(
|
embed["title"] = ctx._("Completed deletion of translation page \"{article}\"").format(
|
||||||
article=sanitize_to_markdown(change["title"]))
|
article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -184,7 +180,7 @@ def compact_pagetranslation_deletelok(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) completed deletion of translation page [{article}]({article_url}){comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
|
@ -200,7 +196,7 @@ def embed_pagetranslation_deletelnok(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Failed to delete \"{article}\" which belongs to translation page \"{target}\"").format(
|
embed["title"] = ctx._("Failed to delete \"{article}\" which belongs to translation page \"{target}\"").format(
|
||||||
article=sanitize_to_markdown(change["title"]), target=sanitize_to_markdown(change["logparams"]["target"]))
|
article=sanitize_to_markdown(change["title"]), target=sanitize_to_markdown(change["logparams"]["target"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -211,7 +207,7 @@ def compact_pagetranslation_deletelnok(ctx: Context, change: dict):
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
target_url = clean_link(create_article_path(sanitize_to_url(change["logparams"]["target"])))
|
target_url = clean_link(create_article_path(sanitize_to_url(change["logparams"]["target"])))
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) failed to delete [{article}]({article_url}) which belongs to translation page [{target}]({target_url}){comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
|
@ -228,7 +224,7 @@ def embed_pagetranslation_encourage(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Encouraged translation of \"{article}\"").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Encouraged translation of \"{article}\"").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -237,7 +233,7 @@ def compact_pagetranslation_encourage(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _("[{author}]({author_url}) encouraged translation of [{article}]({article_url}){comment}").format(
|
content = ctx._("[{author}]({author_url}) encouraged translation of [{article}]({article_url}){comment}").format(
|
||||||
author=author, author_url=author_url,
|
author=author, author_url=author_url,
|
||||||
article=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
comment=parsed_comment
|
comment=parsed_comment
|
||||||
|
@ -252,7 +248,7 @@ def embed_pagetranslation_discourage(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Discouraged translation of \"{article}\"").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Discouraged translation of \"{article}\"").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,7 +257,7 @@ def compact_pagetranslation_discourage(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _("[{author}]({author_url}) discouraged translation of [{article}]({article_url}){comment}").format(
|
content = ctx._("[{author}]({author_url}) discouraged translation of [{article}]({article_url}){comment}").format(
|
||||||
author=author, author_url=author_url,
|
author=author, author_url=author_url,
|
||||||
article=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
comment=parsed_comment
|
comment=parsed_comment
|
||||||
|
@ -279,13 +275,13 @@ def embed_pagetranslation_prioritylanguages(ctx: Context, change: dict):
|
||||||
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":
|
||||||
embed["title"] = _("Limited languages for \"{article}\" to `{languages}`").format(article=sanitize_to_markdown(change["title"]),
|
embed["title"] = ctx._("Limited languages for \"{article}\" to `{languages}`").format(article=sanitize_to_markdown(change["title"]),
|
||||||
languages=languages)
|
languages=languages)
|
||||||
else:
|
else:
|
||||||
embed["title"] = _("Priority languages for \"{article}\" set to `{languages}`").format(
|
embed["title"] = ctx._("Priority languages for \"{article}\" set to `{languages}`").format(
|
||||||
article=sanitize_to_markdown(change["title"]), languages=languages)
|
article=sanitize_to_markdown(change["title"]), languages=languages)
|
||||||
else:
|
else:
|
||||||
embed["title"] = _("Removed priority languages from \"{article}\"").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Removed priority languages from \"{article}\"").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -297,21 +293,21 @@ def compact_pagetranslation_prioritylanguages(ctx: Context, change: dict):
|
||||||
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 = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) limited languages for [{article}]({article_url}) to `{languages}`{comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
languages=languages, comment=parsed_comment
|
languages=languages, comment=parsed_comment
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) set the priority languages for [{article}]({article_url}) to `{languages}`{comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
languages=languages, comment=parsed_comment
|
languages=languages, comment=parsed_comment
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) removed priority languages from [{article}]({article_url}){comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
|
@ -328,7 +324,7 @@ def embed_pagetranslation_associate(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Added translatable page \"{article}\" to aggregate group \"{group}\"").format(
|
embed["title"] = ctx._("Added translatable page \"{article}\" to aggregate group \"{group}\"").format(
|
||||||
article=sanitize_to_markdown(change["title"]), group=change["logparams"]["aggregategroup"])
|
article=sanitize_to_markdown(change["title"]), group=change["logparams"]["aggregategroup"])
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -338,7 +334,7 @@ def compact_pagetranslation_associate(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) added translatable page [{article}]({article_url}) to aggregate group \"{group}\"{comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
|
@ -354,7 +350,7 @@ def embed_pagetranslation_dissociate(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Removed translatable page \"{article}\" from aggregate group \"{group}\"").format(
|
embed["title"] = ctx._("Removed translatable page \"{article}\" from aggregate group \"{group}\"").format(
|
||||||
article=sanitize_to_markdown(change["title"]), group=change["logparams"]["aggregategroup"])
|
article=sanitize_to_markdown(change["title"]), group=change["logparams"]["aggregategroup"])
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@ -364,7 +360,7 @@ def compact_pagetranslation_dissociate(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) removed translatable page [{article}]({article_url}) from aggregate group \"{group}\"{comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
|
@ -384,7 +380,7 @@ def embed_translationreview_message(ctx: Context, change: dict):
|
||||||
embed["url"] = link + "&oldid={}".format(change["logparams"]["revision"])
|
embed["url"] = link + "&oldid={}".format(change["logparams"]["revision"])
|
||||||
else:
|
else:
|
||||||
embed["url"] = link + "?oldid={}".format(change["logparams"]["revision"])
|
embed["url"] = link + "?oldid={}".format(change["logparams"]["revision"])
|
||||||
embed["title"] = _("Reviewed translation \"{article}\"").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Reviewed translation \"{article}\"").format(article=sanitize_to_markdown(change["title"]))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -398,7 +394,7 @@ def compact_translationreview_message(ctx: Context, change: dict):
|
||||||
else:
|
else:
|
||||||
link = link + "?oldid={}".format(change["logparams"]["revision"])
|
link = link + "?oldid={}".format(change["logparams"]["revision"])
|
||||||
link = clean_link(link)
|
link = clean_link(link)
|
||||||
content = _("[{author}]({author_url}) reviewed translation [{article}]({article_url}){comment}").format(
|
content = ctx._("[{author}]({author_url}) reviewed translation [{article}]({article_url}){comment}").format(
|
||||||
author=author, author_url=author_url,
|
author=author, author_url=author_url,
|
||||||
article=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
comment=parsed_comment
|
comment=parsed_comment
|
||||||
|
@ -413,11 +409,11 @@ def embed_translationreview_group(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
embed["title"] = _("Changed the state of `{language}` translations of \"{article}\"").format(
|
embed["title"] = ctx._("Changed the state of `{language}` translations of \"{article}\"").format(
|
||||||
language=change["logparams"]["language"], article=sanitize_to_markdown(change["title"]))
|
language=change["logparams"]["language"], article=sanitize_to_markdown(change["title"]))
|
||||||
if "old-state" in change["logparams"]:
|
if "old-state" in change["logparams"]:
|
||||||
embed.add_field(_("Old state"), change["logparams"]["old-state"], inline=True)
|
embed.add_field(ctx._("Old state"), change["logparams"]["old-state"], inline=True)
|
||||||
embed.add_field(_("New state"), change["logparams"]["new-state"], inline=True)
|
embed.add_field(ctx._("New state"), change["logparams"]["new-state"], inline=True)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -427,7 +423,7 @@ def compact_translationreview_group(ctx: Context, change: dict):
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
if "old-state" in change["logparams"]:
|
if "old-state" in change["logparams"]:
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) changed the state of `{language}` translations of [{article}]({article_url}) from `{old_state}` to `{new_state}`{comment}").format(
|
"[{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=sanitize_to_markdown(change["logparams"]["group-label"]), article_url=link,
|
article=sanitize_to_markdown(change["logparams"]["group-label"]), article_url=link,
|
||||||
|
@ -435,7 +431,7 @@ def compact_translationreview_group(ctx: Context, change: dict):
|
||||||
comment=parsed_comment
|
comment=parsed_comment
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) changed the state of `{language}` translations of [{article}]({article_url}) to `{new_state}`{comment}").format(
|
"[{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=sanitize_to_markdown(change["logparams"]["group-label"]), article_url=link,
|
article=sanitize_to_markdown(change["logparams"]["group-label"]), article_url=link,
|
||||||
|
@ -446,13 +442,13 @@ def compact_translationreview_group(ctx: Context, change: dict):
|
||||||
# pagelang/pagelang - Changing the language of a page
|
# pagelang/pagelang - Changing the language of a page
|
||||||
|
|
||||||
|
|
||||||
def get_languages(change):
|
def get_languages(change: dict, ctx: Context):
|
||||||
old_lang = "`{}`".format(change["logparams"]["oldlanguage"])
|
old_lang = "`{}`".format(change["logparams"]["oldlanguage"])
|
||||||
if change["logparams"]["oldlanguage"][-5:] == "[def]":
|
if change["logparams"]["oldlanguage"][-5:] == "[def]":
|
||||||
old_lang = "`{}` {}".format(change["logparams"]["oldlanguage"][:-5], _("(default)"))
|
old_lang = "`{}` {}".format(change["logparams"]["oldlanguage"][:-5], ctx._("(default)"))
|
||||||
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], ctx._("(default)"))
|
||||||
return old_lang, new_lang
|
return old_lang, new_lang
|
||||||
|
|
||||||
@formatter.embed(event="pagelang/pagelang")
|
@formatter.embed(event="pagelang/pagelang")
|
||||||
|
@ -460,10 +456,10 @@ def embed_pagelang_pagelang(ctx: Context, change: dict):
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
embed_helper(ctx, embed, change)
|
embed_helper(ctx, embed, change)
|
||||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||||
old_lang, new_lang = get_languages(change)
|
old_lang, new_lang = get_languages(change, ctx)
|
||||||
embed["title"] = _("Changed the language of \"{article}\"").format(article=sanitize_to_markdown(change["title"]))
|
embed["title"] = ctx._("Changed the language of \"{article}\"").format(article=sanitize_to_markdown(change["title"]))
|
||||||
embed.add_field(_("Old language"), old_lang, inline=True)
|
embed.add_field(ctx._("Old language"), old_lang, inline=True)
|
||||||
embed.add_field(_("New language"), new_lang, inline=True)
|
embed.add_field(ctx._("New language"), new_lang, inline=True)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@ -472,8 +468,8 @@ def compact_pagelang_pagelang(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = compact_summary(ctx)
|
parsed_comment = compact_summary(ctx)
|
||||||
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
link = clean_link(create_article_path(sanitize_to_url(change["title"])))
|
||||||
old_lang, new_lang = get_languages(change)
|
old_lang, new_lang = get_languages(change, ctx)
|
||||||
content = _(
|
content = ctx._(
|
||||||
"[{author}]({author_url}) changed the language of [{article}]({article_url}) from {old_lang} to {new_lang}{comment}").format(
|
"[{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=sanitize_to_markdown(change["title"]), article_url=link,
|
article=sanitize_to_markdown(change["title"]), article_url=link,
|
||||||
|
|
|
@ -34,6 +34,7 @@ class Context:
|
||||||
self.event = None
|
self.event = None
|
||||||
self.comment_page = None
|
self.comment_page = None
|
||||||
self._ = language.gettext # Singular translations (ex. ctx._("Large goat"))
|
self._ = language.gettext # Singular translations (ex. ctx._("Large goat"))
|
||||||
|
self.gettext = language.gettext # In case you dislike _ or using "protected field" of ctx
|
||||||
self.ngettext = language.npgettext # Plural translations depending on amount (ex. ctx.ngettext("{} action", "{} actions", action_amount))
|
self.ngettext = language.npgettext # Plural translations depending on amount (ex. ctx.ngettext("{} action", "{} actions", action_amount))
|
||||||
self.pgettext = language.pgettext # Translation with context (ex. ctx.pgettext("From mediawiki module", "Blocked {} user"))
|
self.pgettext = language.pgettext # Translation with context (ex. ctx.pgettext("From mediawiki module", "Blocked {} user"))
|
||||||
self.npgettext = language.npgettext # Plural translation with context (ex. ctx.npgettext("From mediawiki module", "Edited {} time", "Edited {} times", edit_amoint)
|
self.npgettext = language.npgettext # Plural translation with context (ex. ctx.npgettext("From mediawiki module", "Edited {} time", "Edited {} times", edit_amoint)
|
||||||
|
|
Loading…
Reference in a new issue