koishi-plugin-noah 1.1.4 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ import { Context } from 'koishi';
2
+ import { CoreConfig } from '../../types/config';
3
+ export declare function locale(ctx: Context, config: CoreConfig): void;
package/lib/index.js CHANGED
@@ -48,10 +48,10 @@ __export(core_exports, {
48
48
  var import_koishi3 = require("koishi");
49
49
 
50
50
  // src/core/locales/en-US.yml
51
- var en_US_default = { _config: { $desc: "Core Module Settings", adminUsers: "**Plugin Admin** User ID (use inspect command to get)" }, commands: { timeout: "Noah didn't wait for your reply, please try again!", noah: { help: { description: "Show Noah help information", messages: { content: "<p>Guide:</p>\n<a>https://docs.logthm.cn/noah</a>" } } }, bind: { description: "Bind card", messages: { prompt: "<p>Please enter your card number:</p>", "invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", duplicate: "<p>This card has already been bound (︶^︶)</p>", name: "<p>Received! Please give this card a name, no spaces allowed:</p>", invalid_name: "<p>No spaces allowed! Please try again o(一︿一+)o</p>", success: "<p>Bound successfully, your card information is as follows:</p>\n<p>[{cardName}]</p>\n<p>{cardCode}</p>" } }, card: { description: "Manage cards", messages: { "invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", "invalid-select": "<p>No such option!</p>", "menu-select": "<p>[Card Management]</p>\n{card_list}\n<p>0. Add new card</p>\n<p>Please enter the serial number:</p>", menu: "<p>[{name}]</p>\n<p>1. Set as default card</p>\n<p>2. View or modify card number</p>\n<p>3. Delete the card</p>\n<p>4. Rename the card</p>\n<p>5. Bind the card to a specified server</p>\n<p>0. Return to card selection</p>\n<p>Please enter the serial number:</p>", "menu-has-bound-server": "<p>[{name}]</p>\n<p>Bound server: {defaultServerName}</p>\n<p>1. Set as default card</p>\n<p>2. View or modify card number</p>\n<p>3. Delete the card</p>\n<p>4. Rename the card</p>\n<p>5. Bind the card to a specified server</p>\n<p>0. Return to card selection</p>\n<p>Please enter the serial number:</p>", "menu-1-success": "<p>Set successfully!</p>", "menu-1-error-duplicate": "<p>The selected card is the same as the old default card!</p>", "menu-2-prompt": "<p>Card number: {code}</p>\n<p>Please enter the new card number:</p>\n<p>Enter 0 to return</p>", "menu-2-success": "<p>Modified successfully!</p>", "menu-2-error-invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", "menu-3-success": "<p>Deleted successfully!</p>", "menu-4-prompt": "<p>Enter a new name, no spaces allowed:</p>", "menu-4-error-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "menu-4-success": "<p>Modified successfully!</p>", "menu-5": "{server_list}\n<p>Please enter the serial number:</p>", "menu-5-success": "<p>Set successfully!</p>", "menu-5-error-duplicate": "<p>The selected server is the same as the old default server!</p>" } }, server: { description: "Manage servers", messages: { "invalid-select": "<p>No such option!</p>", "no-auth": "<p>Only group admins can use this feature~</p>", "admin-menu-select": "<p>[Group server management]</p>\n{server_list}\n<p>0. Add new server</p>\n<p>Please enter the serial number:</p>", "menu-select": "<p>[Server management]</p>\n{server_list}\n<p>0. Add new server</p>\n<p>Please enter the serial number:</p>", menu: "<p>[{name}]</p>\n<p>Type: {type}</p>\n<p>1. Set as default server</p>\n<p>2. View or modify url</p>\n<p>3. Delete the server</p>\n<p>4. Rename the server</p>\n<p>0. Return to server selection</p>\n<p>Please enter the serial number:</p>", "menu-1-success": "<p>Set successfully!</p>", "menu-1-error-duplicate": "<p>The selected server is the same as the old default server!</p>", "menu-2-prompt": "<p>The server's url: {baseUrl}</p>\n<p>Please enter the new server url:</p>\n<p>Enter 0 to return</p>", "menu-2-success": "<p>Modified successfully!</p>", "menu-3-success": "<p>Deleted successfully!</p>", "menu-4-prompt": "<p>Enter a new name, no spaces allowed:</p>", "menu-4-error-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "menu-4-success": "<p>Modified successfully!</p>", "add-type": "<p>Please select the server type:</p>\n{server_type_list}", "add-url": "<p>Please enter the server url:</p>", "add-name": "<p>Received! Please give the server a name, no spaces allowed:</p>", "add-invalid_name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "add-success": "<p>Added successfully, the server information is as follows:</p>\n<p>[{serverName}]</p>\n<p>Type: {serverType}</p>" } } } };
51
+ var en_US_default = { _config: { $desc: "Core Module Settings", adminUsers: "**Plugin Admin** User ID (use inspect command to get)" }, commands: { timeout: "Noah didn't wait for your reply, please try again!", noah: { help: { description: "Show Noah help information", messages: { content: "<p>Guide:</p>\n<a>https://docs.logthm.cn/noah</a>" } } }, locale: { description: "Set language", messages: { "no-auth": "<p>Only group admins can use this feature~</p>", "invalid-select": "<p>No such option!</p>", quit: "<p>Quit!</p>", "reset-channel": "<p>Reset successfully!</p>", "reset-user": "<p>Reset successfully!</p>", success: "<p>Set successfully!</p>", "set-channel": "<p>Select the default language for group chats:</p>\n<p>1. 简体中文</p>\n<p>2. English</p>\n<p>q. Quit</p>", "set-user": "<p>Select the language you use:</p>\n<p>1. 中文</p>\n<p>2. English</p>\n<p>q. Quit</p>" } }, bind: { description: "Bind card", messages: { prompt: "<p>Please enter your card number:</p>", "invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", duplicate: "<p>This card has already been bound (︶^︶)</p>", name: "<p>Received! Please give this card a name, no spaces allowed:</p>", invalid_name: "<p>No spaces allowed! Please try again o(一︿一+)o</p>", success: "<p>Bound successfully, your card information is as follows:</p>\n<p>[{cardName}]</p>\n<p>{cardCode}</p>" } }, card: { description: "Manage cards", messages: { "invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", "invalid-select": "<p>No such option!</p>", "menu-select": "<p>[Card Management]</p>\n{card_list}\n<p>0. Add new card</p>\n<p>Please enter the serial number:</p>", menu: "<p>[{name}]</p>\n<p>1. Set as default card</p>\n<p>2. View or modify card number</p>\n<p>3. Delete the card</p>\n<p>4. Rename the card</p>\n<p>5. Bind the card to a specified server</p>\n<p>0. Return to card selection</p>\n<p>Please enter the serial number:</p>", "menu-has-bound-server": "<p>[{name}]</p>\n<p>Bound server: {defaultServerName}</p>\n<p>1. Set as default card</p>\n<p>2. View or modify card number</p>\n<p>3. Delete the card</p>\n<p>4. Rename the card</p>\n<p>5. Bind the card to a specified server</p>\n<p>0. Return to card selection</p>\n<p>Please enter the serial number:</p>", "menu-1-success": "<p>Set successfully!</p>", "menu-1-error-duplicate": "<p>The selected card is the same as the old default card!</p>", "menu-2-prompt": "<p>Card number: {code}</p>\n<p>Please enter the new card number:</p>\n<p>Enter 0 to return</p>", "menu-2-success": "<p>Modified successfully!</p>", "menu-2-error-invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", "menu-3-success": "<p>Deleted successfully!</p>", "menu-4-prompt": "<p>Enter a new name, no spaces allowed:</p>", "menu-4-error-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "menu-4-success": "<p>Modified successfully!</p>", "menu-5": "{server_list}\n<p>Please enter the serial number:</p>", "menu-5-success": "<p>Set successfully!</p>", "menu-5-error-duplicate": "<p>The selected server is the same as the old default server!</p>" } }, server: { description: "Manage servers", messages: { "invalid-select": "<p>No such option!</p>", "no-auth": "<p>Only group admins can use this feature~</p>", "admin-menu-select": "<p>[Group server management]</p>\n{server_list}\n<p>0. Add new server</p>\n<p>Please enter the serial number:</p>", "menu-select": "<p>[Server management]</p>\n{server_list}\n<p>0. Add new server</p>\n<p>Please enter the serial number:</p>", menu: "<p>[{name}]</p>\n<p>Type: {type}</p>\n<p>1. Set as default server</p>\n<p>2. View or modify url</p>\n<p>3. Delete the server</p>\n<p>4. Rename the server</p>\n<p>0. Return to server selection</p>\n<p>Please enter the serial number:</p>", "menu-1-success": "<p>Set successfully!</p>", "menu-1-error-duplicate": "<p>The selected server is the same as the old default server!</p>", "menu-2-prompt": "<p>The server's url: {baseUrl}</p>\n<p>Please enter the new server url:</p>\n<p>Enter 0 to return</p>", "menu-2-success": "<p>Modified successfully!</p>", "menu-3-success": "<p>Deleted successfully!</p>", "menu-4-prompt": "<p>Enter a new name, no spaces allowed:</p>", "menu-4-error-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "menu-4-success": "<p>Modified successfully!</p>", "add-type": "<p>Please select the server type:</p>\n{server_type_list}", "add-url": "<p>Please enter the server url:</p>", "add-name": "<p>Received! Please give the server a name, no spaces allowed:</p>", "add-invalid_name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "add-success": "<p>Added successfully, the server information is as follows:</p>\n<p>[{serverName}]</p>\n<p>Type: {serverType}</p>" } } } };
52
52
 
53
53
  // src/core/locales/zh-CN.yml
54
- var zh_CN_default = { _config: { $desc: "Core 模块设置", adminUsers: "**插件管理员** 的用户id (使用 inspect 指令获取)" }, commands: { timeout: "Noah 没等到你的回复,请重试!", noah: { help: { description: "显示 Noah 帮助信息", messages: { content: "<p>使用文档:</p>\n<a>https://docs.logthm.cn/noah</a>" } } }, bind: { description: "绑定卡片", messages: { prompt: "<p>请输入你的卡号:</p>", "invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", duplicate: "<p>这张卡已经被绑定啦 (︶^︶)</p>", name: "<p>收到!为这张卡取一个名字吧,不要带空格哦:</p>", invalid_name: "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", success: "<p>绑好啦,你的卡片信息如下:</p>\n<p>[{cardName}]</p>\n<p>{cardCode}</p>" } }, card: { description: "管理卡片", messages: { "invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", "invalid-select": "<p>没有该选项!</p>", quit: "<p>已退出~</p>", "menu-select": "<p>[卡片管理]</p>\n{card_list}\n<p>0. 添加新卡片</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", menu: "<p>[{name}]</p>\n<p>1. 设为默认卡片</p>\n<p>2. 查看或修改卡号</p>\n<p>3. 删除该卡</p>\n<p>4. 重命名该卡片</p>\n<p>5. 将卡片与指定服务器绑定</p>\n<p>0. 返回卡片选择</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-has-bound-server": "<p>[{name}]</p>\n<p>已绑定服务器:{defaultServerName}</p>\n<p>1. 设为默认卡片</p>\n<p>2. 查看或修改卡号</p>\n<p>3. 删除该卡</p>\n<p>4. 重命名该卡片</p>\n<p>5. 将卡片与指定服务器绑定</p>\n<p>0. 返回卡片选择</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-1-success": "<p>设置成功!</p>", "menu-1-error-duplicate": "<p>选择的卡片与旧的默认卡片相同!</p>", "menu-2-prompt": "<p>卡号:{code}</p>\n<p>请输入新的卡号:</p>\n<p>0. 返回</p>\n<p>q. 退出</p>", "menu-2-success": "<p>修改成功!</p>", "menu-2-error-invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", "menu-3-success": "<p>已删除!</p>", "menu-4-prompt": "<p>输入一个新名字,不要带空格哦:</p>\n<p>q. 退出</p>", "menu-4-error-invalid-name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", "menu-4-success": "<p>修改成功!</p>", "menu-5": "<p>请选择一个服务器:</p>\n{server_list}\n<p>q. 退出</p>", "menu-5-success": "<p>设置成功!</p>", "menu-5-error-duplicate": "<p>选择的服务器与旧的默认服务器相同!</p>" } }, server: { description: "管理服务器", messages: { "invalid-select": "<p>没有该选项!</p>", "no-auth": "<p>只有群管理员能使用本功能哦~</p>", quit: "<p>已退出~</p>", "admin-menu-select": "<p>[群聊服务器管理]</p>\n{server_list}\n<p>0. 添加新服务器</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-select": "<p>[服务器管理]</p>\n{server_list}\n<p>0. 添加新服务器</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", menu: "<p>[{name}]</p>\n<p>类型:{type}</p>\n<p>1. 设为默认服务器</p>\n<p>2. 查看或修改 url</p>\n<p>3. 删除该服务器</p>\n<p>4. 重命名该服务器</p>\n<p>0. 返回服务器选择</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-1-success": "<p>设置成功!</p>", "menu-1-error-duplicate": "<p>选择的服务器与旧的默认服务器相同!</p>", "menu-2-prompt": "<p>该服务器的 url:{baseUrl}</p>\n<p>请输入新的服务器 url:</p>\n<p>0. 返回</p>\n<p>q. 退出</p>", "menu-2-success": "<p>修改成功!</p>", "menu-3-success": "<p>已删除!</p>", "menu-4-prompt": "<p>输入一个新名字,不要带空格哦:</p>\n<p>0. 返回</p>\n<p>q. 退出</p>", "menu-4-error-invalid-name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", "menu-4-success": "<p>修改成功!</p>", "add-type": "<p>请选择服务器的类型:</p>\n{server_type_list}\n<p>q. 退出</p>", "add-url": "<p>请输入服务器的 url:</p>\n<p>q. 退出</p>", "add-name": "<p>收到!为服务器取一个名字吧,不要带空格哦:</p>\n<p>q. 退出</p>", "add-invalid_name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", "add-success": "<p>添加成功啦,服务器信息如下:</p>\n<p>[{serverName}]</p>\n<p>类型:{serverType}</p>" } } } };
54
+ var zh_CN_default = { _config: { $desc: "Core 模块设置", adminUsers: "**插件管理员** 的用户id (使用 inspect 指令获取)" }, commands: { timeout: "Noah 没等到你的回复,请重试!", noah: { help: { description: "显示 Noah 帮助信息", messages: { content: "<p>使用文档:</p>\n<a>https://docs.logthm.cn/noah</a>" } } }, locale: { description: "设置语言", messages: { "no-auth": "<p>只有群管理员能使用本功能哦~</p>", "invalid-select": "<p>没有该选项!</p>", quit: "<p>已退出~</p>", "reset-channel": "<p>重置成功!</p>", "reset-user": "<p>重置成功!</p>", success: "<p>设置成功!</p>", "set-channel": "<p>选择群聊默认使用的语言:</p>\n<p>1. 简体中文</p>\n<p>2. English</p>\n<p>q. 退出</p>", "set-user": "<p>选择你使用的语言:</p>\n<p>1. 简体中文</p>\n<p>2. English</p>\n<p>q. 退出</p>" } }, bind: { description: "绑定卡片", messages: { prompt: "<p>请输入你的卡号:</p>", "invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", duplicate: "<p>这张卡已经被绑定啦 (︶^︶)</p>", name: "<p>收到!为这张卡取一个名字吧,不要带空格哦:</p>", invalid_name: "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", success: "<p>绑好啦,你的卡片信息如下:</p>\n<p>[{cardName}]</p>\n<p>{cardCode}</p>" } }, card: { description: "管理卡片", messages: { "invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", "invalid-select": "<p>没有该选项!</p>", quit: "<p>已退出~</p>", "menu-select": "<p>[卡片管理]</p>\n{card_list}\n<p>0. 添加新卡片</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", menu: "<p>[{name}]</p>\n<p>1. 设为默认卡片</p>\n<p>2. 查看或修改卡号</p>\n<p>3. 删除该卡</p>\n<p>4. 重命名该卡片</p>\n<p>5. 将卡片与指定服务器绑定</p>\n<p>0. 返回卡片选择</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-has-bound-server": "<p>[{name}]</p>\n<p>已绑定服务器:{defaultServerName}</p>\n<p>1. 设为默认卡片</p>\n<p>2. 查看或修改卡号</p>\n<p>3. 删除该卡</p>\n<p>4. 重命名该卡片</p>\n<p>5. 将卡片与指定服务器绑定</p>\n<p>0. 返回卡片选择</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-1-success": "<p>设置成功!</p>", "menu-1-error-duplicate": "<p>选择的卡片与旧的默认卡片相同!</p>", "menu-2-prompt": "<p>卡号:{code}</p>\n<p>请输入新的卡号:</p>\n<p>0. 返回</p>\n<p>q. 退出</p>", "menu-2-success": "<p>修改成功!</p>", "menu-2-error-invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", "menu-3-success": "<p>已删除!</p>", "menu-4-prompt": "<p>输入一个新名字,不要带空格哦:</p>\n<p>q. 退出</p>", "menu-4-error-invalid-name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", "menu-4-success": "<p>修改成功!</p>", "menu-5": "<p>请选择一个服务器:</p>\n{server_list}\n<p>q. 退出</p>", "menu-5-success": "<p>设置成功!</p>", "menu-5-error-duplicate": "<p>选择的服务器与旧的默认服务器相同!</p>" } }, server: { description: "管理服务器", messages: { "invalid-select": "<p>没有该选项!</p>", "no-auth": "<p>只有群管理员能使用本功能哦~</p>", quit: "<p>已退出~</p>", "admin-menu-select": "<p>[群聊服务器管理]</p>\n{server_list}\n<p>0. 添加新服务器</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-select": "<p>[服务器管理]</p>\n{server_list}\n<p>0. 添加新服务器</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", menu: "<p>[{name}]</p>\n<p>类型:{type}</p>\n<p>1. 设为默认服务器</p>\n<p>2. 查看或修改 url</p>\n<p>3. 删除该服务器</p>\n<p>4. 重命名该服务器</p>\n<p>0. 返回服务器选择</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-1-success": "<p>设置成功!</p>", "menu-1-error-duplicate": "<p>选择的服务器与旧的默认服务器相同!</p>", "menu-2-prompt": "<p>该服务器的 url:{baseUrl}</p>\n<p>请输入新的服务器 url:</p>\n<p>0. 返回</p>\n<p>q. 退出</p>", "menu-2-success": "<p>修改成功!</p>", "menu-3-success": "<p>已删除!</p>", "menu-4-prompt": "<p>输入一个新名字,不要带空格哦:</p>\n<p>0. 返回</p>\n<p>q. 退出</p>", "menu-4-error-invalid-name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", "menu-4-success": "<p>修改成功!</p>", "add-type": "<p>请选择服务器的类型:</p>\n{server_type_list}\n<p>q. 退出</p>", "add-url": "<p>请输入服务器的 url:</p>\n<p>q. 退出</p>", "add-name": "<p>收到!为服务器取一个名字吧,不要带空格哦:</p>\n<p>q. 退出</p>", "add-invalid_name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", "add-success": "<p>添加成功啦,服务器信息如下:</p>\n<p>[{serverName}]</p>\n<p>类型:{serverType}</p>" } } } };
55
55
 
56
56
  // src/core/database.ts
57
57
  var database_exports = {};
@@ -1058,6 +1058,53 @@ async function addServer(ctx, session, serverService, userService, from, uid, us
1058
1058
  }
1059
1059
  __name(addServer, "addServer");
1060
1060
 
1061
+ // src/core/commands/locale.ts
1062
+ function locale(ctx, config) {
1063
+ ctx.command("locale").alias("language").option("channel", "-c").option("reset", "-r").userFields(["locales"]).channelFields(["locales"]).action(async ({ session, options }) => {
1064
+ if (options.channel && !hasPermission(isPluginAdmin(session, config), isGuildAdmin(session))) {
1065
+ return session.text(".noAuth");
1066
+ }
1067
+ if (options.reset) {
1068
+ if (options.channel) {
1069
+ session.channel.locales = [];
1070
+ await session.channel.$update();
1071
+ return session.text(".reset-channel");
1072
+ } else {
1073
+ session.user.locales = [];
1074
+ await session.user.$update();
1075
+ return session.text(".reset-user");
1076
+ }
1077
+ }
1078
+ const target = options.channel ? "channel" : "user";
1079
+ await session.send(session.text(`.set-${target}`));
1080
+ const select = await session.prompt();
1081
+ if (!select) return session.text("commands.timeout");
1082
+ if (select === "q") return session.text(".quit");
1083
+ const selectNum = parseInt(select, 10);
1084
+ if (isNaN(selectNum) || selectNum < 1 || selectNum > 2) {
1085
+ return session.text(".invalid-select");
1086
+ }
1087
+ const lang = selectNum === 1 ? "zh-CN" : "en-US";
1088
+ if (options.channel) {
1089
+ updateLocales(session.channel, lang);
1090
+ await session.channel.$update();
1091
+ } else {
1092
+ updateLocales(session.user, lang);
1093
+ await session.user.$update();
1094
+ }
1095
+ return session.text(".success");
1096
+ });
1097
+ }
1098
+ __name(locale, "locale");
1099
+ function updateLocales(target, lang) {
1100
+ const index = target.locales.indexOf(lang);
1101
+ if (index !== -1) {
1102
+ target.locales.splice(index, 1);
1103
+ }
1104
+ target.locales.unshift(lang);
1105
+ }
1106
+ __name(updateLocales, "updateLocales");
1107
+
1061
1108
  // src/core/command.ts
1062
1109
  var name2 = "command";
1063
1110
  function apply2(ctx, config) {
@@ -1065,6 +1112,7 @@ function apply2(ctx, config) {
1065
1112
  bind(ctx, config);
1066
1113
  card(ctx, config);
1067
1114
  server(ctx, config);
1115
+ locale(ctx, config);
1068
1116
  }
1069
1117
  __name(apply2, "apply");
1070
1118
 
@@ -1478,10 +1526,10 @@ var SDVXService2 = class _SDVXService {
1478
1526
  }
1479
1527
  async getAllScore(ctx, url, cardId, config) {
1480
1528
  try {
1481
- const data = await ctx.http.get(`/sdvx/scores?card=${cardId}`, { baseURL: url, responseType: "json" });
1482
- if (data.errorCode === 1 && data.errorMessage === "没有此卡或该玩家未游玩 SDVX") {
1483
- return [];
1484
- }
1529
+ const data = await ctx.http.get(`/sdvx/scores?card=${cardId}`, {
1530
+ baseURL: url,
1531
+ responseType: "json"
1532
+ });
1485
1533
  const filteredData = data.filter((score) => score.music_id !== 244 && score.music_id !== 1759 && score.music_id !== 1761);
1486
1534
  const musicIds = filteredData.map((score) => score.music_id);
1487
1535
  const diffTypes = filteredData.map((score) => parseInt(score.music_diff));
@@ -1527,6 +1575,9 @@ var SDVXService2 = class _SDVXService {
1527
1575
  });
1528
1576
  return scores;
1529
1577
  } catch (error) {
1578
+ if (error.response?.status === 404) {
1579
+ return [];
1580
+ }
1530
1581
  throw error;
1531
1582
  }
1532
1583
  }
@@ -2588,15 +2639,16 @@ function vf(ctx, config) {
2588
2639
  const sdvxService = serverManager.getGameService(server2.type, "sdvx");
2589
2640
  const scoreService = ScoreService.getInstance();
2590
2641
  try {
2591
- const scoreList = scoreService.getBest50(await sdvxService.getAllScore(ctx, server2.baseUrl, card2.code, config));
2642
+ const scoreList = await sdvxService.getAllScore(ctx, server2.baseUrl, card2.code, config);
2592
2643
  if (scoreList.length === 0) {
2593
2644
  return session.text(".no-scores-found");
2594
2645
  }
2646
+ const best50ScoreList = scoreService.getBest50(scoreList);
2595
2647
  session.send(session.text(".drawing"));
2596
2648
  const drawerManager = DrawerManager.getInstance(ctx);
2597
2649
  const sdvxDrawer = drawerManager.getDrawer("sdvx");
2598
2650
  const imageBuffer = await sdvxDrawer.generateVFImage({
2599
- scores: scoreList,
2651
+ scores: best50ScoreList,
2600
2652
  playerName: await sdvxService.getUserName(ctx, server2.baseUrl, card2.code),
2601
2653
  config
2602
2654
  }, {
@@ -2982,7 +3034,11 @@ var AssetService = class {
2982
3034
  }
2983
3035
  try {
2984
3036
  const response = await this.ctx.http.get(assetUrl, options);
2985
- import_fs.default.writeFileSync(destination, Buffer.from(response));
3037
+ if (response && typeof response === "object" && response.data) {
3038
+ import_fs.default.writeFileSync(destination, Buffer.from(response.data));
3039
+ } else {
3040
+ import_fs.default.writeFileSync(destination, Buffer.from(response));
3041
+ }
2986
3042
  this.logger.info(`Download complete: ${destination}`);
2987
3043
  } catch (error) {
2988
3044
  if (error.response?.status === 302) {
@@ -2990,10 +3046,15 @@ var AssetService = class {
2990
3046
  this.logger.info(`Following redirect to ${redirectUrl}`);
2991
3047
  const redirectResponse = await this.ctx.http.get(redirectUrl, {
2992
3048
  ...options,
2993
- maxRedirects: 5
3049
+ maxRedirects: 5,
2994
3050
  // Allow some redirects for the actual download
3051
+ responseType: "arraybuffer"
2995
3052
  });
2996
- import_fs.default.writeFileSync(destination, Buffer.from(redirectResponse.data));
3053
+ if (redirectResponse && typeof redirectResponse === "object" && redirectResponse.data) {
3054
+ import_fs.default.writeFileSync(destination, Buffer.from(redirectResponse.data));
3055
+ } else {
3056
+ import_fs.default.writeFileSync(destination, Buffer.from(redirectResponse));
3057
+ }
2997
3058
  this.logger.info(`Download complete: ${destination}`);
2998
3059
  } else {
2999
3060
  throw error;
@@ -3016,16 +3077,27 @@ var AssetService = class {
3016
3077
  await (0, import_promises.mkdir)(extractPath, { recursive: true });
3017
3078
  this.logger.info(`Extracting assets to ${extractPath}`);
3018
3079
  try {
3080
+ if (!import_fs.default.existsSync(archivePath)) {
3081
+ throw new Error(`Archive file does not exist: ${archivePath}`);
3082
+ }
3083
+ try {
3084
+ import_fs.default.accessSync(archivePath, import_fs.default.constants.R_OK);
3085
+ } catch (err) {
3086
+ throw new Error(`Archive file is not readable: ${archivePath}`);
3087
+ }
3019
3088
  const zip = new import_adm_zip.default(archivePath);
3020
3089
  const zipEntries = zip.getEntries();
3021
3090
  this.logger.info(`Found ${zipEntries.length} files in archive`);
3022
3091
  for (const entry of zipEntries) {
3023
3092
  try {
3093
+ if (entry.isDirectory) {
3094
+ continue;
3095
+ }
3024
3096
  const targetPath = import_path2.default.join(extractPath, entry.entryName);
3025
3097
  this.logger.debug(`Extracting: ${entry.entryName} to ${targetPath}`);
3026
3098
  const targetDir = import_path2.default.dirname(targetPath);
3027
3099
  await (0, import_promises.mkdir)(targetDir, { recursive: true });
3028
- zip.extractEntryTo(entry, targetDir, false, true);
3100
+ zip.extractEntryTo(entry.entryName, targetDir, false, true);
3029
3101
  if (process.platform !== "win32") {
3030
3102
  import_fs.default.chmodSync(targetPath, 420);
3031
3103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-noah",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "contributors": [
5
5
  "Logthm <logthm@outlook.com>"
6
6
  ],