🎨 统一发送格式

This commit is contained in:
HibiKier
2024-08-10 02:25:04 +08:00
parent 5e4de123b0
commit e0a3fe526e
61 changed files with 758 additions and 665 deletions
+6 -6
View File
@@ -1,12 +1,12 @@
from nonebot.plugin import PluginMetadata
from nonebot_plugin_alconna import Alconna, Args, Arparma, Match, Option, on_alconna
from nonebot_plugin_saa import Image, Text
from nonebot_plugin_session import EventSession
from zhenxun.configs.utils import PluginExtraData, RegisterConfig
from zhenxun.services.log import logger
from zhenxun.utils.depends import CheckConfig
from zhenxun.utils.image_utils import ImageTemplate
from zhenxun.utils.message import MessageUtils
from .data_source import language, translate_message
@@ -19,7 +19,7 @@ __plugin_meta__ = PluginMetadata(
示例:
翻译 你好: 将中文翻译为英文
翻译 Hello: 将英文翻译为中文
翻译 你好 -to 希腊语: 将"你好"翻译为希腊语
翻译 你好: 允许form和to使用中文
翻译 你好 -form:中文 to:日语 你好: 指定原语种并将"你好"翻译为日文
@@ -57,7 +57,7 @@ async def _(session: EventSession, arparma: Arparma):
for key, value in language.items():
data_list.append([key, value])
image = await ImageTemplate.table_page("翻译语种", "", column_list, data_list)
await Image(image.pic2bytes()).send()
await MessageUtils.build_message(image).send()
logger.info(f"查看翻译语种", arparma.header_result, session=session)
@@ -79,11 +79,11 @@ async def _(
values = language.values()
keys = language.keys()
if source not in values and source not in keys:
await Text("源语种不支持...").finish()
await MessageUtils.build_message("源语种不支持...").finish()
if to not in values and to not in keys:
await Text("目标语种不支持...").finish()
await MessageUtils.build_message("目标语种不支持...").finish()
result = await translate_message(text, source, to)
await Text(result).send(reply=True)
await MessageUtils.build_message(result).send(reply=True)
logger.info(
f"source: {source}, to: {to}, 翻译: {text}",
arparma.header_result,