mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
Update extensions/base/renameuser.py, extensions/base/interwiki.py, extensions/base/mediawiki.py, extensions/base/curseprofile.py files
This commit is contained in:
parent
4a02292bac
commit
b640a090ea
70
extensions/base/curseprofile.py
Normal file
70
extensions/base/curseprofile.py
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
# This file is part of Recent changes Goat compatible Discord webhook (RcGcDw).
|
||||||
|
#
|
||||||
|
# RcGcDw is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# RcGcDw is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RcGcDw. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from src.discord.message import DiscordMessage
|
||||||
|
from src.api import formatter
|
||||||
|
from src.i18n import rc_formatters
|
||||||
|
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
|
||||||
|
|
||||||
|
_ = rc_formatters.gettext
|
||||||
|
ngettext = rc_formatters.ngettext
|
||||||
|
|
||||||
|
|
||||||
|
# CurseProfile - https://help.fandom.com/wiki/Extension:CurseProfile
|
||||||
|
# renameuser/renameuser - Renaming a user
|
||||||
|
|
||||||
|
|
||||||
|
@formatter.embed(event="renameuser/renameuser")
|
||||||
|
def embed_renameuser_renameuser(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
|
embed_helper(ctx, embed, change)
|
||||||
|
edits = change["logparams"]["edits"]
|
||||||
|
if edits > 0:
|
||||||
|
embed["title"] = ngettext("Renamed user \"{old_name}\" with {edits} edit to \"{new_name}\"",
|
||||||
|
"Renamed user \"{old_name}\" with {edits} edits to \"{new_name}\"", edits).format(
|
||||||
|
old_name=sanitize_to_markdown(change["logparams"]["olduser"]), edits=edits,
|
||||||
|
new_name=sanitize_to_markdown(change["logparams"]["newuser"]))
|
||||||
|
else:
|
||||||
|
embed["title"] = _("Renamed user \"{old_name}\" to \"{new_name}\"").format(
|
||||||
|
old_name=sanitize_to_markdown(change["logparams"]["olduser"]),
|
||||||
|
new_name=sanitize_to_markdown(change["logparams"]["newuser"]))
|
||||||
|
embed["url"] = create_article_path("User:" + sanitize_to_url(change["logparams"]["newuser"]))
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@formatter.compact(event="renameuser/renameuser")
|
||||||
|
def compact_renameuser_renameuser(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
|
author, author_url = compact_author(ctx, change)
|
||||||
|
link = clean_link(create_article_path("User:" + sanitize_to_url(change["logparams"]["newuser"])))
|
||||||
|
edits = change["logparams"]["edits"]
|
||||||
|
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
||||||
|
if edits > 0:
|
||||||
|
content = ngettext(
|
||||||
|
"[{author}]({author_url}) renamed user *{old_name}* with {edits} edit to [{new_name}]({link}){comment}",
|
||||||
|
"[{author}]({author_url}) renamed user *{old_name}* with {edits} edits to [{new_name}]({link}){comment}",
|
||||||
|
edits).format(
|
||||||
|
author=author, author_url=author_url, old_name=sanitize_to_markdown(change["logparams"]["olduser"]),
|
||||||
|
edits=edits,
|
||||||
|
new_name=sanitize_to_markdown(change["logparams"]["newuser"]), link=link, comment=parsed_comment
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
content = _("[{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"]),
|
||||||
|
new_name=sanitize_to_markdown(change["logparams"]["newuser"]), link=link, comment=parsed_comment
|
||||||
|
)
|
||||||
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
108
extensions/base/interwiki.py
Normal file
108
extensions/base/interwiki.py
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
# This file is part of Recent changes Goat compatible Discord webhook (RcGcDw).
|
||||||
|
#
|
||||||
|
# RcGcDw is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# RcGcDw is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RcGcDw. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from src.discord.message import DiscordMessage
|
||||||
|
from src.api import formatter
|
||||||
|
from src.i18n import rc_formatters
|
||||||
|
from src.api.context import Context
|
||||||
|
from src.api.util import embed_helper, clean_link, compact_author, create_article_path, sanitize_to_url
|
||||||
|
|
||||||
|
_ = rc_formatters.gettext
|
||||||
|
ngettext = rc_formatters.ngettext
|
||||||
|
|
||||||
|
|
||||||
|
# Interwiki - https://www.mediawiki.org/wiki/Extension:Interwiki
|
||||||
|
# interwiki/iw_add - Added entry to interwiki table
|
||||||
|
|
||||||
|
|
||||||
|
@formatter.embed(event="interwiki/iw_add", mode="embed")
|
||||||
|
def embed_interwiki_iw_add(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
|
embed["url"] = create_article_path("Special:Interwiki")
|
||||||
|
embed["title"] = _("Added an entry to the interwiki table")
|
||||||
|
embed["description"] = _("Prefix: {prefix}, website: {website} | {desc}").format(desc=ctx.parsedcomment,
|
||||||
|
prefix=change["logparams"]['0'],
|
||||||
|
website=change["logparams"]['1'])
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@formatter.compact(event="interwiki/iw_add")
|
||||||
|
def compact_interwiki_iw_add(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
|
author, author_url = compact_author(ctx, change)
|
||||||
|
link = clean_link(create_article_path("Special:Interwiki"))
|
||||||
|
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
||||||
|
content = _(
|
||||||
|
"[{author}]({author_url}) added an entry to the [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(
|
||||||
|
author=author, author_url=author_url, desc=parsed_comment, prefix=change["logparams"]['0'],
|
||||||
|
website=change["logparams"]['1'], table_url=link)
|
||||||
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
|
# interwiki/iw_edit - Editing interwiki entry
|
||||||
|
|
||||||
|
|
||||||
|
@formatter.embed(event="interwiki/iw_edit", mode="embed")
|
||||||
|
def embed_interwiki_iw_edit(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
|
embed["url"] = create_article_path("Special:Interwiki")
|
||||||
|
embed["title"] = _("Edited an entry in interwiki table")
|
||||||
|
embed["description"] = _("Prefix: {prefix}, website: {website} | {desc}").format(desc=ctx.parsedcomment,
|
||||||
|
prefix=change["logparams"]['0'],
|
||||||
|
website=change["logparams"]['1'])
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@formatter.compact(event="interwiki/iw_edit")
|
||||||
|
def compact_interwiki_iw_edit(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
|
author, author_url = compact_author(ctx, change)
|
||||||
|
link = clean_link(create_article_path("Special:Interwiki"))
|
||||||
|
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
||||||
|
content = _(
|
||||||
|
"[{author}]({author_url}) edited an entry in [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(
|
||||||
|
author=author, author_url=author_url, desc=parsed_comment, prefix=change["logparams"]['0'],
|
||||||
|
website=change["logparams"]['1'], table_url=link)
|
||||||
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
|
# interwiki/iw_delete - Deleting interwiki entry
|
||||||
|
|
||||||
|
|
||||||
|
@formatter.embed(event="interwiki/iw_delete", mode="embed")
|
||||||
|
def embed_interwiki_iw_delete(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
|
embed_helper(ctx, embed, change, set_desc=False)
|
||||||
|
embed["url"] = create_article_path("Special:Interwiki")
|
||||||
|
embed["title"] = _("Deleted an entry in interwiki table")
|
||||||
|
embed["description"] = _("Prefix: {prefix} | {desc}").format(desc=ctx.parsedcomment,
|
||||||
|
prefix=change["logparams"]['0'])
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@formatter.compact(event="interwiki/iw_delete")
|
||||||
|
def compact_interwiki_iw_delete(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
|
author, author_url = compact_author(ctx, change)
|
||||||
|
link = clean_link(create_article_path("Special:Interwiki"))
|
||||||
|
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
||||||
|
content = _("[{author}]({author_url}) deleted an entry in [interwiki table]({table_url}){desc}").format(
|
||||||
|
author=author,
|
||||||
|
author_url=author_url,
|
||||||
|
table_url=link,
|
||||||
|
desc=parsed_comment)
|
||||||
|
|
||||||
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
|
@ -988,88 +988,6 @@ def compact_newusers_newusers(ctx, change):
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
# interwiki/iw_add - Added entry to interwiki table
|
|
||||||
|
|
||||||
|
|
||||||
@formatter.embed(event="interwiki/iw_add", mode="embed")
|
|
||||||
def embed_interwiki_iw_add(ctx, change):
|
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
|
||||||
embed["url"] = create_article_path("Special:Interwiki")
|
|
||||||
embed["title"] = _("Added an entry to the interwiki table")
|
|
||||||
embed["description"] = _("Prefix: {prefix}, website: {website} | {desc}").format(desc=ctx.parsedcomment,
|
|
||||||
prefix=change["logparams"]['0'],
|
|
||||||
website=change["logparams"]['1'])
|
|
||||||
return embed
|
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="interwiki/iw_add")
|
|
||||||
def compact_interwiki_iw_add(ctx, change):
|
|
||||||
author, author_url = compact_author(ctx, change)
|
|
||||||
link = clean_link(create_article_path("Special:Interwiki"))
|
|
||||||
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
|
||||||
content = _(
|
|
||||||
"[{author}]({author_url}) added an entry to the [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(
|
|
||||||
author=author, author_url=author_url, desc=parsed_comment, prefix=change["logparams"]['0'],
|
|
||||||
website=change["logparams"]['1'], table_url=link)
|
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
|
||||||
|
|
||||||
|
|
||||||
# interwiki/iw_edit - Editing interwiki entry
|
|
||||||
|
|
||||||
|
|
||||||
@formatter.embed(event="interwiki/iw_edit", mode="embed")
|
|
||||||
def embed_interwiki_iw_edit(ctx, change):
|
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
|
||||||
embed["url"] = create_article_path("Special:Interwiki")
|
|
||||||
embed["title"] = _("Edited an entry in interwiki table")
|
|
||||||
embed["description"] = _("Prefix: {prefix}, website: {website} | {desc}").format(desc=ctx.parsedcomment,
|
|
||||||
prefix=change["logparams"]['0'],
|
|
||||||
website=change["logparams"]['1'])
|
|
||||||
return embed
|
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="interwiki/iw_edit")
|
|
||||||
def compact_interwiki_iw_edit(ctx, change):
|
|
||||||
author, author_url = compact_author(ctx, change)
|
|
||||||
link = clean_link(create_article_path("Special:Interwiki"))
|
|
||||||
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
|
||||||
content = _(
|
|
||||||
"[{author}]({author_url}) edited an entry in [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(
|
|
||||||
author=author, author_url=author_url, desc=parsed_comment, prefix=change["logparams"]['0'],
|
|
||||||
website=change["logparams"]['1'], table_url=link)
|
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
|
||||||
|
|
||||||
|
|
||||||
# interwiki/iw_delete - Deleting interwiki entry
|
|
||||||
|
|
||||||
|
|
||||||
@formatter.embed(event="interwiki/iw_delete", mode="embed")
|
|
||||||
def embed_interwiki_iw_delete(ctx, change):
|
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
|
||||||
embed_helper(ctx, embed, change, set_desc=False)
|
|
||||||
embed["url"] = create_article_path("Special:Interwiki")
|
|
||||||
embed["title"] = _("Deleted an entry in interwiki table")
|
|
||||||
embed["description"] = _("Prefix: {prefix} | {desc}").format(desc=ctx.parsedcomment,
|
|
||||||
prefix=change["logparams"]['0'])
|
|
||||||
return embed
|
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="interwiki/iw_delete")
|
|
||||||
def compact_interwiki_iw_delete(ctx, change):
|
|
||||||
author, author_url = compact_author(ctx, change)
|
|
||||||
link = clean_link(create_article_path("Special:Interwiki"))
|
|
||||||
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
|
||||||
content = _("[{author}]({author_url}) deleted an entry in [interwiki table]({table_url}){desc}").format(
|
|
||||||
author=author,
|
|
||||||
author_url=author_url,
|
|
||||||
table_url=link,
|
|
||||||
desc=parsed_comment)
|
|
||||||
|
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
|
||||||
|
|
||||||
|
|
||||||
# contentmodel/change - Changing the content model of a page
|
# contentmodel/change - Changing the content model of a page
|
||||||
|
|
||||||
|
|
||||||
|
@ -1250,47 +1168,3 @@ def compact_managetags_deactivate(ctx, change):
|
||||||
tag_url=link,
|
tag_url=link,
|
||||||
comment=ctx.parsedcomment)
|
comment=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)
|
||||||
|
|
||||||
|
|
||||||
# renameuser/renameuser - Renaming a user
|
|
||||||
|
|
||||||
|
|
||||||
@formatter.embed(event="renameuser/renameuser")
|
|
||||||
def embed_renameuser_renameuser(ctx, change):
|
|
||||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
|
||||||
embed_helper(ctx, embed, change)
|
|
||||||
edits = change["logparams"]["edits"]
|
|
||||||
if edits > 0:
|
|
||||||
embed["title"] = ngettext("Renamed user \"{old_name}\" with {edits} edit to \"{new_name}\"",
|
|
||||||
"Renamed user \"{old_name}\" with {edits} edits to \"{new_name}\"", edits).format(
|
|
||||||
old_name=sanitize_to_markdown(change["logparams"]["olduser"]), edits=edits,
|
|
||||||
new_name=sanitize_to_markdown(change["logparams"]["newuser"]))
|
|
||||||
else:
|
|
||||||
embed["title"] = _("Renamed user \"{old_name}\" to \"{new_name}\"").format(
|
|
||||||
old_name=sanitize_to_markdown(change["logparams"]["olduser"]),
|
|
||||||
new_name=sanitize_to_markdown(change["logparams"]["newuser"]))
|
|
||||||
embed["url"] = create_article_path("User:" + sanitize_to_url(change["logparams"]["newuser"]))
|
|
||||||
return embed
|
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="renameuser/renameuser")
|
|
||||||
def compact_renameuser_renameuser(ctx, change):
|
|
||||||
author, author_url = compact_author(ctx, change)
|
|
||||||
link = clean_link(create_article_path("User:" + sanitize_to_url(change["logparams"]["newuser"])))
|
|
||||||
edits = change["logparams"]["edits"]
|
|
||||||
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
|
||||||
if edits > 0:
|
|
||||||
content = ngettext(
|
|
||||||
"[{author}]({author_url}) renamed user *{old_name}* with {edits} edit to [{new_name}]({link}){comment}",
|
|
||||||
"[{author}]({author_url}) renamed user *{old_name}* with {edits} edits to [{new_name}]({link}){comment}",
|
|
||||||
edits).format(
|
|
||||||
author=author, author_url=author_url, old_name=sanitize_to_markdown(change["logparams"]["olduser"]),
|
|
||||||
edits=edits,
|
|
||||||
new_name=sanitize_to_markdown(change["logparams"]["newuser"]), link=link, comment=parsed_comment
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
content = _("[{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"]),
|
|
||||||
new_name=sanitize_to_markdown(change["logparams"]["newuser"]), link=link, comment=parsed_comment
|
|
||||||
)
|
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
|
||||||
|
|
70
extensions/base/renameuser.py
Normal file
70
extensions/base/renameuser.py
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
# This file is part of Recent changes Goat compatible Discord webhook (RcGcDw).
|
||||||
|
#
|
||||||
|
# RcGcDw is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# RcGcDw is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RcGcDw. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from src.discord.message import DiscordMessage
|
||||||
|
from src.api import formatter
|
||||||
|
from src.i18n import rc_formatters
|
||||||
|
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
|
||||||
|
|
||||||
|
_ = rc_formatters.gettext
|
||||||
|
ngettext = rc_formatters.ngettext
|
||||||
|
|
||||||
|
|
||||||
|
# Renameuser - https://www.mediawiki.org/wiki/Extension:Renameuser
|
||||||
|
# renameuser/renameuser - Renaming a user
|
||||||
|
|
||||||
|
|
||||||
|
@formatter.embed(event="renameuser/renameuser")
|
||||||
|
def embed_renameuser_renameuser(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
|
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||||
|
embed_helper(ctx, embed, change)
|
||||||
|
edits = change["logparams"]["edits"]
|
||||||
|
if edits > 0:
|
||||||
|
embed["title"] = ngettext("Renamed user \"{old_name}\" with {edits} edit to \"{new_name}\"",
|
||||||
|
"Renamed user \"{old_name}\" with {edits} edits to \"{new_name}\"", edits).format(
|
||||||
|
old_name=sanitize_to_markdown(change["logparams"]["olduser"]), edits=edits,
|
||||||
|
new_name=sanitize_to_markdown(change["logparams"]["newuser"]))
|
||||||
|
else:
|
||||||
|
embed["title"] = _("Renamed user \"{old_name}\" to \"{new_name}\"").format(
|
||||||
|
old_name=sanitize_to_markdown(change["logparams"]["olduser"]),
|
||||||
|
new_name=sanitize_to_markdown(change["logparams"]["newuser"]))
|
||||||
|
embed["url"] = create_article_path("User:" + sanitize_to_url(change["logparams"]["newuser"]))
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
@formatter.compact(event="renameuser/renameuser")
|
||||||
|
def compact_renameuser_renameuser(ctx: Context, change: dict) -> DiscordMessage:
|
||||||
|
author, author_url = compact_author(ctx, change)
|
||||||
|
link = clean_link(create_article_path("User:" + sanitize_to_url(change["logparams"]["newuser"])))
|
||||||
|
edits = change["logparams"]["edits"]
|
||||||
|
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
||||||
|
if edits > 0:
|
||||||
|
content = ngettext(
|
||||||
|
"[{author}]({author_url}) renamed user *{old_name}* with {edits} edit to [{new_name}]({link}){comment}",
|
||||||
|
"[{author}]({author_url}) renamed user *{old_name}* with {edits} edits to [{new_name}]({link}){comment}",
|
||||||
|
edits).format(
|
||||||
|
author=author, author_url=author_url, old_name=sanitize_to_markdown(change["logparams"]["olduser"]),
|
||||||
|
edits=edits,
|
||||||
|
new_name=sanitize_to_markdown(change["logparams"]["newuser"]), link=link, comment=parsed_comment
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
content = _("[{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"]),
|
||||||
|
new_name=sanitize_to_markdown(change["logparams"]["newuser"]), link=link, comment=parsed_comment
|
||||||
|
)
|
||||||
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
Loading…
Reference in a new issue