diff --git a/locales/zh_cn.json b/locales/zh_cn.json index 643267f9..0c6c2b64 100644 --- a/locales/zh_cn.json +++ b/locales/zh_cn.json @@ -16,9 +16,9 @@ "error.request.api.timeout": "请求 API 超时。", "tos.warning": "警告:\n根据服务条款,你已违反我们的行为准则。", "tos.reason": "具体原因:", - "tos.reason.cooldown": "一段时间内使用相同命令的次数过多", - "tos.reason.abuse": "一段时间内使用命令的次数过多", - "tos.reason.bypass": "无视临时限制警告", + "tos.reason.cooldown": "一段时间内使用相同命令的次数过多。", + "tos.reason.abuse": "一段时间内使用命令的次数过多。", + "tos.reason.bypass": "无视临时限制警告。", "tos.warning.count": "这是对你的第 ${current_warns} 次警告。如超过 5 次警告,我们将会把你的账户加入黑名单。", "tos.warning.appeal": "如果你有任何异议,请至 ${issue_url} 发起问题。", "tos.warning.last": "这是对你的最后一次警告。", @@ -32,6 +32,7 @@ "parser.admin.module.permission.denied": "${module} 模块下的命令仅能被该群组的管理员所使用,请联系管理员执行此命令。", "parser.admin.submodule.permission.denied": "此命令仅能被该群组的管理员所使用,请联系管理员执行此命令。", "parser.module.disabled.prompt": "${module} 模块未启用,请发送 ${prefix}enable ${module} 启用本模块。", + "error": "发生错误:", "example": "你好世界!", "success": "成功。", "yes": "是", diff --git a/modules/coin/locales/zh_cn.json b/modules/coin/locales/zh_cn.json index 5390421e..d67bae27 100644 --- a/modules/coin/locales/zh_cn.json +++ b/modules/coin/locales/zh_cn.json @@ -1,7 +1,6 @@ { "coin.begin": "你抛了${count} 枚硬币,", "coin.help": "抛n枚硬币", - "coin.error": "发生错误:", "coin.error.amount": "发生错误:无效的硬币个数:", "coin.error.max": "发生错误:你最多只能抛 ${max} 个硬币", "coin.error.nocoin": "发生错误:你抛了个空气,什么也没发生...", diff --git a/modules/wiki/inline.py b/modules/wiki/inline.py index f9927149..d83ec5b7 100644 --- a/modules/wiki/inline.py +++ b/modules/wiki/inline.py @@ -97,12 +97,12 @@ async def _(msg: Bot.MessageSession): if guess_type is not None: if guess_type.extension in ["png", "gif", "jpg", "jpeg", "webp", "bmp", "ico"]: if msg.Feature.image: - await msg.sendMessage([Plain(msg.locale.t('wiki.message.flies', file=get_page.file)), Image(dl)], + await msg.sendMessage([Plain(msg.locale.t('wiki.wiki_inline.message.flies', file=get_page.file)), Image(dl)], quote=False) img_send = True elif guess_type.extension in ["oga", "ogg", "flac", "mp3", "wav"]: if msg.Feature.voice: - await msg.sendMessage([Plain(msg.locale.t('wiki.message.flies', file=get_page.file)), Voice(dl)], + await msg.sendMessage([Plain(msg.locale.t('wiki.wiki_inline.message.flies', file=get_page.file)), Voice(dl)], quote=False) if msg.Feature.image: if get_page.status and wiki_.wiki_info.in_allowlist: diff --git a/modules/wiki/locales/zh_cn.json b/modules/wiki/locales/zh_cn.json index d0afc56e..1ab846dc 100644 --- a/modules/wiki/locales/zh_cn.json +++ b/modules/wiki/locales/zh_cn.json @@ -15,6 +15,7 @@ "wiki.wiki_audit.list.message.table.header.apilink": "API 链接", "wiki.wiki_audit.list.message.table.header.operator": "操作者", "wiki.wiki_inline.help.desc": "开启后将自动解析消息中带有的[[]]或{{}}字符串并自动查询 Wiki,例如[[海晶石]]。", + "wiki.wiki_inline.message.flies": "此页面包括以下文件:${file}", "wiki.search.help": "搜索一个 Wiki 页面。", "wiki.search.message": "查询到以下结果:", "wiki.search.message.prompt": "回复编号以查询对应的页面。", @@ -30,7 +31,7 @@ "wiki.iw.list.help.legacy": "展示当前设置的 Interwiki。(旧版)", "wiki.iw.list.message": "使用 ${prefix}wiki iw get 可以获取 Interwiki 对应的链接。", "wiki.iw.list.message.legacy": "当前设置了以下 Interwiki:", - "wiki.iw.list.message.redirect": "此处展示的是为机器人设定的自定义 Interwiki,如需查看起始 Wiki 的 Interwiki,请见:${url}", + "wiki.iw.list.message.more_information": "此处展示的是为机器人设定的自定义 Interwiki,如需查看起始 Wiki 的 Interwiki,请见:${url}", "wiki.iw.get.help": "获取设置的 Interwiki 对应的 API 地址。", "wiki.iw.get.message.not_found": "未找到 Interwiki:${iw}", "wiki.headers.list.help": "展示当前设置的请求标头。", @@ -54,11 +55,14 @@ "wiki.prefix.reset.message.success": "成功:已重置请求时所使用的前缀。", "wiki.help": "查询一个 Wiki 页面,若查询“随机页面”则随机一个页面。", "wiki.help.l": "查找本页面的对应语言版本,若无结果则返回当前语言。", - "wiki.p.help": "根据页面 ID 查询一个 Wiki 页面。", - "wiki.p.message.error": "发生错误:页面 ID 必须是数字。", - "wiki.message.error.abuse": "发生错误:页面 ID 必须是数字。", + "wiki.id.help": "根据页面 ID 查询一个 Wiki 页面。", + "wiki.id.message.error": "发生错误:页面 ID 必须是数字。", + "wiki.message.redirect": "(重定向[${title}] -> [${redirected_title}])", + "wiki.message.redirect.template_to_page": "([${title}]不存在,已自动重定向至[${redirected_title}])", + "wiki.message.invalid_namespace": "此 Wiki 上没有名为${namespace}的命名空间,请检查拼写后重试。", + "wiki.message.magic_word": "提示:机器人暂不支持魔术字。", + "tos.reason.too_many_redirects": "使机器人重定向页面的次数过多。", "tos.reason.wiki_abuse": "一次性查询的页面超出15个。", - "wiki.message.flies": "此页面包括以下文件:${file}", "wiki.message.untrust": "注意:此 Wiki 当前没有加入机器人的白名单列表中,查询此 Wiki 时将会对返回内容进行一些限制。\n如需取消限制,请在此处申请白名单:\n", "wiki.message.error.add": "发生错误:无法添加此 Wiki。", "wiki.message.error.blocked": "发生错误:${name} 处于黑名单中。", diff --git a/modules/wiki/set.py b/modules/wiki/set.py index 7f4cea79..8a6d1c6d 100644 --- a/modules/wiki/set.py +++ b/modules/wiki/set.py @@ -79,13 +79,13 @@ async def _(msg: Bot.MessageSession): if img: mt = msg.locale.t("wiki.iw.list.message", prefix=msg.prefixes[0]) if base_interwiki_link is not None: - mt += '\n' + msg.locale.t("wiki.iw.list.message.redirect", url=str(Url(base_interwiki_link))) + mt += '\n' + msg.locale.t("wiki.iw.list.message.more_information", url=str(Url(base_interwiki_link))) await msg.finish([Image(img), Plain(mt)]) else: result = msg.locale.t("wiki.iw.list.message.legacy") + '\n' + \ '\n'.join([f'{x}: {query[x]}' for x in query]) if base_interwiki_link is not None: - result += '\n' + msg.locale.t("wiki.iw.list.message.redirect", url=str(Url(base_interwiki_link))) + result += '\n' + msg.locale.t("wiki.iw.list.message.more_information", url=str(Url(base_interwiki_link))) await msg.finish(result) else: await msg.finish(msg.locale.t("wiki.iw.message.none", prefix=msg.prefixes[0])) diff --git a/modules/wiki/wiki.py b/modules/wiki/wiki.py index ed5cb6e3..3fd4c176 100644 --- a/modules/wiki/wiki.py +++ b/modules/wiki/wiki.py @@ -22,8 +22,8 @@ wiki = module('wiki', developers=['OasisAkari']) -@wiki.handle(' [-l ] {查询一个Wiki页面,若查询“随机页面”则随机一个页面。}', - options_desc={'-l': '查找本页面的对应语言版本,若无结果则返回当前语言。'}) +@wiki.handle(' [-l ] {{wiki.help}}', + options_desc={'-l': '{wiki.help.l}'}) async def _(msg: Bot.MessageSession): get_lang: dict = msg.parsed_msg.get('-l', False) if get_lang: @@ -33,7 +33,7 @@ async def _(msg: Bot.MessageSession): await query_pages(msg, msg.parsed_msg[''], lang=lang) -@wiki.handle('-p [-i ] {根据页面ID查询一个Wiki页面。}') +@wiki.handle('id [-i ] {{wiki.id.help}}') async def _(msg: Bot.MessageSession): if msg.parsed_msg.get('-i', False): iw: str = msg.parsed_msg['-i'].get('', '') @@ -41,7 +41,7 @@ async def _(msg: Bot.MessageSession): iw = '' page_id: str = msg.parsed_msg[''] if not page_id.isdigit(): - await msg.finish('错误:页面ID必须是数字。') + await msg.finish(msg.locale.t('wiki.id.message.error')) Logger.debug(msg.parsed_msg) await query_pages(msg, pageid=page_id, iw=iw) @@ -69,15 +69,13 @@ async def query_pages(session: Union[Bot.MessageSession, QueryInfo], title: Unio if start_wiki is None: if isinstance(session, Bot.MessageSession): - await session.sendMessage( - f'没有指定起始Wiki,已默认指定为中文Minecraft Wiki,发送{session.prefixes[0]}wiki set <域名>来设定自定义起始Wiki。' - f'\n例子:{session.prefixes[0]}wiki set https://minecraft.fandom.com/zh/wiki/') + await session.sendMessage(msg.locale.t('wiki.set.message.default', prefix=session.prefixes[0])) start_wiki = 'https://minecraft.fandom.com/zh/api.php' if title is not None: if isinstance(title, str): title = [title] if len(title) > 15: - raise AbuseWarning('一次性查询的页面超出15个。') + raise AbuseWarning(msg.locale.t('tos.reason.wiki_abuse')) query_task = {start_wiki: {'query': [], 'iw_prefix': ''}} for t in title: if prefix is not None and use_prefix: @@ -147,7 +145,7 @@ async def query_pages(session: Union[Bot.MessageSession, QueryInfo], title: Unio try: tasks = [] for rd in ready_for_query_pages: - if rd == '随机页面': + if rd in {'随机页面', "隨機頁面", "Random"} or : tasks.append(asyncio.create_task( WikiLib(q, headers).random_page())) else: @@ -179,11 +177,9 @@ async def query_pages(session: Union[Bot.MessageSession, QueryInfo], title: Unio plain_slice = [] if display_before_title is not None and display_before_title != display_title: if r.before_page_property == 'template' and r.page_property == 'page': - plain_slice.append( - f'([{display_before_title}]不存在,已自动重定向至[{display_title}])') + plain_slice.append(msg.locale.t('wiki.message.redirect.template_to_page', title=display_before_title, redirected_title=display_title)) else: - plain_slice.append( - f'(重定向[{display_before_title}] -> [{display_title}])') + plain_slice.append(msg.locale.t('wiki.message.redirect', title=display_before_title, redirected_title=display_title)) if r.desc is not None and r.desc != '': plain_slice.append(r.desc) if r.link is not None: @@ -247,24 +243,22 @@ async def query_pages(session: Union[Bot.MessageSession, QueryInfo], title: Unio if r.desc is not None and r.desc != '': plain_slice.append(r.desc) if r.invalid_namespace and r.before_title is not None: - plain_slice.append( - f'此Wiki上没有名为{r.invalid_namespace}的命名空间,请检查拼写后再试。') + plain_slice.append(msg.locale.t('wiki.message.invalid_namespace')) if r.before_page_property == 'template': if r.before_title.split(':')[1].isupper(): - plain_slice.append( - f'提示:机器人暂不支持魔术字。') + plain_slice.append(msg.locale.t('wiki.message.magic_word')) if plain_slice: msg_list.append(Plain('\n'.join(plain_slice))) if wait_plain_slice: wait_msg_list.append( Plain('\n'.join(wait_plain_slice))) except WhatAreUDoingError: - raise AbuseWarning('使机器人重定向页面的次数过多。') + raise AbuseWarning(msg.locale.t('tos.reason.too_many_redirects')) except InvalidWikiError as e: if isinstance(session, Bot.MessageSession): - await session.sendMessage(f'发生错误:' + str(e)) + await session.sendMessage(msg.locale.t('error') + str(e)) else: - msg_list.append(Plain(f'发生错误:' + str(e))) + msg_list.append(Plain(msg.locale.t('error') + str(e))) if isinstance(session, Bot.MessageSession): if msg_list: if all([not render_infobox_list, not render_section_list,