mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
Migrated spritesheet extension related logs
This commit is contained in:
parent
61d7e34575
commit
ddeaadb300
91
extensions/base/sprite.py
Normal file
91
extensions/base/sprite.py
Normal file
|
@ -0,0 +1,91 @@
|
|||
# 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, compact_author, create_article_path, sanitize_to_markdown, sanitize_to_url, \
|
||||
clean_link
|
||||
|
||||
_ = rc_formatters.gettext
|
||||
ngettext = rc_formatters.ngettext
|
||||
|
||||
|
||||
# SpriteSheet - https://www.mediawiki.org/wiki/Extension:SpriteSheet
|
||||
# sprite/sprite - Editing a sprite
|
||||
|
||||
|
||||
@formatter.embed(event="sprite/sprite")
|
||||
def embed_sprite_sprite(ctx: Context, change: dict):
|
||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||
embed_helper(ctx, embed, change)
|
||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||
embed["title"] = _("Edited the sprite for {article}").format(article=sanitize_to_markdown(change["title"]))
|
||||
return embed
|
||||
|
||||
|
||||
@formatter.compact(event="sprite/sprite")
|
||||
def compact_sprite_sprite(ctx: Context, change: dict):
|
||||
author, author_url = compact_author(ctx, change)
|
||||
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,
|
||||
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)
|
||||
|
||||
# sprite/sheet - Creating a sprite sheet
|
||||
|
||||
|
||||
@formatter.embed(event="sprite/sheet")
|
||||
def embed_sprite_sheet(ctx: Context, change: dict):
|
||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||
embed_helper(ctx, embed, change)
|
||||
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"]))
|
||||
return embed
|
||||
|
||||
|
||||
@formatter.compact(event="sprite/sheet")
|
||||
def compact_sprite_sheet(ctx: Context, change: dict):
|
||||
author, author_url = compact_author(ctx, change)
|
||||
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)
|
||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||
|
||||
# sprite/slice - Editing a slice
|
||||
|
||||
|
||||
@formatter.embed(event="sprite/slice")
|
||||
def embed_sprite_slice(ctx: Context, change: dict):
|
||||
embed = DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url)
|
||||
embed_helper(ctx, embed, change)
|
||||
embed["url"] = create_article_path(sanitize_to_url(change["title"]))
|
||||
embed["title"] = _("Edited the slice for {article}").format(article=sanitize_to_markdown(change["title"]))
|
||||
return embed
|
||||
|
||||
@formatter.compact(event="sprite/slice")
|
||||
def compact_sprite_slice(ctx: Context, change: dict):
|
||||
author, author_url = compact_author(ctx, change)
|
||||
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,
|
||||
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)
|
|
@ -220,14 +220,11 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
|
|||
elif action == "contentmodel/new":
|
||||
|
||||
elif action == "sprite/sprite":
|
||||
link = link_formatter(create_article_path(change["title"]))
|
||||
content = _("[{author}]({author_url}) edited the sprite for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link)
|
||||
|
||||
elif action == "sprite/sheet":
|
||||
link = link_formatter(create_article_path(change["title"]))
|
||||
content = _("[{author}]({author_url}) created the sprite sheet for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link)
|
||||
|
||||
elif action == "sprite/slice":
|
||||
link = link_formatter(create_article_path(change["title"]))
|
||||
content = _("[{author}]({author_url}) edited the slice for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link)
|
||||
|
||||
elif action == "cargo/createtable":
|
||||
|
||||
elif action == "cargo/deletetable":
|
||||
|
@ -573,14 +570,11 @@ def embed_formatter(action, change, parsed_comment, categories, recent_changes):
|
|||
elif action == "contentmodel/new":
|
||||
|
||||
elif action == "sprite/sprite":
|
||||
link = create_article_path(change["title"])
|
||||
embed["title"] = _("Edited the sprite for {article}").format(article=change["title"])
|
||||
|
||||
elif action == "sprite/sheet":
|
||||
link = create_article_path(change["title"])
|
||||
embed["title"] = _("Created the sprite sheet for {article}").format(article=change["title"])
|
||||
|
||||
elif action == "sprite/slice":
|
||||
link = create_article_path(change["title"])
|
||||
embed["title"] = _("Edited the slice for {article}").format(article=change["title"])
|
||||
|
||||
elif action == "cargo/createtable":
|
||||
|
||||
elif action == "cargo/deletetable":
|
||||
|
|
Loading…
Reference in a new issue