Compare commits

...

4 Commits

Author SHA1 Message Date
Mlikiowa
48b648b0fb release: v4.17
Some checks failed
Build Action / Build-LiteLoader (push) Failing after 2m22s
Build Action / Build-Shell (push) Failing after 2m23s
2024-11-19 08:30:06 +00:00
手瓜一十雪
68e86b07c7 fix: #543 2024-11-19 16:29:33 +08:00
手瓜一十雪
12cb500818 refactor: rename OB11BaseEvent 2024-11-19 12:55:42 +08:00
手瓜一十雪
9ffaab178a refactor: Action 2024-11-19 12:49:51 +08:00
101 changed files with 228 additions and 242 deletions

View File

@ -4,7 +4,7 @@
"name": "NapCatQQ", "name": "NapCatQQ",
"slug": "NapCat.Framework", "slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现", "description": "高性能的 OneBot 11 协议实现",
"version": "4.1.6", "version": "4.17",
"icon": "./logo.png", "icon": "./logo.png",
"authors": [ "authors": [
{ {

View File

@ -2,7 +2,7 @@
"name": "napcat", "name": "napcat",
"private": true, "private": true,
"type": "module", "type": "module",
"version": "4.1.6", "version": "4.17",
"scripts": { "scripts": {
"build:framework": "npm run build:webui && vite build --mode framework", "build:framework": "npm run build:webui && vite build --mode framework",
"build:shell": "npm run build:webui && vite build --mode shell", "build:shell": "npm run build:webui && vite build --mode shell",

View File

@ -1 +1 @@
export const napCatVersion = '4.1.6'; export const napCatVersion = '4.17';

View File

@ -1,32 +0,0 @@
import { OB11Return } from '../types';
import { isNull } from '@/common/helper';
export class OB11Response {
static res<T>(data: T, status: string, retcode: number, message: string = ''): OB11Return<T> {
return {
status: status,
retcode: retcode,
data: data,
message: message,
wording: message,
echo: null,
};
}
static ok<T>(data: T, echo: any = null) {
const res = OB11Response.res<T>(data, 'ok', 0);
if (!isNull(echo)) {
res.echo = echo;
}
return res;
}
static error(err: string, retcode: number, echo: any = null) {
const res = OB11Response.res(null, 'failed', retcode, err);
if (!isNull(echo)) {
res.echo = echo;
}
return res;
}
}

View File

@ -1,15 +1,38 @@
import { ActionName, BaseCheckResult } from './types'; import { ActionName, BaseCheckResult } from './types';
import { OB11Response } from './OB11Response';
import { OB11Return } from '@/onebot/types';
import Ajv, { ErrorObject, ValidateFunction } from 'ajv'; import Ajv, { ErrorObject, ValidateFunction } from 'ajv';
import { NapCatCore } from '@/core'; import { NapCatCore } from '@/core';
import { isNull } from '@/common/helper';
import { NapCatOneBot11Adapter, OB11Return } from '@/onebot';
import { NapCatOneBot11Adapter } from '@/onebot'; export class OB11Response {
private static createResponse<T>(data: T, status: string, retcode: number, message: string = '', echo: any = null): OB11Return<T> {
return {
status,
retcode,
data,
message,
wording: message,
echo,
};
}
abstract class BaseAction<PayloadType, ReturnDataType> { static res<T>(data: T, status: string, retcode: number, message: string = ''): OB11Return<T> {
return this.createResponse(data, status, retcode, message);
}
static ok<T>(data: T, echo: any = null): OB11Return<T> {
return this.createResponse(data, 'ok', 0, '', echo);
}
static error(err: string, retcode: number, echo: any = null): OB11Return<null> {
return this.createResponse(null, 'failed', retcode, err, echo);
}
}
export abstract class OneBotAction<PayloadType, ReturnDataType> {
actionName: ActionName = ActionName.Unknown; actionName: ActionName = ActionName.Unknown;
core: NapCatCore; core: NapCatCore;
private validate: undefined | ValidateFunction<any> = undefined; private validate: ValidateFunction<any> | undefined = undefined;
payloadSchema: any = undefined; payloadSchema: any = undefined;
obContext: NapCatOneBot11Adapter; obContext: NapCatOneBot11Adapter;
@ -24,17 +47,13 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
} }
if (this.validate && !this.validate(payload)) { if (this.validate && !this.validate(payload)) {
const errors = this.validate.errors as ErrorObject[]; const errors = this.validate.errors as ErrorObject[];
const errorMessages: string[] = errors.map((e) => { const errorMessages = errors.map(e => `Key: ${e.instancePath.split('/').slice(1).join('.')}, Message: ${e.message}`);
return `Key: ${e.instancePath.split('/').slice(1).join('.')}, Message: ${e.message}`;
});
return { return {
valid: false, valid: false,
message: errorMessages.join('\n') ?? '未知错误', message: errorMessages.join('\n') ?? '未知错误',
}; };
} }
return { return { valid: true };
valid: true,
};
} }
public async handle(payload: PayloadType, adaptername: string): Promise<OB11Return<ReturnDataType | null>> { public async handle(payload: PayloadType, adaptername: string): Promise<OB11Return<ReturnDataType | null>> {
@ -46,8 +65,8 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
const resData = await this._handle(payload, adaptername); const resData = await this._handle(payload, adaptername);
return OB11Response.ok(resData); return OB11Response.ok(resData);
} catch (e: any) { } catch (e: any) {
this.core.context.logger.logError.bind(this.core.context.logger)('发生错误', e); this.core.context.logger.logError('发生错误', e);
return OB11Response.error(e?.stack?.toString() || e?.toString() || '未知错误,可能操作超时', 200); return OB11Response.error(e?.toString() || e?.stack?.toString() || '未知错误,可能操作超时', 200);
} }
} }
@ -60,12 +79,10 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
const resData = await this._handle(payload, adaptername); const resData = await this._handle(payload, adaptername);
return OB11Response.ok(resData, echo); return OB11Response.ok(resData, echo);
} catch (e: any) { } catch (e: any) {
this.core.context.logger.logError.bind(this.core.context.logger)('发生错误', e); this.core.context.logger.logError('发生错误', e);
return OB11Response.error(e.stack?.toString() || e.toString(), 1200, echo); return OB11Response.error(e.toString() || e.stack?.toString(), 1200, echo);
} }
} }
abstract _handle(payload: PayloadType, adaptername: string): PromiseLike<ReturnDataType>; abstract _handle(payload: PayloadType, adaptername: string): PromiseLike<ReturnDataType>;
} }
export default BaseAction;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -13,7 +13,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class CreateCollection extends BaseAction<Payload, any> { export class CreateCollection extends OneBotAction<Payload, any> {
actionName = ActionName.CreateCollection; actionName = ActionName.CreateCollection;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,5 +1,5 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
const SchemaData = { const SchemaData = {
@ -11,7 +11,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class FetchCustomFace extends BaseAction<Payload, string[]> { export class FetchCustomFace extends OneBotAction<Payload, string[]> {
actionName = ActionName.FetchCustomFace; actionName = ActionName.FetchCustomFace;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,6 +1,6 @@
//getMsgEmojiLikesList //getMsgEmojiLikesList
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { MessageUnique } from '@/common/message-unique'; import { MessageUnique } from '@/common/message-unique';
@ -19,7 +19,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class FetchEmojiLike extends BaseAction<Payload, any> { export class FetchEmojiLike extends OneBotAction<Payload, any> {
actionName = ActionName.FetchEmojiLike; actionName = ActionName.FetchEmojiLike;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,7 +1,7 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
export class FetchUserProfileLike extends BaseAction<{ qq: number }, any> { export class FetchUserProfileLike extends OneBotAction<{ qq: number }, any> {
actionName = ActionName.FetchUserProfileLike; actionName = ActionName.FetchUserProfileLike;
async _handle(payload: { qq: number }) { async _handle(payload: { qq: number }) {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -13,7 +13,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetCollectionList extends BaseAction<Payload, any> { export class GetCollectionList extends OneBotAction<Payload, any> {
actionName = ActionName.GetCollectionList; actionName = ActionName.GetCollectionList;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,8 +1,8 @@
import { OB11Entities } from '@/onebot/entities'; import { OB11Entities } from '@/onebot/entities';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
export class GetFriendWithCategory extends BaseAction<void, any> { export class GetFriendWithCategory extends OneBotAction<void, any> {
actionName = ActionName.GetFriendsWithCategory; actionName = ActionName.GetFriendsWithCategory;
async _handle(payload: void) { async _handle(payload: void) {

View File

@ -1,5 +1,5 @@
import { GroupNotifyMsgStatus } from '@/core'; import { GroupNotifyMsgStatus } from '@/core';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
interface OB11GroupRequestNotify { interface OB11GroupRequestNotify {
@ -8,7 +8,7 @@ interface OB11GroupRequestNotify {
flag: string flag: string
} }
export default class GetGroupAddRequest extends BaseAction<null, OB11GroupRequestNotify[] | null> { export default class GetGroupAddRequest extends OneBotAction<null, OB11GroupRequestNotify[] | null> {
actionName = ActionName.GetGroupIgnoreAddRequest; actionName = ActionName.GetGroupIgnoreAddRequest;
async _handle(payload: null): Promise<OB11GroupRequestNotify[] | null> { async _handle(payload: null): Promise<OB11GroupRequestNotify[] | null> {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -12,7 +12,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetGroupInfoEx extends BaseAction<Payload, any> { export class GetGroupInfoEx extends OneBotAction<Payload, any> {
actionName = ActionName.GetGroupInfoEx; actionName = ActionName.GetGroupInfoEx;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
interface Payload { interface Payload {
@ -6,7 +6,7 @@ interface Payload {
count: number count: number
} }
export class GetProfileLike extends BaseAction<Payload, any> { export class GetProfileLike extends OneBotAction<Payload, any> {
actionName = ActionName.GetProfileLike; actionName = ActionName.GetProfileLike;
async _handle(payload: Payload) { async _handle(payload: Payload) {

View File

@ -1,7 +1,7 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
export class GetRobotUinRange extends BaseAction<void, Array<any>> { export class GetRobotUinRange extends OneBotAction<void, Array<any>> {
actionName = ActionName.GetRobotUinRange; actionName = ActionName.GetRobotUinRange;
async _handle(payload: void) { async _handle(payload: void) {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { checkFileReceived, uri2local } from '@/common/file'; import { checkFileReceived, uri2local } from '@/common/file';
@ -14,7 +14,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class OCRImage extends BaseAction<Payload, any> { export class OCRImage extends OneBotAction<Payload, any> {
actionName = ActionName.OCRImage; actionName = ActionName.OCRImage;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,5 +1,5 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { ChatType } from '@/core'; import { ChatType } from '@/core';
@ -14,7 +14,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class SetInputStatus extends BaseAction<Payload, any> { export class SetInputStatus extends OneBotAction<Payload, any> {
actionName = ActionName.SetInputStatus; actionName = ActionName.SetInputStatus;
async _handle(payload: Payload) { async _handle(payload: Payload) {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -12,7 +12,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class SetLongNick extends BaseAction<Payload, any> { export class SetLongNick extends OneBotAction<Payload, any> {
actionName = ActionName.SetLongNick; actionName = ActionName.SetLongNick;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
// 设置在线状态 // 设置在线状态
@ -15,7 +15,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class SetOnlineStatus extends BaseAction<Payload, null> { export class SetOnlineStatus extends OneBotAction<Payload, null> {
actionName = ActionName.SetOnlineStatus; actionName = ActionName.SetOnlineStatus;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName, BaseCheckResult } from '../types'; import { ActionName, BaseCheckResult } from '../types';
import * as fs from 'node:fs'; import * as fs from 'node:fs';
import { checkFileReceived, uri2local } from '@/common/file'; import { checkFileReceived, uri2local } from '@/common/file';
@ -7,7 +7,7 @@ interface Payload {
file: string; file: string;
} }
export default class SetAvatar extends BaseAction<Payload, null> { export default class SetAvatar extends OneBotAction<Payload, null> {
actionName = ActionName.SetQQAvatar; actionName = ActionName.SetQQAvatar;
// 用不着复杂检测 // 用不着复杂检测

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -14,7 +14,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class SharePeer extends BaseAction<Payload, any> { export class SharePeer extends OneBotAction<Payload, any> {
actionName = ActionName.SharePeer; actionName = ActionName.SharePeer;
payloadSchema = SchemaData; payloadSchema = SchemaData;
@ -37,7 +37,7 @@ const SchemaDataGroupEx = {
type PayloadGroupEx = FromSchema<typeof SchemaDataGroupEx>; type PayloadGroupEx = FromSchema<typeof SchemaDataGroupEx>;
export class ShareGroupEx extends BaseAction<PayloadGroupEx, any> { export class ShareGroupEx extends OneBotAction<PayloadGroupEx, any> {
actionName = ActionName.ShareGroupEx; actionName = ActionName.ShareGroupEx;
payloadSchema = SchemaDataGroupEx; payloadSchema = SchemaDataGroupEx;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -15,7 +15,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class TranslateEnWordToZn extends BaseAction<Payload, Array<any> | null> { export class TranslateEnWordToZn extends OneBotAction<Payload, Array<any> | null> {
actionName = ActionName.TranslateEnWordToZn; actionName = ActionName.TranslateEnWordToZn;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import fs from 'fs/promises'; import fs from 'fs/promises';
import { FileNapCatOneBotUUID } from '@/common/helper'; import { FileNapCatOneBotUUID } from '@/common/helper';
import { ActionName } from '../types'; import { ActionName } from '../types';
@ -30,7 +30,7 @@ const GetFileBase_PayloadSchema = {
export type GetFilePayload = FromSchema<typeof GetFileBase_PayloadSchema>; export type GetFilePayload = FromSchema<typeof GetFileBase_PayloadSchema>;
export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> { export class GetFileBase extends OneBotAction<GetFilePayload, GetFileResponse> {
payloadSchema = GetFileBase_PayloadSchema; payloadSchema = GetFileBase_PayloadSchema;
async _handle(payload: GetFilePayload): Promise<GetFileResponse> { async _handle(payload: GetFilePayload): Promise<GetFileResponse> {

View File

@ -1,5 +1,5 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
const SchemaData = { const SchemaData = {
@ -13,7 +13,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class CreateGroupFileFolder extends BaseAction<Payload, any> { export class CreateGroupFileFolder extends OneBotAction<Payload, any> {
actionName = ActionName.GoCQHTTP_CreateGroupFileFolder; actionName = ActionName.GoCQHTTP_CreateGroupFileFolder;
payloadSchema = SchemaData; payloadSchema = SchemaData;
async _handle(payload: Payload) { async _handle(payload: Payload) {

View File

@ -1,5 +1,5 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FileNapCatOneBotUUID } from '@/common/helper'; import { FileNapCatOneBotUUID } from '@/common/helper';
@ -14,7 +14,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class DeleteGroupFile extends BaseAction<Payload, any> { export class DeleteGroupFile extends OneBotAction<Payload, any> {
actionName = ActionName.GOCQHTTP_DeleteGroupFile; actionName = ActionName.GOCQHTTP_DeleteGroupFile;
payloadSchema = SchemaData; payloadSchema = SchemaData;
async _handle(payload: Payload) { async _handle(payload: Payload) {

View File

@ -1,6 +1,6 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { ActionName } from '../types'; import { ActionName } from '../types';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
const SchemaData = { const SchemaData = {
type: 'object', type: 'object',
@ -14,7 +14,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class DeleteGroupFileFolder extends BaseAction<Payload, any> { export class DeleteGroupFileFolder extends OneBotAction<Payload, any> {
actionName = ActionName.GoCQHTTP_DeleteGroupFileFolder; actionName = ActionName.GoCQHTTP_DeleteGroupFileFolder;
payloadSchema = SchemaData; payloadSchema = SchemaData;
async _handle(payload: Payload) { async _handle(payload: Payload) {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import fs from 'fs'; import fs from 'fs';
import { join as joinPath } from 'node:path'; import { join as joinPath } from 'node:path';
@ -28,7 +28,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class GoCQHTTPDownloadFile extends BaseAction<Payload, FileResponse> { export default class GoCQHTTPDownloadFile extends OneBotAction<Payload, FileResponse> {
actionName = ActionName.GoCQHTTP_DownloadFile; actionName = ActionName.GoCQHTTP_DownloadFile;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { OB11Message, OB11MessageData, OB11MessageDataType, OB11MessageForward, OB11MessageNodePlain as OB11MessageNode } from '@/onebot'; import { OB11Message, OB11MessageData, OB11MessageDataType, OB11MessageForward, OB11MessageNodePlain as OB11MessageNode } from '@/onebot';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -16,7 +16,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GoCQHTTPGetForwardMsgAction extends BaseAction<Payload, any> { export class GoCQHTTPGetForwardMsgAction extends OneBotAction<Payload, any> {
actionName = ActionName.GoCQHTTP_GetForwardMsg; actionName = ActionName.GoCQHTTP_GetForwardMsg;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { OB11Message } from '@/onebot'; import { OB11Message } from '@/onebot';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { ChatType } from '@/core/entities'; import { ChatType } from '@/core/entities';
@ -23,7 +23,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class GetFriendMsgHistory extends BaseAction<Payload, Response> { export default class GetFriendMsgHistory extends OneBotAction<Payload, Response> {
actionName = ActionName.GetFriendMsgHistory; actionName = ActionName.GetFriendMsgHistory;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -11,7 +11,7 @@ const SchemaData = {
} as const satisfies JSONSchema; } as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GoCQHTTPGetGroupAtAllRemain extends BaseAction<Payload, any> { export class GoCQHTTPGetGroupAtAllRemain extends OneBotAction<Payload, any> {
actionName = ActionName.GoCQHTTP_GetGroupAtAllRemain; actionName = ActionName.GoCQHTTP_GetGroupAtAllRemain;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,5 +1,5 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
const SchemaData = { const SchemaData = {
@ -12,7 +12,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetGroupFileSystemInfo extends BaseAction<Payload, { export class GetGroupFileSystemInfo extends OneBotAction<Payload, {
file_count: number, file_count: number,
limit_count: number, // unimplemented limit_count: number, // unimplemented
used_space: number, // TODO:unimplemented, but can be implemented later used_space: number, // TODO:unimplemented, but can be implemented later

View File

@ -1,5 +1,5 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { OB11Entities } from '@/onebot/entities'; import { OB11Entities } from '@/onebot/entities';
@ -16,7 +16,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetGroupFilesByFolder extends BaseAction<any, any> { export class GetGroupFilesByFolder extends OneBotAction<any, any> {
actionName = ActionName.GoCQHTTP_GetGroupFilesByFolder; actionName = ActionName.GoCQHTTP_GetGroupFilesByFolder;
payloadSchema = SchemaData; payloadSchema = SchemaData;
async _handle(payload: Payload) { async _handle(payload: Payload) {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { WebHonorType } from '@/core/entities'; import { WebHonorType } from '@/core/entities';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -14,7 +14,7 @@ const SchemaData = {
// enum是不是有点抽象 // enum是不是有点抽象
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetGroupHonorInfo extends BaseAction<Payload, Array<any>> { export class GetGroupHonorInfo extends OneBotAction<Payload, Array<any>> {
actionName = ActionName.GetGroupHonorInfo; actionName = ActionName.GetGroupHonorInfo;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { OB11Message } from '@/onebot'; import { OB11Message } from '@/onebot';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { ChatType, Peer } from '@/core/entities'; import { ChatType, Peer } from '@/core/entities';
@ -23,7 +23,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Response> { export default class GoCQHTTPGetGroupMsgHistory extends OneBotAction<Payload, Response> {
actionName = ActionName.GoCQHTTP_GetGroupMsgHistory; actionName = ActionName.GoCQHTTP_GetGroupMsgHistory;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,5 +1,5 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot'; import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot';
import { OB11Entities } from '@/onebot/entities'; import { OB11Entities } from '@/onebot/entities';
@ -15,7 +15,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetGroupRootFiles extends BaseAction<Payload, { export class GetGroupRootFiles extends OneBotAction<Payload, {
files: OB11GroupFile[], files: OB11GroupFile[],
folders: OB11GroupFileFolder[], folders: OB11GroupFileFolder[],
}> { }> {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { JSONSchema } from 'json-schema-to-ts'; import { JSONSchema } from 'json-schema-to-ts';
import { sleep } from '@/common/helper'; import { sleep } from '@/common/helper';
@ -10,7 +10,7 @@ const SchemaData = {
}, },
} as const satisfies JSONSchema; } as const satisfies JSONSchema;
export class GetOnlineClient extends BaseAction<void, Array<any>> { export class GetOnlineClient extends OneBotAction<void, Array<any>> {
actionName = ActionName.GetOnlineClient; actionName = ActionName.GetOnlineClient;
async _handle(payload: void) { async _handle(payload: void) {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { OB11User, OB11UserSex } from '@/onebot'; import { OB11User, OB11UserSex } from '@/onebot';
import { OB11Entities } from '@/onebot/entities'; import { OB11Entities } from '@/onebot/entities';
import { ActionName } from '../types'; import { ActionName } from '../types';
@ -15,7 +15,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11User> { export default class GoCQHTTPGetStrangerInfo extends OneBotAction<Payload, OB11User> {
actionName = ActionName.GoCQHTTP_GetStrangerInfo; actionName = ActionName.GoCQHTTP_GetStrangerInfo;
async _handle(payload: Payload): Promise<OB11User> { async _handle(payload: Payload): Promise<OB11User> {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -11,7 +11,7 @@ const SchemaData = {
} as const satisfies JSONSchema; } as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GoCQHTTPCheckUrlSafely extends BaseAction<Payload, any> { export class GoCQHTTPCheckUrlSafely extends OneBotAction<Payload, any> {
actionName = ActionName.GoCQHTTP_CheckUrlSafely; actionName = ActionName.GoCQHTTP_CheckUrlSafely;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -18,7 +18,7 @@ const SchemaData = {
} as const satisfies JSONSchema; } as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GoCQHTTPDeleteFriend extends BaseAction<Payload, any> { export class GoCQHTTPDeleteFriend extends OneBotAction<Payload, any> {
actionName = ActionName.GoCQHTTP_DeleteFriend; actionName = ActionName.GoCQHTTP_DeleteFriend;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -10,7 +10,7 @@ const SchemaData = {
} as const satisfies JSONSchema; } as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GoCQHTTPGetModelShow extends BaseAction<Payload, any> { export class GoCQHTTPGetModelShow extends OneBotAction<Payload, any> {
actionName = ActionName.GoCQHTTP_GetModelShow; actionName = ActionName.GoCQHTTP_GetModelShow;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -9,7 +9,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
//兼容性代码 //兼容性代码
export class GoCQHTTPSetModelShow extends BaseAction<Payload, any> { export class GoCQHTTPSetModelShow extends OneBotAction<Payload, any> {
actionName = ActionName.GoCQHTTP_SetModelShow; actionName = ActionName.GoCQHTTP_SetModelShow;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { QuickAction, QuickActionEvent } from '@/onebot/types'; import { QuickAction, QuickActionEvent } from '@/onebot/types';
@ -7,7 +7,7 @@ interface Payload {
operation: QuickAction operation: QuickAction
} }
export class GoCQHTTPHandleQuickAction extends BaseAction<Payload, null> { export class GoCQHTTPHandleQuickAction extends OneBotAction<Payload, null> {
actionName = ActionName.GoCQHTTP_HandleQuickAction; actionName = ActionName.GoCQHTTP_HandleQuickAction;
async _handle(payload: Payload): Promise<null> { async _handle(payload: Payload): Promise<null> {

View File

@ -1,5 +1,5 @@
import { checkFileReceived, uri2local } from '@/common/file'; import { checkFileReceived, uri2local } from '@/common/file';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { unlink } from 'node:fs'; import { unlink } from 'node:fs';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -21,7 +21,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class SendGroupNotice extends BaseAction<Payload, null> { export class SendGroupNotice extends OneBotAction<Payload, null> {
actionName = ActionName.GoCQHTTP_SendGroupNotice; actionName = ActionName.GoCQHTTP_SendGroupNotice;
async _handle(payload: Payload) { async _handle(payload: Payload) {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName, BaseCheckResult } from '../types'; import { ActionName, BaseCheckResult } from '../types';
import * as fs from 'node:fs'; import * as fs from 'node:fs';
import { checkFileReceived, uri2local } from '@/common/file'; import { checkFileReceived, uri2local } from '@/common/file';
@ -8,7 +8,7 @@ interface Payload {
group_id: number group_id: number
} }
export default class SetGroupPortrait extends BaseAction<Payload, any> { export default class SetGroupPortrait extends OneBotAction<Payload, any> {
actionName = ActionName.SetGroupPortrait; actionName = ActionName.SetGroupPortrait;
// 用不着复杂检测 // 用不着复杂检测

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -14,7 +14,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class SetQQProfile extends BaseAction<Payload, any> { export class SetQQProfile extends OneBotAction<Payload, any> {
actionName = ActionName.SetQQProfile; actionName = ActionName.SetQQProfile;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { ChatType, Peer } from '@/core/entities'; import { ChatType, Peer } from '@/core/entities';
import fs from 'fs'; import fs from 'fs';
@ -20,7 +20,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class GoCQHTTPUploadGroupFile extends BaseAction<Payload, null> { export default class GoCQHTTPUploadGroupFile extends OneBotAction<Payload, null> {
actionName = ActionName.GoCQHTTP_UploadGroupFile; actionName = ActionName.GoCQHTTP_UploadGroupFile;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { ChatType, Peer, SendFileElement } from '@/core/entities'; import { ChatType, Peer, SendFileElement } from '@/core/entities';
import fs from 'fs'; import fs from 'fs';
@ -19,7 +19,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class GoCQHTTPUploadPrivateFile extends BaseAction<Payload, null> { export default class GoCQHTTPUploadPrivateFile extends OneBotAction<Payload, null> {
actionName = ActionName.GOCQHTTP_UploadPrivateFile; actionName = ActionName.GOCQHTTP_UploadPrivateFile;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { MessageUnique } from '@/common/message-unique'; import { MessageUnique } from '@/common/message-unique';
@ -13,7 +13,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class DelEssenceMsg extends BaseAction<Payload, any> { export default class DelEssenceMsg extends OneBotAction<Payload, any> {
actionName = ActionName.DelEssenceMsg; actionName = ActionName.DelEssenceMsg;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -14,7 +14,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class DelGroupNotice extends BaseAction<Payload, any> { export class DelGroupNotice extends OneBotAction<Payload, any> {
actionName = ActionName.DelGroupNotice; actionName = ActionName.DelGroupNotice;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,5 +1,5 @@
import { ChatType, Peer } from '@/core'; import { ChatType, Peer } from '@/core';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { MessageUnique } from '@/common/message-unique'; import { MessageUnique } from '@/common/message-unique';
@ -16,7 +16,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetGroupEssence extends BaseAction<Payload, any> { export class GetGroupEssence extends OneBotAction<Payload, any> {
actionName = ActionName.GoCQHTTP_GetEssenceMsg; actionName = ActionName.GoCQHTTP_GetEssenceMsg;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,5 +1,5 @@
import { GroupNotifyMsgStatus } from '@/core'; import { GroupNotifyMsgStatus } from '@/core';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -12,7 +12,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetGroupIgnoredNotifies extends BaseAction<void, any> { export class GetGroupIgnoredNotifies extends OneBotAction<void, any> {
actionName = ActionName.GetGroupIgnoredNotifies; actionName = ActionName.GetGroupIgnoredNotifies;
async _handle(payload: void) { async _handle(payload: void) {

View File

@ -1,6 +1,6 @@
import { OB11Group } from '@/onebot'; import { OB11Group } from '@/onebot';
import { OB11Entities } from '@/onebot/entities'; import { OB11Entities } from '@/onebot/entities';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -14,7 +14,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
class GetGroupInfo extends BaseAction<Payload, OB11Group> { class GetGroupInfo extends OneBotAction<Payload, OB11Group> {
actionName = ActionName.GetGroupInfo; actionName = ActionName.GetGroupInfo;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,6 +1,6 @@
import { OB11Group } from '@/onebot'; import { OB11Group } from '@/onebot';
import { OB11Entities } from '@/onebot/entities'; import { OB11Entities } from '@/onebot/entities';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
// no_cache get时传字符串 // no_cache get时传字符串
@ -13,7 +13,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
class GetGroupList extends BaseAction<Payload, OB11Group[]> { class GetGroupList extends OneBotAction<Payload, OB11Group[]> {
actionName = ActionName.GetGroupList; actionName = ActionName.GetGroupList;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,6 +1,6 @@
import { OB11GroupMember } from '@/onebot'; import { OB11GroupMember } from '@/onebot';
import { OB11Entities } from '@/onebot/entities'; import { OB11Entities } from '@/onebot/entities';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -16,7 +16,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> { class GetGroupMemberInfo extends OneBotAction<Payload, OB11GroupMember> {
actionName = ActionName.GetGroupMemberInfo; actionName = ActionName.GetGroupMemberInfo;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,6 +1,6 @@
import { OB11GroupMember } from '@/onebot'; import { OB11GroupMember } from '@/onebot';
import { OB11Entities } from '@/onebot/entities'; import { OB11Entities } from '@/onebot/entities';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -15,7 +15,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> { export class GetGroupMemberList extends OneBotAction<Payload, OB11GroupMember[]> {
actionName = ActionName.GetGroupMemberList; actionName = ActionName.GetGroupMemberList;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,5 +1,5 @@
import { WebApiGroupNoticeFeed } from '@/core'; import { WebApiGroupNoticeFeed } from '@/core';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -29,7 +29,7 @@ type Payload = FromSchema<typeof SchemaData>;
type ApiGroupNotice = GroupNotice & WebApiGroupNoticeFeed; type ApiGroupNotice = GroupNotice & WebApiGroupNoticeFeed;
export class GetGroupNotice extends BaseAction<Payload, GroupNotice[]> { export class GetGroupNotice extends OneBotAction<Payload, GroupNotice[]> {
actionName = ActionName.GoCQHTTP_GetGroupNotice; actionName = ActionName.GoCQHTTP_GetGroupNotice;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -12,7 +12,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetGroupShutList extends BaseAction<Payload, any> { export class GetGroupShutList extends OneBotAction<Payload, any> {
actionName = ActionName.GetGroupShutList; actionName = ActionName.GetGroupShutList;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { MessageUnique } from '@/common/message-unique'; import { MessageUnique } from '@/common/message-unique';
@ -13,7 +13,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class SetEssenceMsg extends BaseAction<Payload, any> { export default class SetEssenceMsg extends OneBotAction<Payload, any> {
actionName = ActionName.SetEssenceMsg; actionName = ActionName.SetEssenceMsg;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { GroupRequestOperateTypes } from '@/core/entities'; import { GroupRequestOperateTypes } from '@/core/entities';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -15,7 +15,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class SetGroupAddRequest extends BaseAction<Payload, null> { export default class SetGroupAddRequest extends OneBotAction<Payload, null> {
actionName = ActionName.SetGroupAddRequest; actionName = ActionName.SetGroupAddRequest;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { GroupMemberRole } from '@/core/entities'; import { GroupMemberRole } from '@/core/entities';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -15,7 +15,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class SetGroupAdmin extends BaseAction<Payload, null> { export default class SetGroupAdmin extends OneBotAction<Payload, null> {
actionName = ActionName.SetGroupAdmin; actionName = ActionName.SetGroupAdmin;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -14,7 +14,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class SetGroupBan extends BaseAction<Payload, null> { export default class SetGroupBan extends OneBotAction<Payload, null> {
actionName = ActionName.SetGroupBan; actionName = ActionName.SetGroupBan;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -14,7 +14,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class SetGroupCard extends BaseAction<Payload, null> { export default class SetGroupCard extends OneBotAction<Payload, null> {
actionName = ActionName.SetGroupCard; actionName = ActionName.SetGroupCard;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -15,7 +15,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class SetGroupKick extends BaseAction<Payload, null> { export default class SetGroupKick extends OneBotAction<Payload, null> {
actionName = ActionName.SetGroupKick; actionName = ActionName.SetGroupKick;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -12,7 +12,7 @@ const SchemaData = {
} as const satisfies JSONSchema; } as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class SetGroupLeave extends BaseAction<Payload, any> { export default class SetGroupLeave extends OneBotAction<Payload, any> {
actionName = ActionName.SetGroupLeave; actionName = ActionName.SetGroupLeave;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,5 +1,5 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
const SchemaData = { const SchemaData = {
@ -12,7 +12,7 @@ const SchemaData = {
} as const satisfies JSONSchema; } as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class SetGroupName extends BaseAction<Payload, null> { export default class SetGroupName extends OneBotAction<Payload, null> {
actionName = ActionName.SetGroupName; actionName = ActionName.SetGroupName;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,5 +1,5 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
const SchemaData = { const SchemaData = {
@ -13,7 +13,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class SetGroupWholeBan extends BaseAction<Payload, null> { export default class SetGroupWholeBan extends OneBotAction<Payload, null> {
actionName = ActionName.SetGroupWholeBan; actionName = ActionName.SetGroupWholeBan;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,7 +1,7 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
export default class GetGuildList extends BaseAction<null, null> { export default class GetGuildList extends OneBotAction<null, null> {
actionName = ActionName.GetGuildList; actionName = ActionName.GetGuildList;
async _handle(payload: null): Promise<null> { async _handle(payload: null): Promise<null> {

View File

@ -1,7 +1,7 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
export default class GetGuildProfile extends BaseAction<null, null> { export default class GetGuildProfile extends OneBotAction<null, null> {
actionName = ActionName.GetGuildProfile; actionName = ActionName.GetGuildProfile;
async _handle(payload: null): Promise<null> { async _handle(payload: null): Promise<null> {

View File

@ -8,7 +8,7 @@ import SendGroupMsg from './group/SendGroupMsg';
import SendPrivateMsg from './msg/SendPrivateMsg'; import SendPrivateMsg from './msg/SendPrivateMsg';
import SendMsg from './msg/SendMsg'; import SendMsg from './msg/SendMsg';
import DeleteMsg from './msg/DeleteMsg'; import DeleteMsg from './msg/DeleteMsg';
import BaseAction from './BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import GetVersionInfo from './system/GetVersionInfo'; import GetVersionInfo from './system/GetVersionInfo';
import CanSendRecord from './system/CanSendRecord'; import CanSendRecord from './system/CanSendRecord';
import CanSendImage from './system/CanSendImage'; import CanSendImage from './system/CanSendImage';
@ -104,7 +104,7 @@ import { SendGroupAiRecord } from "@/onebot/action/group/SendGroupAiRecord";
import { GetAiCharacters } from "@/onebot/action/extends/GetAiCharacters"; import { GetAiCharacters } from "@/onebot/action/extends/GetAiCharacters";
export type ActionMap = Map<string, BaseAction<any, any>>; export type ActionMap = Map<string, OneBotAction<any, any>>;
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore): ActionMap { export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore): ActionMap {

View File

@ -1,5 +1,5 @@
import { ActionName } from '../types'; import { ActionName } from '../types';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { MessageUnique } from '@/common/message-unique'; import { MessageUnique } from '@/common/message-unique';
@ -18,7 +18,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
class DeleteMsg extends BaseAction<Payload, void> { class DeleteMsg extends OneBotAction<Payload, void> {
actionName = ActionName.DeleteMsg; actionName = ActionName.DeleteMsg;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ChatType, Peer } from '@/core/entities'; import { ChatType, Peer } from '@/core/entities';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -16,7 +16,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
class ForwardSingleMsg extends BaseAction<Payload, null> { class ForwardSingleMsg extends OneBotAction<Payload, null> {
protected async getTargetPeer(payload: Payload): Promise<Peer> { protected async getTargetPeer(payload: Payload): Promise<Peer> {
if (payload.user_id) { if (payload.user_id) {
const peerUid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString()); const peerUid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());

View File

@ -1,5 +1,5 @@
import { OB11Message } from '@/onebot'; import { OB11Message } from '@/onebot';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { MessageUnique } from '@/common/message-unique'; import { MessageUnique } from '@/common/message-unique';
@ -19,7 +19,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
class GetMsg extends BaseAction<Payload, OB11Message> { class GetMsg extends OneBotAction<Payload, OB11Message> {
actionName = ActionName.GetMsg; actionName = ActionName.GetMsg;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,6 +1,6 @@
import { ChatType, Peer } from '@/core/entities'; import { ChatType, Peer } from '@/core/entities';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { MessageUnique } from '@/common/message-unique'; import { MessageUnique } from '@/common/message-unique';
@ -15,7 +15,7 @@ const SchemaData = {
type PlayloadType = FromSchema<typeof SchemaData>; type PlayloadType = FromSchema<typeof SchemaData>;
class MarkMsgAsRead extends BaseAction<PlayloadType, null> { class MarkMsgAsRead extends OneBotAction<PlayloadType, null> {
async getPeer(payload: PlayloadType): Promise<Peer> { async getPeer(payload: PlayloadType): Promise<Peer> {
if (payload.message_id) { if (payload.message_id) {
const s_peer = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id)?.Peer; const s_peer = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id)?.Peer;
@ -65,7 +65,7 @@ export class GoCQHTTPMarkMsgAsRead extends MarkMsgAsRead {
actionName = ActionName.GoCQHTTP_MarkMsgAsRead; actionName = ActionName.GoCQHTTP_MarkMsgAsRead;
} }
export class MarkAllMsgAsRead extends BaseAction<any, null> { export class MarkAllMsgAsRead extends OneBotAction<any, null> {
actionName = ActionName._MarkAllMsgAsRead; actionName = ActionName._MarkAllMsgAsRead;
async _handle(): Promise<null> { async _handle(): Promise<null> {

View File

@ -10,7 +10,7 @@ import { ActionName, BaseCheckResult } from '@/onebot/action/types';
import { decodeCQCode } from '@/onebot/cqcode'; import { decodeCQCode } from '@/onebot/cqcode';
import { MessageUnique } from '@/common/message-unique'; import { MessageUnique } from '@/common/message-unique';
import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendArkElement, SendMessageElement } from '@/core'; import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendArkElement, SendMessageElement } from '@/core';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ForwardMsgBuilder } from "@/common/forward-msg-builder"; import { ForwardMsgBuilder } from "@/common/forward-msg-builder";
import { stringifyWithBigInt } from "@/common/helper"; import { stringifyWithBigInt } from "@/common/helper";
import { PacketMsg } from "@/core/packet/message/message"; import { PacketMsg } from "@/core/packet/message/message";
@ -88,7 +88,7 @@ function getSpecialMsgNum(payload: OB11PostSendMsg, msgType: OB11MessageDataType
return 0; return 0;
} }
export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> { export class SendMsg extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
actionName = ActionName.SendMsg; actionName = ActionName.SendMsg;
contextMode = ContextMode.Normal; contextMode = ContextMode.Normal;

View File

@ -1,5 +1,5 @@
import { ActionName } from '../types'; import { ActionName } from '../types';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { MessageUnique } from '@/common/message-unique'; import { MessageUnique } from '@/common/message-unique';
@ -15,7 +15,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class SetMsgEmojiLike extends BaseAction<Payload, any> { export class SetMsgEmojiLike extends OneBotAction<Payload, any> {
actionName = ActionName.SetMsgEmojiLike; actionName = ActionName.SetMsgEmojiLike;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,8 +1,8 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName, BaseCheckResult } from '../types'; import { ActionName, BaseCheckResult } from '../types';
export abstract class GetPacketStatusDepends<PT, RT> extends BaseAction<PT, RT> { export abstract class GetPacketStatusDepends<PT, RT> extends OneBotAction<PT, RT> {
actionName = ActionName.GetPacketStatus; actionName = ActionName.GetPacketStatus;
protected async check(payload: PT): Promise<BaseCheckResult>{ protected async check(payload: PT): Promise<BaseCheckResult>{

View File

@ -1,11 +1,11 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
interface ReturnType { interface ReturnType {
yes: boolean; yes: boolean;
} }
export default class CanSendRecord extends BaseAction<any, ReturnType> { export default class CanSendRecord extends OneBotAction<any, ReturnType> {
actionName = ActionName.CanSendRecord; actionName = ActionName.CanSendRecord;
async _handle(_payload: void): Promise<ReturnType> { async _handle(_payload: void): Promise<ReturnType> {

View File

@ -1,7 +1,7 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
export class GetCSRF extends BaseAction<any, any> { export class GetCSRF extends OneBotAction<any, any> {
actionName = ActionName.GetCSRF; actionName = ActionName.GetCSRF;
async _handle(payload: any) { async _handle(payload: any) {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -17,7 +17,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetCredentials extends BaseAction<Payload, Response> { export class GetCredentials extends OneBotAction<Payload, Response> {
actionName = ActionName.GetCredentials; actionName = ActionName.GetCredentials;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,9 +1,9 @@
import { OB11User } from '@/onebot'; import { OB11User } from '@/onebot';
import { OB11Entities } from '@/onebot/entities'; import { OB11Entities } from '@/onebot/entities';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
class GetLoginInfo extends BaseAction<null, OB11User> { class GetLoginInfo extends OneBotAction<null, OB11User> {
actionName = ActionName.GetLoginInfo; actionName = ActionName.GetLoginInfo;
async _handle(payload: null) { async _handle(payload: null) {

View File

@ -1,7 +1,7 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
export default class GetStatus extends BaseAction<any, any> { export default class GetStatus extends OneBotAction<any, any> {
actionName = ActionName.GetStatus; actionName = ActionName.GetStatus;
async _handle(payload: any): Promise<any> { async _handle(payload: any): Promise<any> {

View File

@ -1,5 +1,5 @@
import { GroupNotifyMsgStatus } from '@/core'; import { GroupNotifyMsgStatus } from '@/core';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -12,7 +12,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetGroupSystemMsg extends BaseAction<void, any> { export class GetGroupSystemMsg extends OneBotAction<void, any> {
actionName = ActionName.GetGroupSystemMsg; actionName = ActionName.GetGroupSystemMsg;
async _handle(payload: void) { async _handle(payload: void) {

View File

@ -1,9 +1,9 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { napCatVersion } from '@/common/version'; import { napCatVersion } from '@/common/version';
export default class GetVersionInfo extends BaseAction<any, any> { export default class GetVersionInfo extends OneBotAction<any, any> {
actionName = ActionName.GetVersionInfo; actionName = ActionName.GetVersionInfo;
async _handle(payload: any): Promise<any> { async _handle(payload: any): Promise<any> {

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -17,7 +17,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetCookies extends BaseAction<Payload, Response> { export class GetCookies extends OneBotAction<Payload, Response> {
actionName = ActionName.GetCookies; actionName = ActionName.GetCookies;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,6 +1,6 @@
import { OB11User } from '@/onebot'; import { OB11User } from '@/onebot';
import { OB11Entities } from '@/onebot/entities'; import { OB11Entities } from '@/onebot/entities';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -13,7 +13,7 @@ const SchemaData = {
} as const satisfies JSONSchema; } as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class GetFriendList extends BaseAction<Payload, OB11User[]> { export default class GetFriendList extends OneBotAction<Payload, OB11User[]> {
actionName = ActionName.GetFriendList; actionName = ActionName.GetFriendList;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,5 +1,5 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { AdapterConfigWrap } from '@/onebot/config/config'; import { AdapterConfigWrap } from '@/onebot/config/config';
@ -12,7 +12,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class GetRecentContact extends BaseAction<Payload, any> { export default class GetRecentContact extends OneBotAction<Payload, any> {
actionName = ActionName.GetRecentContact; actionName = ActionName.GetRecentContact;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,4 +1,4 @@
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -13,7 +13,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class SendLike extends BaseAction<Payload, null> { export default class SendLike extends OneBotAction<Payload, null> {
actionName = ActionName.SendLike; actionName = ActionName.SendLike;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -1,5 +1,5 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
const SchemaData = { const SchemaData = {
@ -14,7 +14,7 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export default class SetFriendAddRequest extends BaseAction<Payload, null> { export default class SetFriendAddRequest extends OneBotAction<Payload, null> {
actionName = ActionName.SetFriendAddRequest; actionName = ActionName.SetFriendAddRequest;
payloadSchema = SchemaData; payloadSchema = SchemaData;

View File

@ -20,7 +20,7 @@ import {
import faceConfig from '@/core/external/face_config.json'; import faceConfig from '@/core/external/face_config.json';
import { NapCatOneBot11Adapter, OB11Message, OB11MessageData, OB11MessageDataType, OB11MessageFileBase, } from '@/onebot'; import { NapCatOneBot11Adapter, OB11Message, OB11MessageData, OB11MessageDataType, OB11MessageFileBase, } from '@/onebot';
import { OB11Entities } from '@/onebot/entities'; import { OB11Entities } from '@/onebot/entities';
import { EventType } from '@/onebot/event/OB11BaseEvent'; import { EventType } from '@/onebot/event/OneBotEvent';
import { encodeCQCode } from '@/onebot/cqcode'; import { encodeCQCode } from '@/onebot/cqcode';
import { uri2local } from '@/common/file'; import { uri2local } from '@/common/file';
import { RequestUtil } from '@/common/request'; import { RequestUtil } from '@/common/request';

View File

@ -8,7 +8,7 @@ export enum EventType {
MESSAGE_SENT = 'message_sent', MESSAGE_SENT = 'message_sent',
} }
export abstract class OB11BaseEvent { export abstract class OneBotEvent {
time = Math.floor(Date.now() / 1000); time = Math.floor(Date.now() / 1000);
self_id: number; self_id: number;
abstract post_type: EventType; abstract post_type: EventType;

View File

@ -1,5 +1,5 @@
import { EventType, OB11BaseEvent } from '../OB11BaseEvent'; import { EventType, OneBotEvent } from '../OneBotEvent';
export abstract class OB11BaseMessageEvent extends OB11BaseEvent { export abstract class OB11BaseMessageEvent extends OneBotEvent {
post_type = EventType.MESSAGE; post_type = EventType.MESSAGE;
} }

View File

@ -1,6 +1,6 @@
import { EventType, OB11BaseEvent } from '../OB11BaseEvent'; import { EventType, OneBotEvent } from '@/onebot/event/OneBotEvent';
export abstract class OB11BaseMetaEvent extends OB11BaseEvent { export abstract class OB11BaseMetaEvent extends OneBotEvent {
post_type = EventType.META; post_type = EventType.META;
abstract meta_event_type: string; abstract meta_event_type: string;
} }

View File

@ -1,5 +1,5 @@
import { EventType, OB11BaseEvent } from '../OB11BaseEvent'; import { EventType, OneBotEvent } from '@/onebot/event/OneBotEvent';
export abstract class OB11BaseNoticeEvent extends OB11BaseEvent { export abstract class OB11BaseNoticeEvent extends OneBotEvent {
post_type = EventType.NOTICE; post_type = EventType.NOTICE;
} }

View File

@ -1,5 +1,5 @@
import { OB11BaseNoticeEvent } from '../notice/OB11BaseNoticeEvent'; import { OB11BaseNoticeEvent } from '../notice/OB11BaseNoticeEvent';
import { EventType } from '../OB11BaseEvent'; import { EventType } from '../OneBotEvent';
import { NapCatCore } from '@/core'; import { NapCatCore } from '@/core';
export class OB11FriendRequestEvent extends OB11BaseNoticeEvent { export class OB11FriendRequestEvent extends OB11BaseNoticeEvent {

View File

@ -1,5 +1,5 @@
import { OB11GroupNoticeEvent } from '../notice/OB11GroupNoticeEvent'; import { OB11GroupNoticeEvent } from '../notice/OB11GroupNoticeEvent';
import { EventType } from '../OB11BaseEvent'; import { EventType } from '../OneBotEvent';
import { NapCatCore } from '@/core'; import { NapCatCore } from '@/core';
export class OB11GroupRequestEvent extends OB11GroupNoticeEvent { export class OB11GroupRequestEvent extends OB11GroupNoticeEvent {

View File

@ -577,15 +577,16 @@ export class NapCatOneBot11Adapter {
private createMsgMap(network: Array<AdapterConfigWrap>, ob11Msg: any, isSelfMsg: boolean, message: RawMessage): Map<string, OB11Message> { private createMsgMap(network: Array<AdapterConfigWrap>, ob11Msg: any, isSelfMsg: boolean, message: RawMessage): Map<string, OB11Message> {
const msgMap: Map<string, OB11Message> = new Map(); const msgMap: Map<string, OB11Message> = new Map();
network.filter(e => e.enable).forEach(e => { network.filter(e => e.enable).forEach(e => {
if (isSelfMsg) {
ob11Msg.stringMsg.target_id = parseInt(message.peerUin);
ob11Msg.arrayMsg.target_id = parseInt(message.peerUin);
}
if (e.messagePostFormat == 'string') { if (e.messagePostFormat == 'string') {
msgMap.set(e.name, structuredClone(ob11Msg.stringMsg)); msgMap.set(e.name, structuredClone(ob11Msg.stringMsg));
} else { } else {
msgMap.set(e.name, structuredClone(ob11Msg.arrayMsg)); msgMap.set(e.name, structuredClone(ob11Msg.arrayMsg));
} }
if (isSelfMsg) {
ob11Msg.stringMsg.target_id = parseInt(message.peerUin);
ob11Msg.arrayMsg.target_id = parseInt(message.peerUin);
}
}); });
return msgMap; return msgMap;
} }

View File

@ -3,7 +3,7 @@ import { WebSocket } from 'ws';
import { OB11HeartbeatEvent } from '../event/meta/OB11HeartbeatEvent'; import { OB11HeartbeatEvent } from '../event/meta/OB11HeartbeatEvent';
import { NapCatCore } from '@/core'; import { NapCatCore } from '@/core';
import { ActionName } from '@/onebot/action/types'; import { ActionName } from '@/onebot/action/types';
import { OB11Response } from '@/onebot/action/OB11Response'; import { OB11Response } from '@/onebot/action/OneBotAction';
import { LogWrapper } from '@/common/log'; import { LogWrapper } from '@/common/log';
import { ActionMap } from '@/onebot/action'; import { ActionMap } from '@/onebot/action';
import { LifeCycleSubType, OB11LifeCycleEvent } from '../event/meta/OB11LifeCycleEvent'; import { LifeCycleSubType, OB11LifeCycleEvent } from '../event/meta/OB11LifeCycleEvent';

View File

@ -1,9 +1,9 @@
import { OB11BaseEvent } from '@/onebot/event/OB11BaseEvent'; import { OneBotEvent } from '@/onebot/event/OneBotEvent';
import { OB11Message } from '@/onebot'; import { OB11Message } from '@/onebot';
import { ActionMap } from '@/onebot/action'; import { ActionMap } from '@/onebot/action';
import { NetworkConfigAdapter } from '../config/config'; import { NetworkConfigAdapter } from '../config/config';
export type OB11EmitEventContent = OB11BaseEvent | OB11Message; export type OB11EmitEventContent = OneBotEvent | OB11Message;
export enum OB11NetworkReloadType { export enum OB11NetworkReloadType {
Normal = 0, Normal = 0,
ConfigChange = 1, ConfigChange = 1,
@ -16,7 +16,7 @@ export interface IOB11NetworkAdapter {
name: string; name: string;
isEnable: boolean; isEnable: boolean;
config: NetworkConfigAdapter; config: NetworkConfigAdapter;
onEvent<T extends OB11EmitEventContent>(event: T): void; onEvent<T extends OB11EmitEventContent>(event: T): void;
open(): void | Promise<void>; open(): void | Promise<void>;

View File

@ -2,7 +2,7 @@ import { IOB11NetworkAdapter, OB11NetworkReloadType } from './index';
import express, { Express, Request, Response } from 'express'; import express, { Express, Request, Response } from 'express';
import http from 'http'; import http from 'http';
import { NapCatCore } from '@/core'; import { NapCatCore } from '@/core';
import { OB11Response } from '../action/OB11Response'; import { OB11Response } from '@/onebot/action/OneBotAction';
import { ActionMap } from '@/onebot/action'; import { ActionMap } from '@/onebot/action';
import cors from 'cors'; import cors from 'cors';
import { HttpServerConfig } from '../config/config'; import { HttpServerConfig } from '../config/config';

View File

@ -2,7 +2,7 @@ import { IOB11NetworkAdapter, OB11EmitEventContent, OB11NetworkReloadType } from
import urlParse from 'url'; import urlParse from 'url';
import { WebSocket, WebSocketServer } from 'ws'; import { WebSocket, WebSocketServer } from 'ws';
import { Mutex } from 'async-mutex'; import { Mutex } from 'async-mutex';
import { OB11Response } from '../action/OB11Response'; import { OB11Response } from '@/onebot/action/OneBotAction';
import { ActionName } from '../action/types'; import { ActionName } from '../action/types';
import { NapCatCore } from '@/core'; import { NapCatCore } from '@/core';
import { LogWrapper } from '@/common/log'; import { LogWrapper } from '@/common/log';

Some files were not shown because too many files have changed in this diff Show More