koishi-plugin-noah 2.1.3 → 2.2.0
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.
- package/lib/global/config.d.ts +16 -0
- package/lib/index.cjs +39 -30
- package/lib/servers/index.d.ts +1 -0
- package/lib/types/config.d.ts +14 -8
- package/package.json +1 -1
|
@@ -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: () =>
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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.
|
|
1939
|
+
url = ctx.globalConfig.maoServerUrl;
|
|
1940
1940
|
serverName = "MaoMaNi";
|
|
1941
1941
|
} else if (serverType === "official") {
|
|
1942
|
-
url = ctx.
|
|
1942
|
+
url = ctx.globalConfig.official_support_url;
|
|
1943
1943
|
serverName = "Official";
|
|
1944
1944
|
} else {
|
|
1945
1945
|
let attempts = 0;
|
|
@@ -2262,7 +2262,7 @@ var zh_CN_default2 = { _config: { $desc: "Core 模块设置", adminUsers: "**插
|
|
|
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
|
;
|
|
@@ -4133,7 +4133,7 @@ __name(apply8, "apply");
|
|
|
4133
4133
|
var sdvx_exports = {};
|
|
4134
4134
|
__export(sdvx_exports, {
|
|
4135
4135
|
apply: () => apply13,
|
|
4136
|
-
inject: () =>
|
|
4136
|
+
inject: () => inject3,
|
|
4137
4137
|
logger: () => logger4,
|
|
4138
4138
|
name: () => name13
|
|
4139
4139
|
});
|
|
@@ -4941,6 +4941,7 @@ var servers_exports = {};
|
|
|
4941
4941
|
__export(servers_exports, {
|
|
4942
4942
|
ServerManager: () => ServerManager,
|
|
4943
4943
|
apply: () => apply9,
|
|
4944
|
+
inject: () => inject2,
|
|
4944
4945
|
name: () => name9
|
|
4945
4946
|
});
|
|
4946
4947
|
|
|
@@ -5192,7 +5193,7 @@ var SDVXService2 = class _SDVXService {
|
|
|
5192
5193
|
*/
|
|
5193
5194
|
async getUserName(ctx, url, cardId) {
|
|
5194
5195
|
const response = await ctx.http.get(`/my?card=${cardId}`, {
|
|
5195
|
-
baseURL:
|
|
5196
|
+
baseURL: ctx.globalConfig.maoServerUrl,
|
|
5196
5197
|
responseType: "text"
|
|
5197
5198
|
});
|
|
5198
5199
|
const match = response.match(/猫网玩家\[([^\]]+)\]/);
|
|
@@ -5210,7 +5211,7 @@ var SDVXService2 = class _SDVXService {
|
|
|
5210
5211
|
* @returns 验证是否通过
|
|
5211
5212
|
*/
|
|
5212
5213
|
async verifyPin(ctx, url, cardId, pin) {
|
|
5213
|
-
const apiKey = ctx.
|
|
5214
|
+
const apiKey = ctx.globalConfig.maoApiKey;
|
|
5214
5215
|
if (!apiKey) {
|
|
5215
5216
|
this.logger.warn("maoApiKey not configured");
|
|
5216
5217
|
return false;
|
|
@@ -5218,7 +5219,7 @@ var SDVXService2 = class _SDVXService {
|
|
|
5218
5219
|
const resp = await ctx.http.get(
|
|
5219
5220
|
`/bot/v2/player/card?card=${cardId}`,
|
|
5220
5221
|
{
|
|
5221
|
-
baseURL:
|
|
5222
|
+
baseURL: ctx.globalConfig.maoServerUrl,
|
|
5222
5223
|
headers: { "X-API-Key": apiKey }
|
|
5223
5224
|
}
|
|
5224
5225
|
);
|
|
@@ -5238,13 +5239,13 @@ var SDVXService2 = class _SDVXService {
|
|
|
5238
5239
|
}
|
|
5239
5240
|
async getAllScore(ctx, url, cardId, config) {
|
|
5240
5241
|
try {
|
|
5241
|
-
const apiKey = ctx.
|
|
5242
|
+
const apiKey = ctx.globalConfig.maoApiKey;
|
|
5242
5243
|
if (!apiKey) {
|
|
5243
5244
|
this.logger.warn("maoApiKey not configured");
|
|
5244
5245
|
return [];
|
|
5245
5246
|
}
|
|
5246
5247
|
const resp = await ctx.http.get(`/bot/v2/sdvx/scores?card=${cardId}`, {
|
|
5247
|
-
baseURL:
|
|
5248
|
+
baseURL: ctx.globalConfig.maoServerUrl,
|
|
5248
5249
|
headers: { "X-API-Key": apiKey }
|
|
5249
5250
|
});
|
|
5250
5251
|
if (resp?.code !== 0 || !resp?.data) {
|
|
@@ -5302,13 +5303,13 @@ var SDVXService2 = class _SDVXService {
|
|
|
5302
5303
|
}
|
|
5303
5304
|
}
|
|
5304
5305
|
async getScore(ctx, url, cardId, musicId, config) {
|
|
5305
|
-
const apiKey = ctx.
|
|
5306
|
+
const apiKey = ctx.globalConfig.maoApiKey;
|
|
5306
5307
|
if (!apiKey) {
|
|
5307
5308
|
this.logger.warn("maoApiKey not configured");
|
|
5308
5309
|
throw new Error("maoApiKey not configured");
|
|
5309
5310
|
}
|
|
5310
5311
|
const resp = await ctx.http.get(`/bot/v2/sdvx/find?card=${cardId}&mid=${musicId}`, {
|
|
5311
|
-
baseURL:
|
|
5312
|
+
baseURL: ctx.globalConfig.maoServerUrl,
|
|
5312
5313
|
headers: { "X-API-Key": apiKey }
|
|
5313
5314
|
});
|
|
5314
5315
|
if (resp?.code !== 0 || !resp?.data) {
|
|
@@ -5382,13 +5383,13 @@ var SDVXService2 = class _SDVXService {
|
|
|
5382
5383
|
return scoreObj;
|
|
5383
5384
|
}
|
|
5384
5385
|
async getRecentScores(ctx, url, cardId, config, count = 1) {
|
|
5385
|
-
const apiKey = ctx.
|
|
5386
|
+
const apiKey = ctx.globalConfig.maoApiKey;
|
|
5386
5387
|
if (!apiKey) {
|
|
5387
5388
|
this.logger.warn("maoApiKey not configured");
|
|
5388
5389
|
return [];
|
|
5389
5390
|
}
|
|
5390
5391
|
const resp = await ctx.http.get(`/bot/v2/sdvx/recent?card=${cardId}&count=${count}`, {
|
|
5391
|
-
baseURL:
|
|
5392
|
+
baseURL: ctx.globalConfig.maoServerUrl,
|
|
5392
5393
|
headers: { "X-API-Key": apiKey }
|
|
5393
5394
|
});
|
|
5394
5395
|
if (resp?.code !== 0 || !resp?.data || resp.data.length === 0) {
|
|
@@ -5635,6 +5636,7 @@ var ServerFactory = class {
|
|
|
5635
5636
|
|
|
5636
5637
|
// src/servers/index.ts
|
|
5637
5638
|
var name9 = "Noah-Server";
|
|
5639
|
+
var inject2 = ["globalConfig"];
|
|
5638
5640
|
var ServerManager = class _ServerManager {
|
|
5639
5641
|
static {
|
|
5640
5642
|
__name(this, "ServerManager");
|
|
@@ -6458,7 +6460,7 @@ var zh_CN_default4 = { _config: { $desc: "SDVX 模块设置", default_model: "<p
|
|
|
6458
6460
|
|
|
6459
6461
|
// src/games/sdvx/index.ts
|
|
6460
6462
|
var name13 = "Noah-SDVX";
|
|
6461
|
-
var
|
|
6463
|
+
var inject3 = ["database", "globalConfig"];
|
|
6462
6464
|
var logger4 = new import_koishi18.Logger("Noah-SDVX");
|
|
6463
6465
|
async function apply13(ctx, config) {
|
|
6464
6466
|
;
|
|
@@ -6473,7 +6475,7 @@ async function apply13(ctx, config) {
|
|
|
6473
6475
|
__name(apply13, "apply");
|
|
6474
6476
|
|
|
6475
6477
|
// src/config.ts
|
|
6476
|
-
var
|
|
6478
|
+
var import_koishi26 = require("koishi");
|
|
6477
6479
|
|
|
6478
6480
|
// src/asset/config.ts
|
|
6479
6481
|
var import_koishi19 = require("koishi");
|
|
@@ -6493,9 +6495,7 @@ var assetConfig = import_koishi19.Schema.object({
|
|
|
6493
6495
|
var import_koishi20 = require("koishi");
|
|
6494
6496
|
var coreConfig = import_koishi20.Schema.object({
|
|
6495
6497
|
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")
|
|
6498
|
+
guildNameCards: import_koishi20.Schema.array(String).role("table").default(["Noah | /help 获取食用指南"])
|
|
6499
6499
|
}).i18n({
|
|
6500
6500
|
"en-US": en_US_default2._config,
|
|
6501
6501
|
"zh-CN": zh_CN_default2._config
|
|
@@ -6545,15 +6545,22 @@ var import_koishi23 = require("koishi");
|
|
|
6545
6545
|
var sdvxConfig = import_koishi23.Schema.object({
|
|
6546
6546
|
default_model: import_koishi23.Schema.string().default("2025100700"),
|
|
6547
6547
|
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()
|
|
6548
|
+
sdvx_search_url: import_koishi23.Schema.string().required()
|
|
6550
6549
|
}).i18n({
|
|
6551
6550
|
"en-US": en_US_default4._config,
|
|
6552
6551
|
"zh-CN": zh_CN_default4._config
|
|
6553
6552
|
});
|
|
6554
6553
|
|
|
6555
|
-
// src/
|
|
6554
|
+
// src/global/config.ts
|
|
6556
6555
|
var import_koishi24 = require("koishi");
|
|
6556
|
+
var globalConfig = import_koishi24.Schema.object({
|
|
6557
|
+
official_support_url: import_koishi24.Schema.string().default("https://noah.logthm.com"),
|
|
6558
|
+
maoServerUrl: import_koishi24.Schema.string().default("http://maomani.cn:577"),
|
|
6559
|
+
maoApiKey: import_koishi24.Schema.string().role("secret").default("")
|
|
6560
|
+
});
|
|
6561
|
+
|
|
6562
|
+
// src/slash/config.ts
|
|
6563
|
+
var import_koishi25 = require("koishi");
|
|
6557
6564
|
|
|
6558
6565
|
// src/slash/locales/en-US.yml
|
|
6559
6566
|
var en_US_default6 = { _config: { $desc: "Slash Module Settings", test_guilds: "**Guilds To Sync**", auto_sync_on_start: "**Auto Sync on Connect**" } };
|
|
@@ -6562,16 +6569,17 @@ var en_US_default6 = { _config: { $desc: "Slash Module Settings", test_guilds: "
|
|
|
6562
6569
|
var zh_CN_default6 = { _config: { $desc: "Slash 模块设置", test_guilds: "**默认同步 Guild 列表**", auto_sync_on_start: "**连接后自动同步**" } };
|
|
6563
6570
|
|
|
6564
6571
|
// src/slash/config.ts
|
|
6565
|
-
var slashConfig =
|
|
6566
|
-
test_guilds:
|
|
6567
|
-
auto_sync_on_start:
|
|
6572
|
+
var slashConfig = import_koishi25.Schema.object({
|
|
6573
|
+
test_guilds: import_koishi25.Schema.array(String).default([]),
|
|
6574
|
+
auto_sync_on_start: import_koishi25.Schema.boolean().default(true)
|
|
6568
6575
|
}).i18n({
|
|
6569
6576
|
"en-US": en_US_default6._config,
|
|
6570
6577
|
"zh-CN": zh_CN_default6._config
|
|
6571
6578
|
});
|
|
6572
6579
|
|
|
6573
6580
|
// src/config.ts
|
|
6574
|
-
var Config =
|
|
6581
|
+
var Config = import_koishi26.Schema.object({
|
|
6582
|
+
global: globalConfig,
|
|
6575
6583
|
core: coreConfig,
|
|
6576
6584
|
sdvx: sdvxConfig,
|
|
6577
6585
|
poke: pokeConfig,
|
|
@@ -6582,9 +6590,10 @@ var Config = import_koishi25.Schema.object({
|
|
|
6582
6590
|
|
|
6583
6591
|
// src/index.ts
|
|
6584
6592
|
var name14 = "noah";
|
|
6585
|
-
var
|
|
6593
|
+
var inject4 = ["database", "skia"];
|
|
6586
6594
|
async function apply14(ctx, config) {
|
|
6587
6595
|
initConstants(ctx);
|
|
6596
|
+
ctx.set("globalConfig", config.global);
|
|
6588
6597
|
ctx.plugin(core_exports, config);
|
|
6589
6598
|
ctx.plugin(general_exports, config);
|
|
6590
6599
|
ctx.plugin(sdvx_exports, config);
|
package/lib/servers/index.d.ts
CHANGED
|
@@ -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;
|
package/lib/types/config.d.ts
CHANGED
|
@@ -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 游戏配置 */
|