Revert "fix:coerce"

This reverts commit dd895d7c17.
This commit is contained in:
手瓜一十雪
2025-04-19 10:58:56 +08:00
parent 2a4589e268
commit d3a27ad701
88 changed files with 276 additions and 277 deletions

View File

@@ -3,13 +3,13 @@ import { NapCatCore } from '@/core';
import { z } from 'zod'; import { z } from 'zod';
export const NapcatConfigSchema = z.object({ export const NapcatConfigSchema = z.object({
fileLog: z.coerce.boolean().default(false), fileLog: z.boolean().default(false),
consoleLog: z.coerce.boolean().default(true), consoleLog: z.boolean().default(true),
fileLogLevel: z.coerce.string().default('debug'), fileLogLevel: z.string().default('debug'),
consoleLogLevel: z.coerce.string().default('info'), consoleLogLevel: z.string().default('info'),
packetBackend: z.coerce.string().default('auto'), packetBackend: z.string().default('auto'),
packetServer: z.coerce.string().default(''), packetServer: z.string().default(''),
o3HookMode: z.coerce.number().default(0), o3HookMode: z.number().default(0),
}); });
export type NapcatConfig = z.infer<typeof NapcatConfigSchema>; export type NapcatConfig = z.infer<typeof NapcatConfigSchema>;

View File

