koishi-plugin-noah 2.1.3 → 2.2.1

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,16 @@
1
+ import { Schema } from 'koishi';
2
+ import { GlobalConfig } from '../types/config';
3
+ export declare const globalConfig: Schema<Schemastery.ObjectS<{
4
+ official_support_url: Schema<string, string>;
5
+ maoServerUrl: Schema<string, string>;
6
+ maoApiKey: Schema<string, string>;
7
+ }>, Schemastery.ObjectT<{
8
+ official_support_url: Schema<string, string>;
9
+ maoServerUrl: Schema<string, string>;
10
+ maoApiKey: Schema<string, string>;
11
+ }>>;
12
+ declare module 'koishi' {
13
+ interface Context {
14
+ globalConfig: GlobalConfig;
15
+ }
16
+ }
package/lib/index.cjs CHANGED
@@ -32,7 +32,7 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  Config: () => Config,
34
34
  apply: () => apply14,
35
- inject: () => inject3,
35
+ inject: () => inject4,
36
36
  name: () => name14
37
37
  });
38
38
  module.exports = __toCommonJS(index_exports);
@@ -1001,7 +1001,7 @@ async function ensureOfficialServerForUser(ctx, serverService, userService, uid,
1001
1001
  const userServers = await serverService.getServersByUid(uid);
1002
1002
  const existingOfficial = userServers.find((server3) => server3.type === "official");
1003
1003
  if (existingOfficial) return existingOfficial.id;
1004
- const baseUrl = officialSupportUrl || ctx.config.official_support_url;
1004
+ const baseUrl = officialSupportUrl || ctx.globalConfig.official_support_url;
1005
1005
  const server2 = await serverService.createServerForUser(
1006
1006
  {
1007
1007
  type: "official",
@@ -1059,7 +1059,7 @@ function bind(ctx, config) {
1059
1059
  serverService,
1060
1060
  userService,
1061
1061
  session.user.id,
1062
- config.official_support_url
1062
+ ctx.globalConfig.official_support_url
1063
1063
  );
1064
1064
  }
1065
1065
  const res = await cardService.createCard(
@@ -1301,7 +1301,7 @@ async function showCardMenu(ctx, session, card2, cardService, serverService, use
1301
1301
  serverService,
1302
1302
  userService,
1303
1303
  uid,
1304
- ctx.config.official_support_url
1304
+ ctx.globalConfig.official_support_url
1305
1305
  );
1306
1306
  }
1307
1307
  await cardService.updateCard(card2.id, { code: cardCode, defaultServerId });
@@ -1936,10 +1936,10 @@ async function addServer(ctx, session, serverService, userService, from, uid, us
1936
1936
  let url;
1937
1937
  let serverName;
1938
1938
  if (serverType === "mao") {
1939
- url = ctx.config.maoServerUrl;
1939
+ url = ctx.globalConfig.maoServerUrl;
1940
1940
  serverName = "MaoMaNi";
1941
1941
  } else if (serverType === "official") {
1942
- url = ctx.config.official_support_url;
1942
+ url = ctx.globalConfig.official_support_url;
1943
1943
  serverName = "Official";
1944
1944
  } else {
1945
1945
  let attempts = 0;
@@ -2252,17 +2252,17 @@ function apply4(ctx, config) {
2252
2252
  __name(apply4, "apply");
2253
2253
 
2254
2254
  // src/core/locales/en-US.yml
2255
- var en_US_default2 = { _config: { $desc: "Core Module Settings", adminUsers: "**Plugin Admin** User ID (use inspect command to get)", guildNameCards: "**Group Card** Name List", maoServerUrl: "**Mao Server** URL address", official_support_url: "**Official Support** URL address" }, commands: { maintain: { description: "Switch to maintenance mode", messages: { "no-auth": "<p>You don't have permission to use this feature~</p>", start: "<p>Entering maintenance mode</p>", "success-start": "<p>Successfully switched to maintenance mode</p>", stop: "<p>Exiting maintenance mode</p>", "success-stop": "<p>Successfully exited maintenance mode</p>" } }, timeout: "Noah didn't wait for your reply, please try again!", noah: { help: { description: "Show Noah help information", messages: { content: "<p>Guide:</p>\nhttps://docs.logthm.cn/noah" } } }, 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>" } }, link: { description: "Link account to another platform", options: { remove: "Unlink" }, messages: { "generated-1": `<p>The Link command can be used to link user data across multiple platforms. During the linking process, the original platform's user data is fully preserved, while the target platform's user data is overwritten.</p>
2255
+ var en_US_default2 = { _config: { $desc: "Core Module Settings", adminUsers: "**Plugin Admin** User ID (use inspect command to get)", guildNameCards: "**Group Card** Name List", maoServerUrl: "**Mao Server** URL address", official_support_url: "**Official Support** URL address" }, commands: { maintain: { description: "Switch to maintenance mode", messages: { "no-auth": "<p>You don't have permission to use this feature~</p>", start: "<p>Entering maintenance mode</p>", "success-start": "<p>Successfully switched to maintenance mode</p>", stop: "<p>Exiting maintenance mode</p>", "success-stop": "<p>Successfully exited maintenance mode</p>" } }, timeout: "Noah didn't wait for your reply, please try again!", help: { description: "Show Noah help information", messages: { content: "<p>Guide:</p>\nhttps://docs.logthm.cn/noah" } }, 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>" } }, link: { description: "Link account to another platform", options: { remove: "Unlink" }, messages: { "generated-1": `<p>The Link command can be used to link user data across multiple platforms. During the linking process, the original platform's user data is fully preserved, while the target platform's user data is overwritten.</p>
2256
2256
  <p>Please make sure the current platform is your target platform and send the following text to the bot on the original platform within 5 minutes:</p>
2257
2257
  <p>{0}</p>
2258
2258
  <p>Once linked, you can use "link -r" to unlink at any time.</p>`, "generated-2": "<p>Token verified! Now proceeding to the second step.</p>\n<p>Please send the following text to the bot on the target platform within 5 minutes:</p>\n<p>{0}</p>\n<p>Note: The current platform is your original platform. User data here will overwrite the target platform's data.</p>", "self-1": "<p>Please enter this on the original platform.</p>", "self-2": "<p>Please enter this on the target platform.</p>", success: "<p>Account linked successfully!</p>", "remove-success": "<p>Account unlinked successfully!</p>", "remove-original": "<p>Cannot unlink: this is your original account.</p>" } }, bind: { description: "Bind card", messages: { prompt: "<p>Please enter your card number:</p>", "convert-access-failed": "<p>Failed to convert Access Code, please use 16-digit card code instead.</p>", "invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</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", options: { detail: "Show detailed card information" }, 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>", "lookup-error": "Lookup failed: {message}", "lookup-error-unknown": "Lookup failed: unknown error", "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: { "no-channel": "<p>Please use this feature in group chats~</p>", "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-2-invalid-url": "<p>Invalid URL format! Please enter a valid url address.</p>", "menu-2-too-many-attempts": "<p>Too many attempts. Operation cancelled.</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-invalid-url": "<p>Invalid URL format! Please enter a valid url address.</p>", "add-too-many-attempts": "<p>Too many attempts. Operation cancelled.</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>" } } } };
2259
2259
 
2260
2260
  // src/core/locales/zh-CN.yml
2261
- var zh_CN_default2 = { _config: { $desc: "Core 模块设置", adminUsers: "**插件管理员** 的用户id (使用 inspect 指令获取)", guildNameCards: "**群聊卡片** 的名称列表", maoServerUrl: "**猫网服务器** 的 URL 地址", official_support_url: "**官方支持** 的 URL 地址" }, commands: { maintain: { description: "切换到维护模式", messages: { "no-auth": "<p>你没有权限使用本功能哦~</p>", start: "<p>正在进入维护模式</p>", "success-start": "<p>成功切换到维护模式</p>", stop: "<p>正在退出维护模式</p>", "success-stop": "<p>成功退出维护模式</p>" } }, timeout: "Noah 没等到你的回复,请重试!", noah: { help: { description: "显示 Noah 帮助信息", messages: { content: "<p>使用文档:</p>\nhttps://docs.logthm.cn/noah" } } }, 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>" } }, link: { description: "关联账号到其他平台", options: { remove: "解除关联" }, messages: { "generated-1": "<p>Link 指令可用于在多个平台间关联用户数据。关联过程中,原始平台的用户数据将完全保留,而目标平台的用户数据将被原始平台的数据所覆盖。</p>\n<p>请确认当前平台是你的目标平台,并在 5 分钟内使用你的账号在原始平台内向机器人发送以下文本:</p>\n<p>{0}</p>\n<p>关联完成后,你可以随时使用「link -r」来解除关联。</p>", "generated-2": "<p>令牌核验成功!下面将进行第二步操作。</p>\n<p>请在 5 分钟内使用你的账号在目标平台内向机器人发送以下文本:</p>\n<p>{0}</p>\n<p>注意:当前平台是你的原始平台,这里的用户数据将覆盖目标平台的数据。</p>", "self-1": "<p>请前往原始平台输入。</p>", "self-2": "<p>请前往目标平台输入。</p>", success: "<p>账号关联成功!</p>", "remove-success": "<p>账号解除关联成功!</p>", "remove-original": "<p>无法解除关联:这是你的原始账号。</p>" } }, bind: { description: "绑定卡片", messages: { prompt: "<p>请输入你的卡号:</p>", "convert-access-failed": "<p>转换 Access Code 失败,请使用 16 位卡号进行绑定。</p>", "invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", name: "<p>收到!为这张卡取一个名字吧,不要带空格哦:</p>", "invalid-name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", success: "<p>绑好啦,你的卡片信息如下:</p>\n<p>[{cardName}]</p>\n<p>{cardCode}</p>" } }, card: { description: "管理卡片", options: { detail: "显示卡片详细信息" }, messages: { "invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", "invalid-select": "<p>没有该选项!</p>", quit: "<p>已退出~</p>", "lookup-error": "查询失败: {message}", "lookup-error-unknown": "查询失败: 未知错误", "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: { "no-channel": "<p>请在群聊中使用本功能哦~</p>", "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-2-invalid-url": "<p>URL 格式不正确!请输入有效的 url 地址。</p>", "menu-2-too-many-attempts": "<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-invalid-url": "<p>URL 格式不正确!请输入有效的 url 地址。</p>", "add-too-many-attempts": "<p>尝试次数过多,操作已取消。</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>" } } } };
2261
+ var zh_CN_default2 = { _config: { $desc: "Core 模块设置", adminUsers: "**插件管理员** 的用户id (使用 inspect 指令获取)", guildNameCards: "**群聊卡片** 的名称列表", maoServerUrl: "**猫网服务器** 的 URL 地址", official_support_url: "**官方支持** 的 URL 地址" }, commands: { maintain: { description: "切换到维护模式", messages: { "no-auth": "<p>你没有权限使用本功能哦~</p>", start: "<p>正在进入维护模式</p>", "success-start": "<p>成功切换到维护模式</p>", stop: "<p>正在退出维护模式</p>", "success-stop": "<p>成功退出维护模式</p>" } }, timeout: "Noah 没等到你的回复,请重试!", help: { description: "显示 Noah 帮助信息", messages: { content: "<p>使用文档:</p>\nhttps://docs.logthm.cn/noah" } }, 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>" } }, link: { description: "关联账号到其他平台", options: { remove: "解除关联" }, messages: { "generated-1": "<p>Link 指令可用于在多个平台间关联用户数据。关联过程中,原始平台的用户数据将完全保留,而目标平台的用户数据将被原始平台的数据所覆盖。</p>\n<p>请确认当前平台是你的目标平台,并在 5 分钟内使用你的账号在原始平台内向机器人发送以下文本:</p>\n<p>{0}</p>\n<p>关联完成后,你可以随时使用「link -r」来解除关联。</p>", "generated-2": "<p>令牌核验成功!下面将进行第二步操作。</p>\n<p>请在 5 分钟内使用你的账号在目标平台内向机器人发送以下文本:</p>\n<p>{0}</p>\n<p>注意:当前平台是你的原始平台,这里的用户数据将覆盖目标平台的数据。</p>", "self-1": "<p>请前往原始平台输入。</p>", "self-2": "<p>请前往目标平台输入。</p>", success: "<p>账号关联成功!</p>", "remove-success": "<p>账号解除关联成功!</p>", "remove-original": "<p>无法解除关联:这是你的原始账号。</p>" } }, bind: { description: "绑定卡片", messages: { prompt: "<p>请输入你的卡号:</p>", "convert-access-failed": "<p>转换 Access Code 失败,请使用 16 位卡号进行绑定。</p>", "invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", name: "<p>收到!为这张卡取一个名字吧,不要带空格哦:</p>", "invalid-name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", success: "<p>绑好啦,你的卡片信息如下:</p>\n<p>[{cardName}]</p>\n<p>{cardCode}</p>" } }, card: { description: "管理卡片", options: { detail: "显示卡片详细信息" }, messages: { "invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", "invalid-select": "<p>没有该选项!</p>", quit: "<p>已退出~</p>", "lookup-error": "查询失败: {message}", "lookup-error-unknown": "查询失败: 未知错误", "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: { "no-channel": "<p>请在群聊中使用本功能哦~</p>", "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-2-invalid-url": "<p>URL 格式不正确!请输入有效的 url 地址。</p>", "menu-2-too-many-attempts": "<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-invalid-url": "<p>URL 格式不正确!请输入有效的 url 地址。</p>", "add-too-many-attempts": "<p>尝试次数过多,操作已取消。</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>" } } } };
2262
2262
 
2263
2263
  // src/core/index.ts
2264
2264
  var name5 = "Noah-Core";
2265
- var inject = ["database"];
2265
+ var inject = ["database", "globalConfig"];
2266
2266
  var logger2 = new import_koishi6.Logger("Noah-Core");
2267
2267
  function apply5(ctx, config) {
2268
2268
  ;
@@ -2991,10 +2991,7 @@ var SDVXDrawer = class extends BaseDrawer {
2991
2991
  let jacketImage;
2992
2992
  try {
2993
2993
  if (options.score.difficulty_data?.cover_url) {
2994
- const coverUrl = `${options.config.sdvx_data_url}${options.score.difficulty_data.cover_url}`.replace(
2995
- ".webp",
2996
- ".png"
2997
- );
2994
+ const coverUrl = `${options.config.sdvx_data_url}${options.score.difficulty_data.cover_url}`;
2998
2995
  jacketImage = await loadImage(coverUrl);
2999
2996
  }
3000
2997
  } catch (error) {
@@ -3218,23 +3215,30 @@ var SDVXDrawer = class extends BaseDrawer {
3218
3215
  const jacketImages = {};
3219
3216
  const uniqueUrls = [
3220
3217
  ...new Set(
3221
- scores.filter((s) => s.difficulty_data?.cover_url).map(
3222
- (s) => `${config.sdvx_data_url}${s.difficulty_data.cover_url}`.replace(
3223
- ".webp",
3224
- ".png"
3225
- )
3226
- )
3218
+ scores.filter((s) => s.difficulty_data?.cover_url).map((s) => `${config.sdvx_data_url}${s.difficulty_data.cover_url}`)
3227
3219
  )
3228
3220
  ];
3229
- const jacketEntries = await Promise.all(
3230
- uniqueUrls.map(async (url) => {
3231
- try {
3232
- return [url, await loadImage(url)];
3233
- } catch {
3221
+ const concurrency = 5;
3222
+ const jacketEntries = [];
3223
+ for (let i = 0; i < uniqueUrls.length; i += concurrency) {
3224
+ const batch = uniqueUrls.slice(i, i + concurrency);
3225
+ const results = await Promise.all(
3226
+ batch.map(async (url) => {
3227
+ for (let attempt = 0; attempt < 3; attempt++) {
3228
+ try {
3229
+ return [url, await loadImage(url)];
3230
+ } catch (e) {
3231
+ this.ctx.logger("SDVX-Drawer").warn(
3232
+ `Failed to load jacket (attempt ${attempt + 1}/3): ${url} — ${e.message}`
3233
+ );
3234
+ if (attempt === 2) return [url, null];
3235
+ }
3236
+ }
3234
3237
  return [url, null];
3235
- }
3236
- })
3237
- );
3238
+ })
3239
+ );
3240
+ jacketEntries.push(...results);
3241
+ }
3238
3242
  for (const [url, img] of jacketEntries) {
3239
3243
  if (img) jacketImages[url] = img;
3240
3244
  }
@@ -3456,10 +3460,7 @@ var SDVXDrawer = class extends BaseDrawer {
3456
3460
  }
3457
3461
  ctx.fillStyle = "#FFFFFF";
3458
3462
  if (score.difficulty_data?.cover_url) {
3459
- const coverUrl = `${config.sdvx_data_url}${score.difficulty_data.cover_url}`.replace(
3460
- ".webp",
3461
- ".png"
3462
- );
3463
+ const coverUrl = `${config.sdvx_data_url}${score.difficulty_data.cover_url}`;
3463
3464
  const jacketImage = jacketImages[coverUrl];
3464
3465
  if (jacketImage) {
3465
3466
  ctx.drawImage(jacketImage, x + 24, y + 89, 300, 300);
@@ -4133,7 +4134,7 @@ __name(apply8, "apply");
4133
4134
  var sdvx_exports = {};
4134
4135
  __export(sdvx_exports, {
4135
4136
  apply: () => apply13,
4136
- inject: () => inject2,
4137
+ inject: () => inject3,
4137
4138
  logger: () => logger4,
4138
4139
  name: () => name13
4139
4140
  });
@@ -4941,6 +4942,7 @@ var servers_exports = {};
4941
4942
  __export(servers_exports, {
4942
4943
  ServerManager: () => ServerManager,
4943
4944
  apply: () => apply9,
4945
+ inject: () => inject2,
4944
4946
  name: () => name9
4945
4947
  });
4946
4948
 
@@ -5192,7 +5194,7 @@ var SDVXService2 = class _SDVXService {
5192
5194
  */
5193
5195
  async getUserName(ctx, url, cardId) {
5194
5196
  const response = await ctx.http.get(`/my?card=${cardId}`, {
5195
- baseURL: url,
5197
+ baseURL: ctx.globalConfig.maoServerUrl,
5196
5198
  responseType: "text"
5197
5199
  });
5198
5200
  const match = response.match(/猫网玩家\[([^\]]+)\]/);
@@ -5210,7 +5212,7 @@ var SDVXService2 = class _SDVXService {
5210
5212
  * @returns 验证是否通过
5211
5213
  */
5212
5214
  async verifyPin(ctx, url, cardId, pin) {
5213
- const apiKey = ctx.config.maoApiKey;
5215
+ const apiKey = ctx.globalConfig.maoApiKey;
5214
5216
  if (!apiKey) {
5215
5217
  this.logger.warn("maoApiKey not configured");
5216
5218
  return false;
@@ -5218,7 +5220,7 @@ var SDVXService2 = class _SDVXService {
5218
5220
  const resp = await ctx.http.get(
5219
5221
  `/bot/v2/player/card?card=${cardId}`,
5220
5222
  {
5221
- baseURL: url,
5223
+ baseURL: ctx.globalConfig.maoServerUrl,
5222
5224
  headers: { "X-API-Key": apiKey }
5223
5225
  }
5224
5226
  );
@@ -5238,13 +5240,13 @@ var SDVXService2 = class _SDVXService {
5238
5240
  }
5239
5241
  async getAllScore(ctx, url, cardId, config) {
5240
5242
  try {
5241
- const apiKey = ctx.config.maoApiKey;
5243
+ const apiKey = ctx.globalConfig.maoApiKey;
5242
5244
  if (!apiKey) {
5243
5245
  this.logger.warn("maoApiKey not configured");
5244
5246
  return [];
5245
5247
  }
5246
5248
  const resp = await ctx.http.get(`/bot/v2/sdvx/scores?card=${cardId}`, {
5247
- baseURL: url,
5249
+ baseURL: ctx.globalConfig.maoServerUrl,
5248
5250
  headers: { "X-API-Key": apiKey }
5249
5251
  });
5250
5252
  if (resp?.code !== 0 || !resp?.data) {
@@ -5302,13 +5304,13 @@ var SDVXService2 = class _SDVXService {
5302
5304
  }
5303
5305
  }
5304
5306
  async getScore(ctx, url, cardId, musicId, config) {
5305
- const apiKey = ctx.config.maoApiKey;
5307
+ const apiKey = ctx.globalConfig.maoApiKey;
5306
5308
  if (!apiKey) {
5307
5309
  this.logger.warn("maoApiKey not configured");
5308
5310
  throw new Error("maoApiKey not configured");
5309
5311
  }
5310
5312
  const resp = await ctx.http.get(`/bot/v2/sdvx/find?card=${cardId}&mid=${musicId}`, {
5311
- baseURL: url,
5313
+ baseURL: ctx.globalConfig.maoServerUrl,
5312
5314
  headers: { "X-API-Key": apiKey }
5313
5315
  });
5314
5316
  if (resp?.code !== 0 || !resp?.data) {
@@ -5382,13 +5384,13 @@ var SDVXService2 = class _SDVXService {
5382
5384
  return scoreObj;
5383
5385
  }
5384
5386
  async getRecentScores(ctx, url, cardId, config, count = 1) {
5385
- const apiKey = ctx.config.maoApiKey;
5387
+ const apiKey = ctx.globalConfig.maoApiKey;
5386
5388
  if (!apiKey) {
5387
5389
  this.logger.warn("maoApiKey not configured");
5388
5390
  return [];
5389
5391
  }
5390
5392
  const resp = await ctx.http.get(`/bot/v2/sdvx/recent?card=${cardId}&count=${count}`, {
5391
- baseURL: url,
5393
+ baseURL: ctx.globalConfig.maoServerUrl,
5392
5394
  headers: { "X-API-Key": apiKey }
5393
5395
  });
5394
5396
  if (resp?.code !== 0 || !resp?.data || resp.data.length === 0) {
@@ -5635,6 +5637,7 @@ var ServerFactory = class {
5635
5637
 
5636
5638
  // src/servers/index.ts
5637
5639
  var name9 = "Noah-Server";
5640
+ var inject2 = ["globalConfig"];
5638
5641
  var ServerManager = class _ServerManager {
5639
5642
  static {
5640
5643
  __name(this, "ServerManager");
@@ -6458,7 +6461,7 @@ var zh_CN_default4 = { _config: { $desc: "SDVX 模块设置", default_model: "<p
6458
6461
 
6459
6462
  // src/games/sdvx/index.ts
6460
6463
  var name13 = "Noah-SDVX";
6461
- var inject2 = ["database"];
6464
+ var inject3 = ["database", "globalConfig"];
6462
6465
  var logger4 = new import_koishi18.Logger("Noah-SDVX");
6463
6466
  async function apply13(ctx, config) {
6464
6467
  ;
@@ -6473,7 +6476,7 @@ async function apply13(ctx, config) {
6473
6476
  __name(apply13, "apply");
6474
6477
 
6475
6478
  // src/config.ts
6476
- var import_koishi25 = require("koishi");
6479
+ var import_koishi26 = require("koishi");
6477
6480
 
6478
6481
  // src/asset/config.ts
6479
6482
  var import_koishi19 = require("koishi");
@@ -6493,9 +6496,7 @@ var assetConfig = import_koishi19.Schema.object({
6493
6496
  var import_koishi20 = require("koishi");
6494
6497
  var coreConfig = import_koishi20.Schema.object({
6495
6498
  adminUsers: import_koishi20.Schema.array(String).role("table"),
6496
- guildNameCards: import_koishi20.Schema.array(String).role("table").default(["Noah | /help 获取食用指南"]),
6497
- maoServerUrl: import_koishi20.Schema.string().default("http://maomani.cn:573"),
6498
- official_support_url: import_koishi20.Schema.string().default("https://noah.logthm.com")
6499
+ guildNameCards: import_koishi20.Schema.array(String).role("table").default(["Noah | /help 获取食用指南"])
6499
6500
  }).i18n({
6500
6501
  "en-US": en_US_default2._config,
6501
6502
  "zh-CN": zh_CN_default2._config
@@ -6545,15 +6546,22 @@ var import_koishi23 = require("koishi");
6545
6546
  var sdvxConfig = import_koishi23.Schema.object({
6546
6547
  default_model: import_koishi23.Schema.string().default("2025100700"),
6547
6548
  sdvx_data_url: import_koishi23.Schema.string().required(),
6548
- sdvx_search_url: import_koishi23.Schema.string().required(),
6549
- official_support_url: import_koishi23.Schema.string().required()
6549
+ sdvx_search_url: import_koishi23.Schema.string().required()
6550
6550
  }).i18n({
6551
6551
  "en-US": en_US_default4._config,
6552
6552
  "zh-CN": zh_CN_default4._config
6553
6553
  });
6554
6554
 
6555
- // src/slash/config.ts
6555
+ // src/global/config.ts
6556
6556
  var import_koishi24 = require("koishi");
6557
+ var globalConfig = import_koishi24.Schema.object({
6558
+ official_support_url: import_koishi24.Schema.string().default("https://noah.logthm.com"),
6559
+ maoServerUrl: import_koishi24.Schema.string().default("http://maomani.cn:577"),
6560
+ maoApiKey: import_koishi24.Schema.string().role("secret").default("")
6561
+ });
6562
+
6563
+ // src/slash/config.ts
6564
+ var import_koishi25 = require("koishi");
6557
6565
 
6558
6566
  // src/slash/locales/en-US.yml
6559
6567
  var en_US_default6 = { _config: { $desc: "Slash Module Settings", test_guilds: "**Guilds To Sync**", auto_sync_on_start: "**Auto Sync on Connect**" } };
@@ -6562,16 +6570,17 @@ var en_US_default6 = { _config: { $desc: "Slash Module Settings", test_guilds: "
6562
6570
  var zh_CN_default6 = { _config: { $desc: "Slash 模块设置", test_guilds: "**默认同步 Guild 列表**", auto_sync_on_start: "**连接后自动同步**" } };
6563
6571
 
6564
6572
  // src/slash/config.ts
6565
- var slashConfig = import_koishi24.Schema.object({
6566
- test_guilds: import_koishi24.Schema.array(String).default([]),
6567
- auto_sync_on_start: import_koishi24.Schema.boolean().default(true)
6573
+ var slashConfig = import_koishi25.Schema.object({
6574
+ test_guilds: import_koishi25.Schema.array(String).default([]),
6575
+ auto_sync_on_start: import_koishi25.Schema.boolean().default(true)
6568
6576
  }).i18n({
6569
6577
  "en-US": en_US_default6._config,
6570
6578
  "zh-CN": zh_CN_default6._config
6571
6579
  });
6572
6580
 
6573
6581
  // src/config.ts
6574
- var Config = import_koishi25.Schema.object({
6582
+ var Config = import_koishi26.Schema.object({
6583
+ global: globalConfig,
6575
6584
  core: coreConfig,
6576
6585
  sdvx: sdvxConfig,
6577
6586
  poke: pokeConfig,
@@ -6582,9 +6591,10 @@ var Config = import_koishi25.Schema.object({
6582
6591
 
6583
6592
  // src/index.ts
6584
6593
  var name14 = "noah";
6585
- var inject3 = ["database", "skia"];
6594
+ var inject4 = ["database", "skia"];
6586
6595
  async function apply14(ctx, config) {
6587
6596
  initConstants(ctx);
6597
+ ctx.set("globalConfig", config.global);
6588
6598
  ctx.plugin(core_exports, config);
6589
6599
  ctx.plugin(general_exports, config);
6590
6600
  ctx.plugin(sdvx_exports, config);
@@ -2,6 +2,7 @@ import { Context } from 'koishi';
2
2
  import { TServer, TGame } from '../types';
3
3
  import type { AppConfig } from '../types/config';
4
4
  export declare const name = "Noah-Server";
5
+ export declare const inject: string[];
5
6
  export declare class ServerManager {
6
7
  private static instance;
7
8
  private factory;
@@ -5,6 +5,18 @@ import { MessageReply } from '../fun/poke/types';
5
5
  */
6
6
  export interface BaseConfig {
7
7
  }
8
+ /**
9
+ * 全局配置接口
10
+ * 包含所有模块共享的配置项
11
+ */
12
+ export interface GlobalConfig extends BaseConfig {
13
+ /** Official Support URL */
14
+ official_support_url?: string;
15
+ /** 猫网服务器 URL */
16
+ maoServerUrl?: string;
17
+ /** 猫网服务器 API Key */
18
+ maoApiKey?: string;
19
+ }
8
20
  /**
9
21
  * Slash 配置接口
10
22
  * 包含 Slash 相关的配置项
@@ -24,12 +36,6 @@ export interface CoreConfig extends BaseConfig {
24
36
  adminUsers?: string[];
25
37
  /** 群名片列表 */
26
38
  guildNameCards?: string[];
27
- /** 猫网服务器 URL */
28
- maoServerUrl?: string;
29
- /** 猫网服务器 API Key */
30
- maoApiKey?: string;
31
- /** Official Support URL */
32
- official_support_url?: string;
33
39
  }
34
40
  /**
35
41
  * SDVX 游戏配置接口
@@ -42,8 +48,6 @@ export interface SDVXConfig extends BaseConfig {
42
48
  sdvx_data_url: string;
43
49
  /** SDVX 搜索 URL */
44
50
  sdvx_search_url: string;
45
- /** Official Support URL */
46
- official_support_url: string;
47
51
  }
48
52
  /**
49
53
  * 戳一戳功能配置接口
@@ -80,6 +84,8 @@ export interface AssetConfig extends BaseConfig {
80
84
  * 包含所有模块的配置项
81
85
  */
82
86
  export interface AppConfig {
87
+ /** 全局配置 */
88
+ global: GlobalConfig;
83
89
  /** 核心配置 */
84
90
  core: CoreConfig;
85
91
  /** SDVX 游戏配置 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-noah",
3
- "version": "2.1.3",
3
+ "version": "2.2.1",
4
4
  "contributors": [
5
5
  "Logthm <logthm@outlook.com>"
6
6
  ],