@@ -3,11 +3,11 @@ import { OneBotAction } from '../OneBotAction';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.coerce.string(), group_id: z.string(),
bot_appid: z.coerce.string(), bot_appid: z.string(),
button_id: z.coerce.string().default(''), button_id: z.string().default(''),
callback_data: z.coerce.string().default(''), callback_data: z.string().default(''),
msg_seq: z.coerce.string().default('10086'), msg_seq: z.string().default('10086'),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
rawData: z.coerce.string(), rawData: z.string(),
brief: z.coerce.string(), brief: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '@/onebot/action/router'; import { ActionName } from '@/onebot/action/router';
const SchemaData = z.object({ const SchemaData = z.object({
count: z.coerce.number().default(48), count: z.number().default(48),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,10 +5,10 @@ import { MessageUnique } from '@/common/message-unique';
import { type NTQQMsgApi } from '@/core/apis'; import { type NTQQMsgApi } from '@/core/apis';
const SchemaData = z.object({ const SchemaData = z.object({
message_id: z.coerce.string(), message_id: z.string(),
emojiId: z.coerce.string(), emojiId: z.string(),
emojiType: z.coerce.string(), emojiType: z.string(),
count: z.coerce.number().default(20), count: z.number().default(20),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,8 +4,8 @@ import { AIVoiceChatType } from '@/core/packet/entities/aiChat';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.coerce.string(), group_id: z.string(),
chat_type: z.coerce.number().default(1), chat_type: z.number().default(1),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,8 +4,8 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
category: z.coerce.number(), category: z.number(),
count: z.coerce.number().default(1), count: z.number().default(1),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -2,7 +2,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '@/onebot/action/router'; import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.coerce.string(), group_id: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -7,30 +7,30 @@ import { z } from 'zod';
const SchemaData = z.union([ const SchemaData = z.union([
z.object({ z.object({
type: z.union([z.literal('bili'), z.literal('weibo')]), type: z.union([z.literal('bili'), z.literal('weibo')]),
title: z.coerce.string(), title: z.string(),
desc: z.coerce.string(), desc: z.string(),
picUrl: z.coerce.string(), picUrl: z.string(),
jumpUrl: z.coerce.string(), jumpUrl: z.string(),
webUrl: z.coerce.string().optional(), webUrl: z.string().optional(),
rawArkData: z.coerce.string().optional() rawArkData: z.string().optional()
}), }),
z.object({ z.object({
title: z.coerce.string(), title: z.string(),
desc: z.coerce.string(), desc: z.string(),
picUrl: z.coerce.string(), picUrl: z.string(),
jumpUrl: z.coerce.string(), jumpUrl: z.string(),
iconUrl: z.coerce.string(), iconUrl: z.string(),
webUrl: z.coerce.string().optional(), webUrl: z.string().optional(),
appId: z.coerce.string(), appId: z.string(),
scene: z.union([z.coerce.number(), z.coerce.string()]), scene: z.union([z.number(), z.string()]),
templateType: z.union([z.coerce.number(), z.coerce.string()]), templateType: z.union([z.number(), z.string()]),
businessType: z.union([z.coerce.number(), z.coerce.string()]), businessType: z.union([z.number(), z.string()]),
verType: z.union([z.coerce.number(), z.coerce.string()]), verType: z.union([z.number(), z.string()]),
shareType: z.union([z.coerce.number(), z.coerce.string()]), shareType: z.union([z.number(), z.string()]),
versionId: z.coerce.string(), versionId: z.string(),
sdkId: z.coerce.string(), sdkId: z.string(),
withShareTicket: z.union([z.coerce.number(), z.coerce.string()]), withShareTicket: z.union([z.number(), z.string()]),
rawArkData: z.coerce.string().optional() rawArkData: z.string().optional()
}) })
]); ]);
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
user_id: z.coerce.string().optional(), user_id: z.string().optional(),
start: z.coerce.number().default(0), start: z.number().default(0),
count: z.coerce.number().default(10), count: z.number().default(10),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
user_id: z.coerce.number(), user_id: z.number(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,10 +4,10 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
file_id: z.coerce.string(), file_id: z.string(),
current_parent_directory: z.coerce.string(), current_parent_directory: z.string(),
target_parent_directory: z.coerce.string(), target_parent_directory: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -6,7 +6,7 @@ import { z } from 'zod';
import { GeneralCallResultStatus } from '@/core'; import { GeneralCallResultStatus } from '@/core';
const SchemaData = z.object({ const SchemaData = z.object({
image: z.coerce.string(), image: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,10 +4,10 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
file_id: z.coerce.string(), file_id: z.string(),
current_parent_directory: z.coerce.string(), current_parent_directory: z.string(),
new_name: z.coerce.string(), new_name: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
cmd: z.coerce.string(), cmd: z.string(),
data: z.coerce.string(), data: z.string(),
rsp: z.coerce.boolean().default(true), rsp: z.boolean().default(true),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,9 +3,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
face_id: z.union([z.coerce.number(), z.coerce.string()]),// 参考 face_config.json 的 QSid face_id: z.union([z.number(), z.string()]),// 参考 face_config.json 的 QSid
face_type: z.union([z.coerce.number(), z.coerce.string()]).default('1'), face_type: z.union([z.number(), z.string()]).default('1'),
wording: z.coerce.string().default(' '), wording: z.string().default(' '),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.coerce.string(), group_id: z.string(),
remark: z.coerce.string(), remark: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,8 +4,8 @@ import { ChatType } from '@/core';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
event_type: z.coerce.number(), event_type: z.number(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
longNick: z.coerce.string(), longNick: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,9 +3,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
status: z.union([z.coerce.number(), z.coerce.string()]), status: z.union([z.number(), z.string()]),
ext_status: z.union([z.coerce.number(), z.coerce.string()]), ext_status: z.union([z.number(), z.string()]),
battery_status: z.union([z.coerce.number(), z.coerce.string()]), battery_status: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,7 +5,7 @@ import { checkFileExist, uriToLocalFile } from '@/common/file';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
file: z.coerce.string(), file: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,9 +3,9 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
special_title: z.coerce.string().default(''), special_title: z.string().default(''),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
user_id: z.union([z.coerce.number(), z.coerce.string()]).optional(), user_id: z.union([z.number(), z.string()]).optional(),
group_id: z.union([z.coerce.number(), z.coerce.string()]).optional(), group_id: z.union([z.number(), z.string()]).optional(),
phoneNumber: z.coerce.string().default(''), phoneNumber: z.string().default(''),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;
@@ -29,7 +29,7 @@ export class SharePeer extends OneBotAction<Payload, GeneralCallResult & {
} }
const SchemaDataGroupEx = z.object({ const SchemaDataGroupEx = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
}); });
type PayloadGroupEx = z.infer<typeof SchemaDataGroupEx>; type PayloadGroupEx = z.infer<typeof SchemaDataGroupEx>;

View File

@@ -4,8 +4,8 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
file_id: z.coerce.string(), file_id: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
words: z.array(z.coerce.string()), words: z.array(z.string()),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -14,8 +14,8 @@ export interface GetFileResponse {
} }
const GetFileBase_PayloadSchema = z.object({ const GetFileBase_PayloadSchema = z.object({
file: z.coerce.string().optional(), file: z.string().optional(),
file_id: z.coerce.string().optional(), file_id: z.string().optional(),
}); });

View File

@@ -4,8 +4,8 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
file_id: z.coerce.string(), file_id: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,7 +4,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
file_id: z.coerce.string(), file_id: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
folder_name: z.coerce.string(), folder_name: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -6,8 +6,8 @@ import { z } from 'zod';
import { NTQQGroupApi } from '@/core/apis'; import { NTQQGroupApi } from '@/core/apis';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
file_id: z.coerce.string(), file_id: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { z } from 'zod';
import { NTQQGroupApi } from '@/core/apis'; import { NTQQGroupApi } from '@/core/apis';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
folder_id: z.coerce.string().optional(), folder_id: z.string().optional(),
folder: z.coerce.string().optional(), folder: z.string().optional(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -11,10 +11,10 @@ interface FileResponse {
} }
const SchemaData = z.object({ const SchemaData = z.object({
url: z.coerce.string().optional(), url: z.string().optional(),
base64: z.coerce.string().optional(), base64: z.string().optional(),
name: z.coerce.string().optional(), name: z.string().optional(),
headers: z.union([z.coerce.string(), z.array(z.coerce.string())]).optional(), headers: z.union([z.string(), z.array(z.string())]).optional(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -7,8 +7,8 @@ import { z } from 'zod';
import { isNumeric } from '@/common/helper'; import { isNumeric } from '@/common/helper';
const SchemaData = z.object({ const SchemaData = z.object({
message_id: z.coerce.string().optional(), message_id: z.string().optional(),
id: z.coerce.string().optional(), id: z.string().optional(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -10,10 +10,10 @@ interface Response {
messages: OB11Message[]; messages: OB11Message[];
} }
const SchemaData = z.object({ const SchemaData = z.object({
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
message_seq: z.union([z.coerce.number(), z.coerce.string()]).optional(), message_seq: z.union([z.number(), z.string()]).optional(),
count: z.union([z.coerce.number(), z.coerce.string()]).default(20), count: z.union([z.number(), z.string()]).default(20),
reverseOrder: z.coerce.boolean().default(false) reverseOrder: z.boolean().default(false)
}); });

View File

@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]) group_id: z.union([z.number(), z.string()])
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]) group_id: z.union([z.number(), z.string()])
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,10 +5,10 @@ import { OB11Construct } from '@/onebot/helper/data';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
folder_id: z.coerce.string().optional(), folder_id: z.string().optional(),
folder: z.coerce.string().optional(), folder: z.string().optional(),
file_count: z.union([z.coerce.number(), z.coerce.string()]).default(50), file_count: z.union([z.number(), z.string()]).default(50),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,7 +4,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
type: z.nativeEnum(WebHonorType).optional() type: z.nativeEnum(WebHonorType).optional()
}); });

View File

@@ -11,10 +11,10 @@ interface Response {
} }
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
message_seq: z.union([z.coerce.number(), z.coerce.string()]).optional(), message_seq: z.union([z.number(), z.string()]).optional(),
count: z.union([z.coerce.number(), z.coerce.string()]).default(20), count: z.union([z.number(), z.string()]).default(20),
reverseOrder: z.coerce.boolean().default(false) reverseOrder: z.boolean().default(false)
}); });

View File

@@ -6,8 +6,8 @@ import { OB11Construct } from '@/onebot/helper/data';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
file_count: z.union([z.coerce.number(), z.coerce.string()]).default(50), file_count: z.union([z.number(), z.string()]).default(50),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -6,8 +6,8 @@ import { calcQQLevel } from '@/common/helper';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
no_cache: z.coerce.boolean().default(false), no_cache: z.boolean().default(false),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
url: z.coerce.string(), url: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,10 +3,10 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
friend_id: z.union([z.coerce.string(), z.coerce.number()]).optional(), friend_id: z.union([z.string(), z.number()]).optional(),
user_id: z.union([z.coerce.string(), z.coerce.number()]).optional(), user_id: z.union([z.string(), z.number()]).optional(),
temp_block: z.coerce.boolean().optional(), temp_block: z.boolean().optional(),
temp_both_del: z.coerce.boolean().optional(), temp_both_del: z.boolean().optional(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
model: z.coerce.string(), model: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,14 +5,14 @@ import { unlink } from 'node:fs/promises';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
content: z.coerce.string(), content: z.string(),
image: z.coerce.string().optional(), image: z.string().optional(),
pinned: z.union([z.coerce.number(), z.coerce.string()]).default(0), pinned: z.union([z.number(), z.string()]).default(0),
type: z.union([z.coerce.number(), z.coerce.string()]).default(1), type: z.union([z.number(), z.string()]).default(1),
confirm_required: z.union([z.coerce.number(), z.coerce.string()]).default(1), confirm_required: z.union([z.number(), z.string()]).default(1),
is_show_edit_card: z.union([z.coerce.number(), z.coerce.string()]).default(0), is_show_edit_card: z.union([z.number(), z.string()]).default(0),
tip_window_type: z.union([z.coerce.number(), z.coerce.string()]).default(0), tip_window_type: z.union([z.number(), z.string()]).default(0),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,8 +5,8 @@ import { z } from 'zod';
import fs from 'node:fs/promises'; import fs from 'node:fs/promises';
import { GeneralCallResult } from '@/core'; import { GeneralCallResult } from '@/core';
const SchemaData = z.object({ const SchemaData = z.object({
file: z.coerce.string(), file: z.string(),
group_id: z.union([z.coerce.number(), z.coerce.string()]) group_id: z.union([z.number(), z.string()])
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
nickname: z.coerce.string(), nickname: z.string(),
personal_note: z.coerce.string().optional(), personal_note: z.string().optional(),
sex: z.union([z.coerce.number(), z.coerce.string()]).optional(), // 传Sex值建议传0 sex: z.union([z.number(), z.string()]).optional(), // 传Sex值建议传0
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -7,11 +7,11 @@ import { SendMessageContext } from '@/onebot/api';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
file: z.coerce.string(), file: z.string(),
name: z.coerce.string(), name: z.string(),
folder: z.coerce.string().optional(), folder: z.string().optional(),
folder_id: z.coerce.string().optional(),//临时扩展 folder_id: z.string().optional(),//临时扩展
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -8,9 +8,9 @@ import { ContextMode, createContext } from '@/onebot/action/msg/SendMsg';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
file: z.coerce.string(), file: z.string(),
name: z.coerce.string(), name: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,7 +4,7 @@ import { MessageUnique } from '@/common/message-unique';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
message_id: z.union([z.coerce.number(), z.coerce.string()]), message_id: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
notice_id: z.coerce.string() notice_id: z.string()
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { AIVoiceChatType } from '@/core/packet/entities/aiChat';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
character: z.coerce.string(), character: z.string(),
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
text: z.coerce.string(), text: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -7,7 +7,7 @@ import { z } from 'zod';
import { NetworkAdapterConfig } from '@/onebot/config/config'; import { NetworkAdapterConfig } from '@/onebot/config/config';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,7 +5,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,7 +5,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
no_cache: z.coerce.boolean().default(false), no_cache: z.boolean().default(false),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,9 +5,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
no_cache: z.coerce.boolean().default(false), no_cache: z.boolean().default(false),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -6,8 +6,8 @@ import { z } from 'zod';
import { GroupMember } from '@/core'; import { GroupMember } from '@/core';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
no_cache: z.coerce.boolean().default(false) no_cache: z.boolean().default(false)
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -17,7 +17,7 @@ interface GroupNotice {
} }
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,7 +4,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,8 +3,8 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { AIVoiceChatType } from '@/core/packet/entities/aiChat';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
character: z.coerce.string(), character: z.string(),
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
text: z.coerce.string(), text: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,7 +4,7 @@ import { MessageUnique } from '@/common/message-unique';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
message_id: z.union([z.coerce.number(), z.coerce.string()]), message_id: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
flag: z.union([z.coerce.string(), z.coerce.number()]), flag: z.union([z.string(), z.number()]),
approve: z.coerce.boolean().default(true), approve: z.boolean().default(true),
reason: z.union([z.coerce.string(), z.null()]).default(' '), reason: z.union([z.string(), z.null()]).default(' '),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
enable: z.coerce.boolean().default(false), enable: z.boolean().default(false),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,9 +3,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
duration: z.union([z.coerce.number(), z.coerce.string()]).default(0), duration: z.union([z.number(), z.string()]).default(0),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,9 +3,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
card: z.coerce.string().optional(), card: z.string().optional(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,9 +3,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
reject_add_request: z.union([z.coerce.boolean(), z.coerce.string()]).optional(), reject_add_request: z.union([z.boolean(), z.string()]).optional(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
is_dismiss: z.coerce.boolean().optional(), is_dismiss: z.boolean().optional(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,8 +4,8 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
group_name: z.coerce.string(), group_name: z.string(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]), group_id: z.union([z.number(), z.string()]),
enable: z.union([z.coerce.boolean(), z.coerce.string()]).optional(), enable: z.union([z.boolean(), z.string()]).optional(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,7 +4,7 @@ import { MessageUnique } from '@/common/message-unique';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
message_id: z.union([z.coerce.number(), z.coerce.string()]), message_id: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,9 +5,9 @@ import { MessageUnique } from '@/common/message-unique';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
message_id: z.union([z.coerce.number(), z.coerce.string()]), message_id: z.union([z.number(), z.string()]),
group_id: z.coerce.string().optional(), group_id: z.string().optional(),
user_id: z.coerce.string().optional(), user_id: z.string().optional(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -9,7 +9,7 @@ import { NetworkAdapterConfig } from '@/onebot/config/config';
export type ReturnDataType = OB11Message export type ReturnDataType = OB11Message
const SchemaData = z.object({ const SchemaData = z.object({
message_id: z.union([z.coerce.number(), z.coerce.string()]), message_id: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,9 +5,9 @@ import { MessageUnique } from '@/common/message-unique';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
user_id: z.union([z.coerce.string(), z.coerce.number()]).optional(), user_id: z.union([z.string(), z.number()]).optional(),
group_id: z.union([z.coerce.string(), z.coerce.number()]).optional(), group_id: z.union([z.string(), z.number()]).optional(),
message_id: z.union([z.coerce.string(), z.coerce.number()]).optional(), message_id: z.union([z.string(), z.number()]).optional(),
}); });
type PlayloadType = z.infer<typeof SchemaData>; type PlayloadType = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { MessageUnique } from '@/common/message-unique';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
message_id: z.union([z.coerce.number(), z.coerce.string()]), message_id: z.union([z.number(), z.string()]),
emoji_id: z.union([z.coerce.number(), z.coerce.string()]), emoji_id: z.union([z.number(), z.string()]),
set: z.coerce.boolean().optional(), set: z.boolean().optional(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,8 +3,8 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
group_id: z.union([z.coerce.number(), z.coerce.string()]).optional(), group_id: z.union([z.number(), z.string()]).optional(),
user_id: z.union([z.coerce.number(), z.coerce.string()]), user_id: z.union([z.number(), z.string()]),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -8,7 +8,7 @@ interface Response {
} }
const SchemaData = z.object({ const SchemaData = z.object({
domain: z.coerce.string() domain: z.string()
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
user_id: z.union([z.coerce.number(), z.coerce.string()]) user_id: z.union([z.number(), z.string()])
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -7,7 +7,7 @@ interface Response {
} }
const SchemaData = z.object({ const SchemaData = z.object({
domain: z.coerce.string() domain: z.string()
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,7 +5,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
no_cache: z.coerce.boolean().optional(), no_cache: z.boolean().optional(),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,7 +5,7 @@ import { NetworkAdapterConfig } from '@/onebot/config/config';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
count: z.coerce.number().default(10), count: z.number().default(10),
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
times: z.union([z.coerce.number(), z.coerce.string()]).default(1), times: z.union([z.number(), z.string()]).default(1),
user_id: z.union([z.coerce.number(), z.coerce.string()]) user_id: z.union([z.number(), z.string()])
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,9 +3,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod'; import { z } from 'zod';
const SchemaData = z.object({ const SchemaData = z.object({
flag: z.union([z.coerce.string(), z.coerce.number()]), flag: z.union([z.string(), z.number()]),
approve: z.union([z.coerce.string(), z.coerce.boolean()]).default(true), approve: z.union([z.string(), z.boolean()]).default(true),
remark: z.union([z.coerce.string(), z.null()]).nullable().optional() remark: z.union([z.string(), z.null()]).nullable().optional()
}); });
type Payload = z.infer<typeof SchemaData>; type Payload = z.infer<typeof SchemaData>;

View File

@@ -1,71 +1,71 @@
import { z } from 'zod'; import { z } from 'zod';
const HttpServerConfigSchema = z.object({ const HttpServerConfigSchema = z.object({
name: z.coerce.string().default('http-server'), name: z.string().default('http-server'),
enable: z.coerce.boolean().default(false), enable: z.boolean().default(false),
port: z.coerce.number().default(3000), port: z.number().default(3000),
host: z.coerce.string().default('0.0.0.0'), host: z.string().default('0.0.0.0'),
enableCors: z.coerce.boolean().default(true), enableCors: z.boolean().default(true),
enableWebsocket: z.coerce.boolean().default(true), enableWebsocket: z.boolean().default(true),
messagePostFormat: z.coerce.string().default('array'), messagePostFormat: z.string().default('array'),
token: z.coerce.string().default(''), token: z.string().default(''),
debug: z.coerce.boolean().default(false) debug: z.boolean().default(false)
}); });
const HttpSseServerConfigSchema = z.object({ const HttpSseServerConfigSchema = z.object({
name: z.coerce.string().default('http-sse-server'), name: z.string().default('http-sse-server'),
enable: z.coerce.boolean().default(false), enable: z.boolean().default(false),
port: z.coerce.number().default(3000), port: z.number().default(3000),
host: z.coerce.string().default('0.0.0.0'), host: z.string().default('0.0.0.0'),
enableCors: z.coerce.boolean().default(true), enableCors: z.boolean().default(true),
enableWebsocket: z.coerce.boolean().default(true), enableWebsocket: z.boolean().default(true),
messagePostFormat: z.coerce.string().default('array'), messagePostFormat: z.string().default('array'),
token: z.coerce.string().default(''), token: z.string().default(''),
debug: z.coerce.boolean().default(false), debug: z.boolean().default(false),
reportSelfMessage: z.coerce.boolean().default(false) reportSelfMessage: z.boolean().default(false)
}); });
const HttpClientConfigSchema = z.object({ const HttpClientConfigSchema = z.object({
name: z.coerce.string().default('http-client'), name: z.string().default('http-client'),
enable: z.coerce.boolean().default(false), enable: z.boolean().default(false),
url: z.coerce.string().default('http://localhost:8080'), url: z.string().default('http://localhost:8080'),
messagePostFormat: z.coerce.string().default('array'), messagePostFormat: z.string().default('array'),
reportSelfMessage: z.coerce.boolean().default(false), reportSelfMessage: z.boolean().default(false),
token: z.coerce.string().default(''), token: z.string().default(''),
debug: z.coerce.boolean().default(false) debug: z.boolean().default(false)
}); });
const WebsocketServerConfigSchema = z.object({ const WebsocketServerConfigSchema = z.object({
name: z.coerce.string().default('websocket-server'), name: z.string().default('websocket-server'),
enable: z.coerce.boolean().default(false), enable: z.boolean().default(false),
host: z.coerce.string().default('0.0.0.0'), host: z.string().default('0.0.0.0'),
port: z.coerce.number().default(3001), port: z.number().default(3001),
messagePostFormat: z.coerce.string().default('array'), messagePostFormat: z.string().default('array'),
reportSelfMessage: z.coerce.boolean().default(false), reportSelfMessage: z.boolean().default(false),
token: z.coerce.string().default(''), token: z.string().default(''),
enableForcePushEvent: z.coerce.boolean().default(true), enableForcePushEvent: z.boolean().default(true),
debug: z.coerce.boolean().default(false), debug: z.boolean().default(false),
heartInterval: z.coerce.number().default(30000) heartInterval: z.number().default(30000)
}); });
const WebsocketClientConfigSchema = z.object({ const WebsocketClientConfigSchema = z.object({
name: z.coerce.string().default('websocket-client'), name: z.string().default('websocket-client'),
enable: z.coerce.boolean().default(false), enable: z.boolean().default(false),
url: z.coerce.string().default('ws://localhost:8082'), url: z.string().default('ws://localhost:8082'),
messagePostFormat: z.coerce.string().default('array'), messagePostFormat: z.string().default('array'),
reportSelfMessage: z.coerce.boolean().default(false), reportSelfMessage: z.boolean().default(false),
reconnectInterval: z.coerce.number().default(5000), reconnectInterval: z.number().default(5000),
token: z.coerce.string().default(''), token: z.string().default(''),
debug: z.coerce.boolean().default(false), debug: z.boolean().default(false),
heartInterval: z.coerce.number().default(30000) heartInterval: z.number().default(30000)
}); });
const PluginConfigSchema = z.object({ const PluginConfigSchema = z.object({
name: z.coerce.string().default('plugin'), name: z.string().default('plugin'),
enable: z.coerce.boolean().default(false), enable: z.boolean().default(false),
messagePostFormat: z.coerce.string().default('array'), messagePostFormat: z.string().default('array'),
reportSelfMessage: z.coerce.boolean().default(false), reportSelfMessage: z.boolean().default(false),
debug: z.coerce.boolean().default(false), debug: z.boolean().default(false),
}); });
const NetworkConfigSchema = z.object({ const NetworkConfigSchema = z.object({
@@ -79,9 +79,9 @@ const NetworkConfigSchema = z.object({
export const OneBotConfigSchema = z.object({ export const OneBotConfigSchema = z.object({
network: NetworkConfigSchema, network: NetworkConfigSchema,
musicSignUrl: z.coerce.string().default(''), musicSignUrl: z.string().default(''),
enableLocalFile2Url: z.coerce.boolean().default(false), enableLocalFile2Url: z.boolean().default(false),
parseMultMsg: z.coerce.boolean().default(false) parseMultMsg: z.boolean().default(false)
}); });
export type OneBotConfig = z.infer<typeof OneBotConfigSchema>; export type OneBotConfig = z.infer<typeof OneBotConfigSchema>;

View File

@@ -50,7 +50,6 @@ import {
import { OB11Message } from './types'; import { OB11Message } from './types';
import { IOB11NetworkAdapter } from '@/onebot/network/adapter'; import { IOB11NetworkAdapter } from '@/onebot/network/adapter';
import { OB11HttpSSEServerAdapter } from './network/http-server-sse'; import { OB11HttpSSEServerAdapter } from './network/http-server-sse';
import { ZodType } from 'zod';
//OneBot实现类 //OneBot实现类
export class NapCatOneBot11Adapter { export class NapCatOneBot11Adapter {
@@ -67,7 +66,7 @@ export class NapCatOneBot11Adapter {
constructor(core: NapCatCore, context: InstanceContext, pathWrapper: NapCatPathWrapper) { constructor(core: NapCatCore, context: InstanceContext, pathWrapper: NapCatPathWrapper) {
this.core = core; this.core = core;
this.context = context; this.context = context;
this.configLoader = new OB11ConfigLoader(core, pathWrapper.configPath, OneBotConfigSchema as ZodType<OneBotConfig>); this.configLoader = new OB11ConfigLoader(core, pathWrapper.configPath, OneBotConfigSchema);
this.apis = { this.apis = {
GroupApi: new OneBotGroupApi(this, core), GroupApi: new OneBotGroupApi(this, core),
UserApi: new OneBotUserApi(this, core), UserApi: new OneBotUserApi(this, core),

View File

@@ -6,11 +6,11 @@ import { themeType } from '../types/theme';
import { z } from 'zod'; import { z } from 'zod';
// 定义配置的类型 // 定义配置的类型
const WebUiConfigSchema = z.object({ const WebUiConfigSchema = z.object({
host: z.coerce.string().default('0.0.0.0'), host: z.string().default('0.0.0.0'),
port: z.coerce.number().default(6099), port: z.number().default(6099),
token: z.coerce.string().default('napcat'), token: z.string().default('napcat'),
loginRate: z.coerce.number().default(10), loginRate: z.number().default(10),
autoLoginAccount: z.coerce.string().default(''), autoLoginAccount: z.string().default(''),
theme: themeType, theme: themeType,
}); });

View File

@@ -2,8 +2,8 @@ import { z } from 'zod';
export const themeType = z.object( export const themeType = z.object(
{ {
dark: z.record(z.coerce.string(), z.coerce.string()), dark: z.record(z.string(), z.string()),
light: z.record(z.coerce.string(), z.coerce.string()), light: z.record(z.string(), z.string()),
} }
).default({ ).default({
dark: { dark: {