mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
refactor: type-check (#586)
* refactor: type-check * fix: default * refactor: type-check
This commit is contained in:
@@ -43,13 +43,13 @@
|
|||||||
"file-type": "^19.0.0",
|
"file-type": "^19.0.0",
|
||||||
"globals": "^15.12.0",
|
"globals": "^15.12.0",
|
||||||
"image-size": "^1.1.1",
|
"image-size": "^1.1.1",
|
||||||
"json-schema-to-ts": "^3.1.1",
|
|
||||||
"typescript": "^5.3.3",
|
"typescript": "^5.3.3",
|
||||||
"typescript-eslint": "^8.13.0",
|
"typescript-eslint": "^8.13.0",
|
||||||
"vite": "^6.0.1",
|
"vite": "^6.0.1",
|
||||||
"vite-plugin-cp": "^4.0.8",
|
"vite-plugin-cp": "^4.0.8",
|
||||||
"vite-tsconfig-paths": "^5.1.0",
|
"vite-tsconfig-paths": "^5.1.0",
|
||||||
"winston": "^3.17.0"
|
"winston": "^3.17.0",
|
||||||
|
"@sinclair/typebox": "^0.34.9"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^5.0.0",
|
"express": "^5.0.0",
|
||||||
|
@@ -42,7 +42,7 @@ export abstract class OneBotAction<PayloadType, ReturnDataType> {
|
|||||||
|
|
||||||
protected async check(payload: PayloadType): Promise<BaseCheckResult> {
|
protected async check(payload: PayloadType): Promise<BaseCheckResult> {
|
||||||
if (this.payloadSchema) {
|
if (this.payloadSchema) {
|
||||||
this.validate = new Ajv({ allowUnionTypes: true }).compile(this.payloadSchema);
|
this.validate = new Ajv({ allowUnionTypes: true, useDefaults: true }).compile(this.payloadSchema);
|
||||||
}
|
}
|
||||||
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[];
|
||||||
|
@@ -1,17 +1,13 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
rawData: Type.String(),
|
||||||
properties: {
|
brief: Type.String(),
|
||||||
rawData: { type: 'string' },
|
});
|
||||||
brief: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['brief', 'rawData'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class CreateCollection extends OneBotAction<Payload, any> {
|
export class CreateCollection extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.CreateCollection;
|
actionName = ActionName.CreateCollection;
|
||||||
|
@@ -1,23 +1,19 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
count: Type.Union([Type.Number(), Type.String()], { default: 48 }),
|
||||||
properties: {
|
});
|
||||||
count: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class FetchCustomFace extends OneBotAction<Payload, string[]> {
|
export class FetchCustomFace extends OneBotAction<Payload, string[]> {
|
||||||
actionName = ActionName.FetchCustomFace;
|
actionName = ActionName.FetchCustomFace;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
//48 可能正好是QQ需要的一个页面的数量 Tagged Mlikiowa
|
const ret = await this.core.apis.MsgApi.fetchFavEmojiList(+payload.count);
|
||||||
const ret = await this.core.apis.MsgApi.fetchFavEmojiList(+(payload.count ?? 48));
|
|
||||||
return ret.emojiInfoList.map(e => e.url);
|
return ret.emojiInfoList.map(e => e.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,32 +1,27 @@
|
|||||||
//getMsgEmojiLikesList
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
emojiId: Type.Union([Type.Number(), Type.String()]),
|
||||||
user_id: { type: 'string' },
|
emojiType: Type.Union([Type.Number(), Type.String()]),
|
||||||
group_id: { type: 'string' },
|
count: Type.Union([Type.Number(), Type.String()], { default: 20 }),
|
||||||
emojiId: { type: 'string' },
|
});
|
||||||
emojiType: { type: 'string' },
|
|
||||||
message_id: { type: ['string', 'number'] },
|
|
||||||
count: { type: ['string', 'number'] },
|
|
||||||
},
|
|
||||||
required: ['emojiId', 'emojiType', 'message_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class FetchEmojiLike extends OneBotAction<Payload, any> {
|
export class FetchEmojiLike extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.FetchEmojiLike;
|
actionName = ActionName.FetchEmojiLike;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString()));
|
const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||||
if (!msgIdPeer) throw new Error('消息不存在');
|
if (!msgIdPeer) throw new Error('消息不存在');
|
||||||
const msg = (await this.core.apis.MsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0];
|
const msg = (await this.core.apis.MsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0];
|
||||||
return await this.core.apis.MsgApi.getMsgEmojiLikesList(msgIdPeer.Peer, msg.msgSeq, payload.emojiId, payload.emojiType, +(payload.count ?? 20));
|
return await this.core.apis.MsgApi.getMsgEmojiLikesList(
|
||||||
|
msgIdPeer.Peer, msg.msgSeq, payload.emojiId.toString(), payload.emojiType.toString(), +payload.count
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,17 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
|
|
||||||
export class FetchUserProfileLike extends OneBotAction<{ qq: number }, any> {
|
const SchemaData = Type.Object({
|
||||||
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
|
export class FetchUserProfileLike extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.FetchUserProfileLike;
|
actionName = ActionName.FetchUserProfileLike;
|
||||||
|
|
||||||
async _handle(payload: { qq: number }) {
|
async _handle(payload: Payload) {
|
||||||
if (!payload.qq) throw new Error('qq is required');
|
return await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||||
return await this.core.apis.UserApi.getUidByUinV2(payload.qq.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
||||||
import { AIVoiceChatType } from "@/core/packet/entities/aiChat";
|
import { AIVoiceChatType } from "@/core/packet/entities/aiChat";
|
||||||
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
chat_type: Type.Union([Type.Union([Type.Number(), Type.String()])], { default: 1 }),
|
||||||
group_id: { type: ['number', 'string'] },
|
});
|
||||||
chat_type: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
interface GetAiCharactersResponse {
|
interface GetAiCharactersResponse {
|
||||||
type: string;
|
type: string;
|
||||||
@@ -28,7 +24,7 @@ export class GetAiCharacters extends GetPacketStatusDepends<Payload, GetAiCharac
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const rawList = await this.core.apis.PacketApi.pkt.operation.FetchAiVoiceList(+payload.group_id, +(payload.chat_type ?? 1) as AIVoiceChatType);
|
const rawList = await this.core.apis.PacketApi.pkt.operation.FetchAiVoiceList(+payload.group_id, +payload.chat_type as AIVoiceChatType);
|
||||||
return rawList?.map((item) => ({
|
return rawList?.map((item) => ({
|
||||||
type: item.category,
|
type: item.category,
|
||||||
characters: item.voices.map((voice) => ({
|
characters: item.voices.map((voice) => ({
|
||||||
|
@@ -1,23 +1,19 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
category: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
count: Type.Union([Type.Union([Type.Number(), Type.String()])], { default: 1 }),
|
||||||
category: { type: ['number', 'string'] },
|
});
|
||||||
count: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['category', 'count'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetCollectionList extends OneBotAction<Payload, any> {
|
export class GetCollectionList extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GetCollectionList;
|
actionName = ActionName.GetCollectionList;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
return await this.core.apis.CollectionApi.getAllCollection(parseInt(payload.category.toString()), +(payload.count ?? 1));
|
return await this.core.apis.CollectionApi.getAllCollection(parseInt(payload.category.toString()), +payload.count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,11 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
|
const SchemaData = Type.Object({
|
||||||
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
});
|
||||||
|
|
||||||
const SchemaData = {
|
type Payload = Static<typeof SchemaData>;
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GetGroupInfoEx extends OneBotAction<Payload, any> {
|
export class GetGroupInfoEx extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GetGroupInfoEx;
|
actionName = ActionName.GetGroupInfoEx;
|
||||||
|
@@ -1,47 +1,29 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
||||||
import { MiniAppInfo, MiniAppInfoHelper } from "@/core/packet/utils/helper/miniAppHelper";
|
import { MiniAppInfo, MiniAppInfoHelper } from "@/core/packet/utils/helper/miniAppHelper";
|
||||||
import { MiniAppData, MiniAppRawData, MiniAppReqCustomParams, MiniAppReqParams } from "@/core/packet/entities/miniApp";
|
import { MiniAppData, MiniAppRawData, MiniAppReqCustomParams, MiniAppReqParams } from "@/core/packet/entities/miniApp";
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
type: Type.Optional(Type.Union([Type.Literal('bili'), Type.Literal('weibo')])),
|
||||||
properties: {
|
title: Type.String(),
|
||||||
type: {
|
desc: Type.String(),
|
||||||
type: 'string',
|
picUrl: Type.String(),
|
||||||
enum: ['bili', 'weibo']
|
jumpUrl: Type.String(),
|
||||||
},
|
iconUrl: Type.Optional(Type.String()),
|
||||||
title: { type: 'string' },
|
sdkId: Type.Optional(Type.String()),
|
||||||
desc: { type: 'string' },
|
appId: Type.Optional(Type.String()),
|
||||||
picUrl: { type: 'string' },
|
scene: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
jumpUrl: { type: 'string' },
|
templateType: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
iconUrl: { type: 'string' },
|
businessType: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
sdkId: { type: 'string' },
|
verType: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
appId: { type: 'string' },
|
shareType: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
scene: { type: ['number', 'string'] },
|
versionId: Type.Optional(Type.String()),
|
||||||
templateType: { type: ['number', 'string'] },
|
withShareTicket: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
businessType: { type: ['number', 'string'] },
|
rawArkData: Type.Optional(Type.Union([Type.Boolean(), Type.String()]))
|
||||||
verType: { type: ['number', 'string'] },
|
});
|
||||||
shareType: { type: ['number', 'string'] },
|
|
||||||
versionId: { type: 'string' },
|
|
||||||
withShareTicket: { type: ['number', 'string'] },
|
|
||||||
rawArkData: { type: ['boolean', 'string'] }
|
|
||||||
},
|
|
||||||
oneOf: [
|
|
||||||
{
|
|
||||||
required: ['type', 'title', 'desc', 'picUrl', 'jumpUrl']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
required: [
|
|
||||||
'title', 'desc', 'picUrl', 'jumpUrl',
|
|
||||||
'iconUrl', 'appId', 'scene', 'templateType', 'businessType',
|
|
||||||
'verType', 'shareType', 'versionId', 'withShareTicket'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetMiniAppArk extends GetPacketStatusDepends<Payload, {
|
export class GetMiniAppArk extends GetPacketStatusDepends<Payload, {
|
||||||
data: MiniAppData | MiniAppRawData
|
data: MiniAppData | MiniAppRawData
|
||||||
@@ -61,6 +43,9 @@ export class GetMiniAppArk extends GetPacketStatusDepends<Payload, {
|
|||||||
reqParam = MiniAppInfoHelper.generateReq(customParams, MiniAppInfo.get(payload.type)!.template);
|
reqParam = MiniAppInfoHelper.generateReq(customParams, MiniAppInfo.get(payload.type)!.template);
|
||||||
} else {
|
} else {
|
||||||
const { appId, scene, iconUrl, templateType, businessType, verType, shareType, versionId, withShareTicket } = payload;
|
const { appId, scene, iconUrl, templateType, businessType, verType, shareType, versionId, withShareTicket } = payload;
|
||||||
|
if (!appId || !scene || !iconUrl || !templateType || !businessType || !verType || !shareType || !versionId || !withShareTicket) {
|
||||||
|
throw new Error('Missing required parameters');
|
||||||
|
}
|
||||||
reqParam = MiniAppInfoHelper.generateReq(
|
reqParam = MiniAppInfoHelper.generateReq(
|
||||||
customParams,
|
customParams,
|
||||||
{
|
{
|
||||||
|
@@ -1,34 +1,28 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
user_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
properties: {
|
start: Type.Union([Type.Number(), Type.String()], { default: 0 }),
|
||||||
user_id: { type: ['number', 'string'] },
|
count: Type.Union([Type.Number(), Type.String()], { default: 10 }),
|
||||||
start: { type: ['number', 'string'] },
|
type: Type.Union([Type.Number(), Type.String()], { default: 2 }),
|
||||||
count: { type: ['number', 'string'] },
|
});
|
||||||
type: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetProfileLike extends OneBotAction<Payload, any> {
|
export class GetProfileLike extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GetProfileLike;
|
actionName = ActionName.GetProfileLike;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const start = payload.start ? Number(payload.start) : 0;
|
|
||||||
const count = payload.count ? Number(payload.count) : 10;
|
|
||||||
const type = payload.count ? Number(payload.count) : 2;
|
|
||||||
const user_uid =
|
const user_uid =
|
||||||
this.core.selfInfo.uin === payload.user_id || !payload.user_id ?
|
this.core.selfInfo.uin === payload.user_id || !payload.user_id ?
|
||||||
this.core.selfInfo.uid :
|
this.core.selfInfo.uid :
|
||||||
await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||||
const ret = await this.core.apis.UserApi.getProfileLike(user_uid ?? this.core.selfInfo.uid, start, count, type);
|
const ret = await this.core.apis.UserApi.getProfileLike(user_uid ?? this.core.selfInfo.uid, +payload.start, +payload.count, +payload.type);
|
||||||
const listdata = ret.info.userLikeInfos[0].voteInfo.userInfos;
|
const listdata = ret.info.userLikeInfos[0].voteInfo.userInfos;
|
||||||
for (const item of listdata) {
|
for (const item of listdata) {
|
||||||
item.uin = parseInt((await this.core.apis.UserApi.getUinByUidV2(item.uid)) || '');
|
item.uin = +((await this.core.apis.UserApi.getUinByUidV2(item.uid)) ?? '');
|
||||||
}
|
}
|
||||||
return ret.info.userLikeInfos[0].voteInfo;
|
return ret.info.userLikeInfos[0].voteInfo;
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
||||||
|
|
||||||
|
export class GetRkey extends GetPacketStatusDepends<void, Array<any>> {
|
||||||
export class GetRkey extends GetPacketStatusDepends<null, Array<any>> {
|
|
||||||
actionName = ActionName.GetRkey;
|
actionName = ActionName.GetRkey;
|
||||||
|
|
||||||
async _handle() {
|
async _handle() {
|
||||||
|
@@ -4,7 +4,7 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
export class GetRobotUinRange extends OneBotAction<void, Array<any>> {
|
export class GetRobotUinRange extends OneBotAction<void, Array<any>> {
|
||||||
actionName = ActionName.GetRobotUinRange;
|
actionName = ActionName.GetRobotUinRange;
|
||||||
|
|
||||||
async _handle(payload: void) {
|
async _handle() {
|
||||||
return await this.core.apis.UserApi.getRobotUinRange();
|
return await this.core.apis.UserApi.getRobotUinRange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
||||||
// no_cache get时传字符串
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
user_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['user_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
const SchemaData = Type.Object({
|
||||||
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetUserStatus extends GetPacketStatusDepends<Payload, { status: number; ext_status: number; } | undefined> {
|
export class GetUserStatus extends GetPacketStatusDepends<Payload, { status: number; ext_status: number; } | undefined> {
|
||||||
actionName = ActionName.GetUserStatus;
|
actionName = ActionName.GetUserStatus;
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { checkFileExist, uri2local } from '@/common/file';
|
import { checkFileExist, uri2local } from '@/common/file';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
image: Type.String(),
|
||||||
properties: {
|
});
|
||||||
image: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['image'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class OCRImage extends OneBotAction<Payload, any> {
|
export class OCRImage extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.OCRImage;
|
actionName = ActionName.OCRImage;
|
||||||
@@ -29,12 +25,12 @@ export class OCRImage extends OneBotAction<Payload, any> {
|
|||||||
fs.unlink(path, () => { });
|
fs.unlink(path, () => { });
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
throw new Error(`OCR ${payload.file}失败`);
|
throw new Error(`OCR ${payload.image}失败`);
|
||||||
}
|
}
|
||||||
return ret.result;
|
return ret.result;
|
||||||
}
|
}
|
||||||
fs.unlink(path, () => { });
|
fs.unlink(path, () => { });
|
||||||
throw new Error(`OCR ${payload.file}失败,文件可能不存在`);
|
throw new Error(`OCR ${payload.image}失败,文件可能不存在`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
});
|
||||||
group_id: { type: ['string', 'number'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class SetGroupSign extends GetPacketStatusDepends<Payload, any> {
|
export class SetGroupSign extends GetPacketStatusDepends<Payload, any> {
|
||||||
actionName = ActionName.SetGroupSign;
|
actionName = ActionName.SetGroupSign;
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { ChatType } from '@/core';
|
import { ChatType } from '@/core';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
event_type: Type.Number(),
|
||||||
event_type: { type: 'number' },
|
});
|
||||||
user_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['event_type', 'user_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class SetInputStatus extends OneBotAction<Payload, any> {
|
export class SetInputStatus extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.SetInputStatus;
|
actionName = ActionName.SetInputStatus;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
longNick: Type.String(),
|
||||||
properties: {
|
});
|
||||||
longNick: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['longNick'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class SetLongNick extends OneBotAction<Payload, any> {
|
export class SetLongNick extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.SetLongNick;
|
actionName = ActionName.SetLongNick;
|
||||||
|
@@ -1,19 +1,14 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
// 设置在线状态
|
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
status: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
ext_status: Type.Union([Type.Number(), Type.String()]),
|
||||||
status: { type: ['number', 'string'] },
|
battery_status: Type.Union([Type.Number(), Type.String()]),
|
||||||
ext_status: { type: ['number', 'string'] },
|
});
|
||||||
battery_status: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['status', 'ext_status', 'battery_status'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class SetOnlineStatus extends OneBotAction<Payload, null> {
|
export class SetOnlineStatus extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.SetOnlineStatus;
|
actionName = ActionName.SetOnlineStatus;
|
||||||
@@ -21,9 +16,9 @@ export class SetOnlineStatus extends OneBotAction<Payload, null> {
|
|||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const ret = await this.core.apis.UserApi.setSelfOnlineStatus(
|
const ret = await this.core.apis.UserApi.setSelfOnlineStatus(
|
||||||
parseInt(payload.status.toString()),
|
+payload.status,
|
||||||
parseInt(payload.ext_status.toString()),
|
+payload.ext_status,
|
||||||
parseInt(payload.battery_status.toString()),
|
+payload.battery_status,
|
||||||
);
|
);
|
||||||
if (ret.result !== 0) {
|
if (ret.result !== 0) {
|
||||||
throw new Error('设置在线状态失败');
|
throw new Error('设置在线状态失败');
|
||||||
|
@@ -1,28 +1,18 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import * as fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
import { checkFileExist, uri2local } from '@/common/file';
|
import { checkFileExist, uri2local } from '@/common/file';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
interface Payload {
|
const SchemaData = Type.Object({
|
||||||
file: string;
|
file: Type.String(),
|
||||||
}
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class SetAvatar extends OneBotAction<Payload, null> {
|
export default class SetAvatar extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.SetQQAvatar;
|
actionName = ActionName.SetQQAvatar;
|
||||||
|
payloadSchema = SchemaData;
|
||||||
// 用不着复杂检测
|
|
||||||
protected async check(payload: Payload): Promise<BaseCheckResult> {
|
|
||||||
if (!payload.file || typeof payload.file != 'string') {
|
|
||||||
return {
|
|
||||||
valid: false,
|
|
||||||
message: 'file字段不能为空或者类型错误',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
valid: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<null> {
|
async _handle(payload: Payload): Promise<null> {
|
||||||
const { path, success } = (await uri2local(this.core.NapCatTempPath, payload.file));
|
const { path, success } = (await uri2local(this.core.NapCatTempPath, payload.file));
|
||||||
if (!success) {
|
if (!success) {
|
||||||
@@ -45,7 +35,6 @@ export default class SetAvatar extends OneBotAction<Payload, null> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fs.unlink(path, () => { });
|
fs.unlink(path, () => { });
|
||||||
|
|
||||||
throw new Error(`头像${payload.file}设置失败,无法获取头像,文件可能不存在`);
|
throw new Error(`头像${payload.file}设置失败,无法获取头像,文件可能不存在`);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@@ -1,17 +1,14 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
||||||
const SchemaData = {
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['number', 'string'] },
|
|
||||||
user_id: { type: ['number', 'string'] },
|
|
||||||
special_title: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'user_id', 'special_title'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
const SchemaData = Type.Object({
|
||||||
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
special_title: Type.String(),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class SetSpecialTittle extends GetPacketStatusDepends<Payload, any> {
|
export class SetSpecialTittle extends GetPacketStatusDepends<Payload, any> {
|
||||||
actionName = ActionName.SetSpecialTittle;
|
actionName = ActionName.SetSpecialTittle;
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
user_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
properties: {
|
group_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
user_id: { type: 'string' },
|
phoneNumber: Type.String({ default: '' }),
|
||||||
group_id: { type: 'string' },
|
});
|
||||||
phoneNumber: { type: 'string' },
|
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class SharePeer extends OneBotAction<Payload, any> {
|
export class SharePeer extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.SharePeer;
|
actionName = ActionName.SharePeer;
|
||||||
@@ -20,28 +16,24 @@ export class SharePeer extends OneBotAction<Payload, any> {
|
|||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
if (payload.group_id) {
|
if (payload.group_id) {
|
||||||
return await this.core.apis.GroupApi.getGroupRecommendContactArkJson(payload.group_id);
|
return await this.core.apis.GroupApi.getGroupRecommendContactArkJson(payload.group_id.toString());
|
||||||
} else if (payload.user_id) {
|
} else if (payload.user_id) {
|
||||||
return await this.core.apis.UserApi.getBuddyRecommendContactArkJson(payload.user_id, payload.phoneNumber || '');
|
return await this.core.apis.UserApi.getBuddyRecommendContactArkJson(payload.user_id.toString(), payload.phoneNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SchemaDataGroupEx = {
|
const SchemaDataGroupEx = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
});
|
||||||
group_id: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type PayloadGroupEx = FromSchema<typeof SchemaDataGroupEx>;
|
type PayloadGroupEx = Static<typeof SchemaDataGroupEx>;
|
||||||
|
|
||||||
export class ShareGroupEx extends OneBotAction<PayloadGroupEx, any> {
|
export class ShareGroupEx extends OneBotAction<PayloadGroupEx, any> {
|
||||||
actionName = ActionName.ShareGroupEx;
|
actionName = ActionName.ShareGroupEx;
|
||||||
payloadSchema = SchemaDataGroupEx;
|
payloadSchema = SchemaDataGroupEx;
|
||||||
|
|
||||||
async _handle(payload: PayloadGroupEx) {
|
async _handle(payload: PayloadGroupEx) {
|
||||||
return await this.core.apis.GroupApi.getArkJsonGroupShare(payload.group_id);
|
return await this.core.apis.GroupApi.getArkJsonGroupShare(payload.group_id.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,19 +1,12 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
words: Type.Array(Type.String()),
|
||||||
properties: {
|
});
|
||||||
words: {
|
|
||||||
type: 'array',
|
|
||||||
items: { type: 'string' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: ['words'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class TranslateEnWordToZn extends OneBotAction<Payload, Array<any> | null> {
|
export class TranslateEnWordToZn extends OneBotAction<Payload, Array<any> | null> {
|
||||||
actionName = ActionName.TranslateEnWordToZn;
|
actionName = ActionName.TranslateEnWordToZn;
|
||||||
|
@@ -2,12 +2,8 @@ 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 '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OB11MessageImage, OB11MessageVideo } from '@/onebot/types';
|
import { OB11MessageImage, OB11MessageVideo } from '@/onebot/types';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
// interface GetFilePayload {
|
|
||||||
// file: string; // 文件名或者fileUuid
|
|
||||||
// }
|
|
||||||
|
|
||||||
export interface GetFileResponse {
|
export interface GetFileResponse {
|
||||||
file?: string; // path
|
file?: string; // path
|
||||||
@@ -16,19 +12,14 @@ export interface GetFileResponse {
|
|||||||
file_name?: string;
|
file_name?: string;
|
||||||
base64?: string;
|
base64?: string;
|
||||||
}
|
}
|
||||||
const GetFileBase_PayloadSchema = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
file: { type: 'string' },
|
|
||||||
file_id: { type: 'string' }
|
|
||||||
},
|
|
||||||
oneOf: [
|
|
||||||
{ required: ['file'] },
|
|
||||||
{ required: ['file_id'] }
|
|
||||||
]
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
export type GetFilePayload = FromSchema<typeof GetFileBase_PayloadSchema>;
|
const GetFileBase_PayloadSchema = Type.Object({
|
||||||
|
file: Type.Optional(Type.String()),
|
||||||
|
file_id: Type.Optional(Type.String())
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
export type GetFilePayload = Static<typeof GetFileBase_PayloadSchema>;
|
||||||
|
|
||||||
export class GetFileBase extends OneBotAction<GetFilePayload, GetFileResponse> {
|
export class GetFileBase extends OneBotAction<GetFilePayload, GetFileResponse> {
|
||||||
payloadSchema = GetFileBase_PayloadSchema;
|
payloadSchema = GetFileBase_PayloadSchema;
|
||||||
@@ -50,12 +41,12 @@ export class GetFileBase extends OneBotAction<GetFilePayload, GetFileResponse> {
|
|||||||
let url = '';
|
let url = '';
|
||||||
if (mixElement?.picElement && rawMessage) {
|
if (mixElement?.picElement && rawMessage) {
|
||||||
const tempData =
|
const tempData =
|
||||||
await this.obContext.apis.MsgApi.rawToOb11Converters.picElement?.(mixElement?.picElement, rawMessage, mixElement) as OB11MessageImage | undefined;
|
await this.obContext.apis.MsgApi.rawToOb11Converters.picElement?.(mixElement?.picElement, rawMessage, mixElement, { parseMultMsg: false }) as OB11MessageImage | undefined;
|
||||||
url = tempData?.data.url ?? '';
|
url = tempData?.data.url ?? '';
|
||||||
}
|
}
|
||||||
if (mixElement?.videoElement && rawMessage) {
|
if (mixElement?.videoElement && rawMessage) {
|
||||||
const tempData =
|
const tempData =
|
||||||
await this.obContext.apis.MsgApi.rawToOb11Converters.videoElement?.(mixElement?.videoElement, rawMessage, mixElement) as OB11MessageVideo | undefined;
|
await this.obContext.apis.MsgApi.rawToOb11Converters.videoElement?.(mixElement?.videoElement, rawMessage, mixElement, { parseMultMsg: false }) as OB11MessageVideo | undefined;
|
||||||
url = tempData?.data.url ?? '';
|
url = tempData?.data.url ?? '';
|
||||||
}
|
}
|
||||||
const res: GetFileResponse = {
|
const res: GetFileResponse = {
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { FileNapCatOneBotUUID } from "@/common/helper";
|
import { FileNapCatOneBotUUID } from "@/common/helper";
|
||||||
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
file_id: Type.String(),
|
||||||
group_id: { type: ['number', 'string'] },
|
});
|
||||||
file_id: { type: ['string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'file_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
interface GetGroupFileUrlResponse {
|
interface GetGroupFileUrlResponse {
|
||||||
url?: string;
|
url?: string;
|
||||||
|
@@ -1,17 +1,13 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
folder_name: Type.String(),
|
||||||
group_id: { type: ['string', 'number'] },
|
});
|
||||||
folder_name: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'folder_name'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class CreateGroupFileFolder extends OneBotAction<Payload, any> {
|
export class CreateGroupFileFolder extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_CreateGroupFileFolder;
|
actionName = ActionName.GoCQHTTP_CreateGroupFileFolder;
|
||||||
|
@@ -1,18 +1,15 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
file_id: Type.String(),
|
||||||
group_id: { type: ['string', 'number'] },
|
});
|
||||||
file_id: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'file_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class DeleteGroupFile extends OneBotAction<Payload, any> {
|
export class DeleteGroupFile extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GOCQHTTP_DeleteGroupFile;
|
actionName = ActionName.GOCQHTTP_DeleteGroupFile;
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
folder_id: Type.Optional(Type.String()),
|
||||||
group_id: { type: ['string', 'number'] },
|
folder: Type.Optional(Type.String()),
|
||||||
folder_id: { type: 'string' },
|
});
|
||||||
folder: { type: 'string' }
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class DeleteGroupFileFolder extends OneBotAction<Payload, any> {
|
export class DeleteGroupFileFolder extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_DeleteGroupFileFolder;
|
actionName = ActionName.GoCQHTTP_DeleteGroupFileFolder;
|
||||||
|
@@ -4,29 +4,20 @@ import fs from 'fs';
|
|||||||
import { join as joinPath } from 'node:path';
|
import { join as joinPath } from 'node:path';
|
||||||
import { calculateFileMD5, httpDownload } from '@/common/file';
|
import { calculateFileMD5, httpDownload } from '@/common/file';
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
interface FileResponse {
|
interface FileResponse {
|
||||||
file: string;
|
file: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
url: Type.Optional(Type.String()),
|
||||||
properties: {
|
base64: Type.Optional(Type.String()),
|
||||||
thread_count: { type: ['number', 'string'] },
|
name: Type.Optional(Type.String()),
|
||||||
url: { type: 'string' },
|
headers: Type.Optional(Type.Union([Type.String(), Type.Array(Type.String())])),
|
||||||
base64: { type: 'string' },
|
});
|
||||||
name: { type: 'string' },
|
|
||||||
headers: {
|
|
||||||
type: ['string', 'array'],
|
|
||||||
items: {
|
|
||||||
type: 'string',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class GoCQHTTPDownloadFile extends OneBotAction<Payload, FileResponse> {
|
export default class GoCQHTTPDownloadFile extends OneBotAction<Payload, FileResponse> {
|
||||||
actionName = ActionName.GoCQHTTP_DownloadFile;
|
actionName = ActionName.GoCQHTTP_DownloadFile;
|
||||||
|
@@ -1,20 +1,15 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
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 '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
|
const SchemaData = Type.Object({
|
||||||
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
message_id: { type: 'string' },
|
|
||||||
id: { type: 'string' },
|
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GoCQHTTPGetForwardMsgAction extends OneBotAction<Payload, any> {
|
export class GoCQHTTPGetForwardMsgAction extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_GetForwardMsg;
|
actionName = ActionName.GoCQHTTP_GetForwardMsg;
|
||||||
@@ -60,7 +55,7 @@ export class GoCQHTTPGetForwardMsgAction extends OneBotAction<Payload, any> {
|
|||||||
throw new Error('message_id is required');
|
throw new Error('message_id is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootMsgId = MessageUnique.getShortIdByMsgId(msgId);
|
const rootMsgId = MessageUnique.getShortIdByMsgId(msgId.toString());
|
||||||
const rootMsg = MessageUnique.getMsgIdAndPeerByShortId(rootMsgId ?? +msgId);
|
const rootMsg = MessageUnique.getMsgIdAndPeerByShortId(rootMsgId ?? +msgId);
|
||||||
if (!rootMsg) {
|
if (!rootMsg) {
|
||||||
throw new Error('msg not found');
|
throw new Error('msg not found');
|
||||||
|
@@ -2,26 +2,22 @@ import { OneBotAction } from '@/onebot/action/OneBotAction';
|
|||||||
import { OB11Message } from '@/onebot';
|
import { OB11Message } from '@/onebot';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { ChatType } from '@/core/types';
|
import { ChatType } from '@/core/types';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
import { AdapterConfigWrap } from '@/onebot/config/config';
|
import { AdapterConfigWrap } from '@/onebot/config/config';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
messages: OB11Message[];
|
messages: OB11Message[];
|
||||||
}
|
}
|
||||||
|
const SchemaData = Type.Object({
|
||||||
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
message_seq: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
|
count: Type.Union([Type.Number(), Type.String()], { default: 20 }),
|
||||||
|
reverseOrder: Type.Optional(Type.Union([Type.Boolean(), Type.String()]))
|
||||||
|
});
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
user_id: { type: ['number', 'string'] },
|
|
||||||
message_seq: { type: ['number', 'string'] },
|
|
||||||
count: { type: ['number', 'string'] },
|
|
||||||
reverseOrder: { type: ['boolean', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['user_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class GetFriendMsgHistory extends OneBotAction<Payload, Response> {
|
export default class GetFriendMsgHistory extends OneBotAction<Payload, Response> {
|
||||||
actionName = ActionName.GetFriendMsgHistory;
|
actionName = ActionName.GetFriendMsgHistory;
|
||||||
@@ -30,7 +26,7 @@ export default class GetFriendMsgHistory extends OneBotAction<Payload, Response>
|
|||||||
async _handle(payload: Payload, adapter: string): Promise<Response> {
|
async _handle(payload: Payload, adapter: string): Promise<Response> {
|
||||||
//处理参数
|
//处理参数
|
||||||
const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||||
const MsgCount = +(payload.count ?? 20);
|
|
||||||
const isReverseOrder = typeof payload.reverseOrder === 'string' ? payload.reverseOrder === 'true' : !!payload.reverseOrder;
|
const isReverseOrder = typeof payload.reverseOrder === 'string' ? payload.reverseOrder === 'true' : !!payload.reverseOrder;
|
||||||
if (!uid) throw new Error(`记录${payload.user_id}不存在`);
|
if (!uid) throw new Error(`记录${payload.user_id}不存在`);
|
||||||
const friend = await this.core.apis.FriendApi.isBuddy(uid);
|
const friend = await this.core.apis.FriendApi.isBuddy(uid);
|
||||||
@@ -38,7 +34,7 @@ export default class GetFriendMsgHistory extends OneBotAction<Payload, Response>
|
|||||||
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
||||||
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
||||||
const msgList = hasMessageSeq ?
|
const msgList = hasMessageSeq ?
|
||||||
(await this.core.apis.MsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList : (await this.core.apis.MsgApi.getAioFirstViewLatestMsgs(peer, MsgCount)).msgList;
|
(await this.core.apis.MsgApi.getMsgHistory(peer, startMsgId, +payload.count)).msgList : (await this.core.apis.MsgApi.getAioFirstViewLatestMsgs(peer, +payload.count)).msgList;
|
||||||
if (msgList.length === 0) throw new Error(`消息${payload.message_seq}不存在`);
|
if (msgList.length === 0) throw new Error(`消息${payload.message_seq}不存在`);
|
||||||
//翻转消息
|
//翻转消息
|
||||||
if (isReverseOrder) msgList.reverse();
|
if (isReverseOrder) msgList.reverse();
|
||||||
|
@@ -1,15 +1,12 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()])
|
||||||
properties: {
|
});
|
||||||
group_id: { type: ['number', 'string'] }
|
|
||||||
},
|
type Payload = Static<typeof SchemaData>;
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GoCQHTTPGetGroupAtAllRemain extends OneBotAction<Payload, any> {
|
export class GoCQHTTPGetGroupAtAllRemain extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_GetGroupAtAllRemain;
|
actionName = ActionName.GoCQHTTP_GetGroupAtAllRemain;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()])
|
||||||
properties: {
|
});
|
||||||
group_id: { type: ['string', 'number'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetGroupFileSystemInfo extends OneBotAction<Payload, {
|
export class GetGroupFileSystemInfo extends OneBotAction<Payload, {
|
||||||
file_count: number,
|
file_count: number,
|
||||||
|
@@ -1,20 +1,17 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { OB11Construct } from '@/onebot/helper/data';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
folder_id: Type.Optional(Type.String()),
|
||||||
group_id: { type: ['string', 'number'] },
|
folder: Type.Optional(Type.String()),
|
||||||
folder_id: { type: 'string' },
|
file_count: Type.Union([Type.Number(), Type.String()], { default: 50 }),
|
||||||
folder: { type: 'string' },
|
});
|
||||||
file_count: { type: ['string', 'number'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetGroupFilesByFolder extends OneBotAction<any, any> {
|
export class GetGroupFilesByFolder extends OneBotAction<any, any> {
|
||||||
actionName = ActionName.GoCQHTTP_GetGroupFilesByFolder;
|
actionName = ActionName.GoCQHTTP_GetGroupFilesByFolder;
|
||||||
@@ -23,7 +20,7 @@ export class GetGroupFilesByFolder extends OneBotAction<any, any> {
|
|||||||
|
|
||||||
const ret = await this.core.apis.MsgApi.getGroupFileList(payload.group_id.toString(), {
|
const ret = await this.core.apis.MsgApi.getGroupFileList(payload.group_id.toString(), {
|
||||||
sortType: 1,
|
sortType: 1,
|
||||||
fileCount: +(payload.file_count ?? 50),
|
fileCount: +payload.file_count,
|
||||||
startIndex: 0,
|
startIndex: 0,
|
||||||
sortOrder: 2,
|
sortOrder: 2,
|
||||||
showOnlinedocFolder: 0,
|
showOnlinedocFolder: 0,
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { WebHonorType } from '@/core/types';
|
import { WebHonorType } from '@/core/types';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
type: Type.Optional(Type.Enum(WebHonorType))
|
||||||
group_id: { type: ['number', 'string'] },
|
});
|
||||||
type: { enum: [WebHonorType.ALL, WebHonorType.EMOTION, WebHonorType.LEGEND, WebHonorType.PERFORMER, WebHonorType.STRONG_NEWBIE, WebHonorType.TALKATIVE] },
|
|
||||||
},
|
type Payload = Static<typeof SchemaData>;
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
// enum是不是有点抽象
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GetGroupHonorInfo extends OneBotAction<Payload, Array<any>> {
|
export class GetGroupHonorInfo extends OneBotAction<Payload, Array<any>> {
|
||||||
actionName = ActionName.GetGroupHonorInfo;
|
actionName = ActionName.GetGroupHonorInfo;
|
||||||
|
@@ -2,26 +2,24 @@ import { OneBotAction } from '@/onebot/action/OneBotAction';
|
|||||||
import { OB11Message } from '@/onebot';
|
import { OB11Message } from '@/onebot';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { ChatType, Peer } from '@/core/types';
|
import { ChatType, Peer } from '@/core/types';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
import { AdapterConfigWrap } from '@/onebot/config/config';
|
import { AdapterConfigWrap } from '@/onebot/config/config';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
messages: OB11Message[];
|
messages: OB11Message[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
message_seq: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
group_id: { type: ['number', 'string'] },
|
count: Type.Union([Type.Number(), Type.String()], { default: 20 }),
|
||||||
message_seq: { type: ['number', 'string'] },
|
reverseOrder: Type.Optional(Type.Union([Type.Boolean(), Type.String()]))
|
||||||
count: { type: ['number', 'string'] },
|
});
|
||||||
reverseOrder: { type: ['boolean', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
type Payload = Static<typeof SchemaData>;
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export default class GoCQHTTPGetGroupMsgHistory extends OneBotAction<Payload, Response> {
|
export default class GoCQHTTPGetGroupMsgHistory extends OneBotAction<Payload, Response> {
|
||||||
actionName = ActionName.GoCQHTTP_GetGroupMsgHistory;
|
actionName = ActionName.GoCQHTTP_GetGroupMsgHistory;
|
||||||
@@ -30,13 +28,12 @@ export default class GoCQHTTPGetGroupMsgHistory extends OneBotAction<Payload, Re
|
|||||||
async _handle(payload: Payload, adapter: string): Promise<Response> {
|
async _handle(payload: Payload, adapter: string): Promise<Response> {
|
||||||
//处理参数
|
//处理参数
|
||||||
const isReverseOrder = typeof payload.reverseOrder === 'string' ? payload.reverseOrder === 'true' : !!payload.reverseOrder;
|
const isReverseOrder = typeof payload.reverseOrder === 'string' ? payload.reverseOrder === 'true' : !!payload.reverseOrder;
|
||||||
const MsgCount = +(payload.count ?? 20);
|
|
||||||
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
||||||
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
||||||
//拉取消息
|
//拉取消息
|
||||||
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
||||||
const msgList = hasMessageSeq ?
|
const msgList = hasMessageSeq ?
|
||||||
(await this.core.apis.MsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList : (await this.core.apis.MsgApi.getAioFirstViewLatestMsgs(peer, MsgCount)).msgList;
|
(await this.core.apis.MsgApi.getMsgHistory(peer, startMsgId, +payload.count)).msgList : (await this.core.apis.MsgApi.getAioFirstViewLatestMsgs(peer, +payload.count)).msgList;
|
||||||
if (msgList.length === 0) throw new Error(`消息${payload.message_seq}不存在`);
|
if (msgList.length === 0) throw new Error(`消息${payload.message_seq}不存在`);
|
||||||
//翻转消息
|
//翻转消息
|
||||||
if (isReverseOrder) msgList.reverse();
|
if (isReverseOrder) msgList.reverse();
|
||||||
|
@@ -1,19 +1,16 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot';
|
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot';
|
||||||
import { OB11Construct } from '@/onebot/helper/data';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
file_count: Type.Union([Type.Number(), Type.String()], { default: 50 }),
|
||||||
group_id: { type: ['string', 'number'] },
|
});
|
||||||
file_count: { type: ['string', 'number'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetGroupRootFiles extends OneBotAction<Payload, {
|
export class GetGroupRootFiles extends OneBotAction<Payload, {
|
||||||
files: OB11GroupFile[],
|
files: OB11GroupFile[],
|
||||||
@@ -24,7 +21,7 @@ export class GetGroupRootFiles extends OneBotAction<Payload, {
|
|||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const ret = await this.core.apis.MsgApi.getGroupFileList(payload.group_id.toString(), {
|
const ret = await this.core.apis.MsgApi.getGroupFileList(payload.group_id.toString(), {
|
||||||
sortType: 1,
|
sortType: 1,
|
||||||
fileCount: +(payload.file_count ?? 50),
|
fileCount: +payload.file_count,
|
||||||
startIndex: 0,
|
startIndex: 0,
|
||||||
sortOrder: 2,
|
sortOrder: 2,
|
||||||
showOnlinedocFolder: 0,
|
showOnlinedocFolder: 0,
|
||||||
|
@@ -1,15 +1,7 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { sleep } from '@/common/helper';
|
import { sleep } from '@/common/helper';
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
no_cache: { type: 'boolean' },
|
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
export class GetOnlineClient extends OneBotAction<void, Array<any>> {
|
export class GetOnlineClient extends OneBotAction<void, Array<any>> {
|
||||||
actionName = ActionName.GetOnlineClient;
|
actionName = ActionName.GetOnlineClient;
|
||||||
|
|
||||||
|
@@ -2,18 +2,14 @@ import { OneBotAction } from '@/onebot/action/OneBotAction';
|
|||||||
import { OB11User, OB11UserSex } from '@/onebot';
|
import { OB11User, OB11UserSex } from '@/onebot';
|
||||||
import { OB11Construct } from '@/onebot/helper/data';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { calcQQLevel } from '@/common/helper';
|
import { calcQQLevel } from '@/common/helper';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
});
|
||||||
user_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['user_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class GoCQHTTPGetStrangerInfo extends OneBotAction<Payload, OB11User> {
|
export default class GoCQHTTPGetStrangerInfo extends OneBotAction<Payload, OB11User> {
|
||||||
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
||||||
|
@@ -1,15 +1,12 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
url: Type.String(),
|
||||||
properties: {
|
});
|
||||||
url: { type: 'string' },
|
|
||||||
},
|
type Payload = Static<typeof SchemaData>;
|
||||||
required: ['url'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GoCQHTTPCheckUrlSafely extends OneBotAction<Payload, any> {
|
export class GoCQHTTPCheckUrlSafely extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_CheckUrlSafely;
|
actionName = ActionName.GoCQHTTP_CheckUrlSafely;
|
||||||
|
@@ -1,22 +1,15 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
friend_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||||
properties: {
|
user_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||||
friend_id: { type: ['string', 'number'] },
|
temp_block: Type.Optional(Type.Boolean()),
|
||||||
user_id: { type: ['string', 'number'] },
|
temp_both_del: Type.Optional(Type.Boolean()),
|
||||||
temp_block: { type: 'boolean' },
|
});
|
||||||
temp_both_del: { type: 'boolean' },
|
|
||||||
},
|
|
||||||
oneOf: [
|
|
||||||
{ required: ['friend_id'] },
|
|
||||||
{ required: ['user_id'] },
|
|
||||||
],
|
|
||||||
|
|
||||||
} as const satisfies JSONSchema;
|
type Payload = Static<typeof SchemaData>;
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GoCQHTTPDeleteFriend extends OneBotAction<Payload, any> {
|
export class GoCQHTTPDeleteFriend extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_DeleteFriend;
|
actionName = ActionName.GoCQHTTP_DeleteFriend;
|
||||||
|
@@ -1,14 +1,12 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
model: Type.String(),
|
||||||
properties: {
|
});
|
||||||
model: { type: 'string' },
|
|
||||||
}
|
type Payload = Static<typeof SchemaData>;
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GoCQHTTPGetModelShow extends OneBotAction<Payload, any> {
|
export class GoCQHTTPGetModelShow extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_GetModelShow;
|
actionName = ActionName.GoCQHTTP_GetModelShow;
|
||||||
|
@@ -1,19 +1,10 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
//兼容性代码
|
//兼容性代码
|
||||||
export class GoCQHTTPSetModelShow extends OneBotAction<Payload, any> {
|
export class GoCQHTTPSetModelShow extends OneBotAction<void, any> {
|
||||||
actionName = ActionName.GoCQHTTP_SetModelShow;
|
actionName = ActionName.GoCQHTTP_SetModelShow;
|
||||||
payloadSchema = SchemaData;
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: void) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,24 +2,20 @@ import { checkFileExist, uri2local } from '@/common/file';
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { unlink } from 'node:fs';
|
import { unlink } from 'node:fs';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
content: Type.String(),
|
||||||
group_id: { type: ['number', 'string'] },
|
image: Type.Optional(Type.String()),
|
||||||
content: { type: 'string' },
|
pinned: Type.Union([Type.Number(), Type.String()], { default: 0 }),
|
||||||
image: { type: 'string' },
|
type: Type.Union([Type.Number(), Type.String()], { default: 1 }),
|
||||||
pinned: { type: ['number', 'string'] },
|
confirm_required: Type.Union([Type.Number(), Type.String()], { default: 1 }),
|
||||||
type: { type: ['number', 'string'] },
|
is_show_edit_card: Type.Union([Type.Number(), Type.String()], { default: 0 }),
|
||||||
confirm_required: { type: ['number', 'string'] },
|
tip_window_type: Type.Union([Type.Number(), Type.String()], { default: 0 })
|
||||||
is_show_edit_card: { type: ['number', 'string'] },
|
});
|
||||||
tip_window_type: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'content'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class SendGroupNotice extends OneBotAction<Payload, null> {
|
export class SendGroupNotice extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
||||||
@@ -50,21 +46,14 @@ export class SendGroupNotice extends OneBotAction<Payload, null> {
|
|||||||
|
|
||||||
UploadImage = ImageUploadResult.picInfo;
|
UploadImage = ImageUploadResult.picInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
const noticeType = +(payload.type ?? 1);
|
|
||||||
const noticePinned = +(payload.pinned ?? 0);
|
|
||||||
|
|
||||||
const noticeShowEditCard = +(payload.is_show_edit_card ?? 0);
|
|
||||||
const noticeTipWindowType = +(payload.tip_window_type ?? 0);
|
|
||||||
const noticeConfirmRequired = +(payload.confirm_required ?? 1);
|
|
||||||
const publishGroupBulletinResult = await this.core.apis.WebApi.setGroupNotice(
|
const publishGroupBulletinResult = await this.core.apis.WebApi.setGroupNotice(
|
||||||
payload.group_id.toString(),
|
payload.group_id.toString(),
|
||||||
payload.content,
|
payload.content,
|
||||||
noticePinned,
|
+payload.pinned,
|
||||||
noticeType,
|
+payload.type,
|
||||||
noticeShowEditCard,
|
+payload.is_show_edit_card,
|
||||||
noticeTipWindowType,
|
+payload.tip_window_type,
|
||||||
noticeConfirmRequired,
|
+payload.confirm_required,
|
||||||
UploadImage?.id,
|
UploadImage?.id,
|
||||||
UploadImage?.width,
|
UploadImage?.width,
|
||||||
UploadImage?.height
|
UploadImage?.height
|
||||||
|
@@ -2,27 +2,18 @@ import { OneBotAction } from '@/onebot/action/OneBotAction';
|
|||||||
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
||||||
import * as fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
import { checkFileExistV2, uri2local } from '@/common/file';
|
import { checkFileExistV2, uri2local } from '@/common/file';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
interface Payload {
|
const SchemaData = Type.Object({
|
||||||
file: string,
|
file: Type.String(),
|
||||||
group_id: number
|
group_id: Type.Union([Type.Number(), Type.String()])
|
||||||
}
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class SetGroupPortrait extends OneBotAction<Payload, any> {
|
export default class SetGroupPortrait extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.SetGroupPortrait;
|
actionName = ActionName.SetGroupPortrait;
|
||||||
|
payloadSchema = SchemaData;
|
||||||
// 用不着复杂检测
|
|
||||||
protected async check(payload: Payload): Promise<BaseCheckResult> {
|
|
||||||
if (!payload.file || typeof payload.file != 'string' || !payload.group_id || typeof payload.group_id != 'number') {
|
|
||||||
return {
|
|
||||||
valid: false,
|
|
||||||
message: 'file和group_id字段不能为空或者类型错误',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
valid: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<any> {
|
async _handle(payload: Payload): Promise<any> {
|
||||||
const { path, success } = (await uri2local(this.core.NapCatTempPath, payload.file));
|
const { path, success } = (await uri2local(this.core.NapCatTempPath, payload.file));
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
nickname: Type.String(),
|
||||||
properties: {
|
personal_note: Type.Optional(Type.String()),
|
||||||
nickname: { type: 'string' },
|
sex: Type.Optional(Type.Union([Type.Number(), Type.String()])), // 传Sex值?建议传0
|
||||||
personal_note: { type: 'string' },
|
});
|
||||||
sex: { type: ['number', 'string'] },//传Sex值?建议传0
|
|
||||||
},
|
|
||||||
required: ['nickname'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class SetQQProfile extends OneBotAction<Payload, any> {
|
export class SetQQProfile extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.SetQQProfile;
|
actionName = ActionName.SetQQProfile;
|
||||||
|
@@ -3,22 +3,18 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { ChatType, Peer } from '@/core/types';
|
import { ChatType, Peer } from '@/core/types';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { uri2local } from '@/common/file';
|
import { uri2local } from '@/common/file';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { SendMessageContext } from '@/onebot/api';
|
||||||
import { MessageContext } from '@/onebot/api';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
file: Type.String(),
|
||||||
group_id: { type: ['number', 'string'] },
|
name: Type.String(),
|
||||||
file: { type: 'string' },
|
folder: Type.Optional(Type.String()),
|
||||||
name: { type: 'string' },
|
folder_id: Type.Optional(Type.String()),//临时扩展
|
||||||
folder: { type: 'string' },
|
});
|
||||||
folder_id: { type: 'string' },//临时扩展
|
|
||||||
},
|
|
||||||
required: ['group_id', 'file', 'name'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class GoCQHTTPUploadGroupFile extends OneBotAction<Payload, null> {
|
export default class GoCQHTTPUploadGroupFile extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.GoCQHTTP_UploadGroupFile;
|
actionName = ActionName.GoCQHTTP_UploadGroupFile;
|
||||||
@@ -37,7 +33,7 @@ export default class GoCQHTTPUploadGroupFile extends OneBotAction<Payload, null>
|
|||||||
if (!downloadResult.success) {
|
if (!downloadResult.success) {
|
||||||
throw new Error(downloadResult.errMsg);
|
throw new Error(downloadResult.errMsg);
|
||||||
}
|
}
|
||||||
const msgContext: MessageContext = {
|
const msgContext: SendMessageContext = {
|
||||||
peer: peer,
|
peer: peer,
|
||||||
deleteAfterSentFiles: []
|
deleteAfterSentFiles: []
|
||||||
};
|
};
|
||||||
|
@@ -3,21 +3,17 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { ChatType, Peer, SendFileElement } from '@/core/types';
|
import { ChatType, Peer, SendFileElement } from '@/core/types';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { uri2local } from '@/common/file';
|
import { uri2local } from '@/common/file';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { SendMessageContext } from '@/onebot/api';
|
||||||
import { MessageContext } from '@/onebot/api';
|
|
||||||
import { ContextMode, createContext } from '@/onebot/action/msg/SendMsg';
|
import { ContextMode, createContext } from '@/onebot/action/msg/SendMsg';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
file: Type.String(),
|
||||||
user_id: { type: ['number', 'string'] },
|
name: Type.String(),
|
||||||
file: { type: 'string' },
|
});
|
||||||
name: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['user_id', 'file', 'name'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class GoCQHTTPUploadPrivateFile extends OneBotAction<Payload, null> {
|
export default class GoCQHTTPUploadPrivateFile extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.GOCQHTTP_UploadPrivateFile;
|
actionName = ActionName.GOCQHTTP_UploadPrivateFile;
|
||||||
@@ -45,7 +41,7 @@ export default class GoCQHTTPUploadPrivateFile extends OneBotAction<Payload, nul
|
|||||||
throw new Error(downloadResult.errMsg);
|
throw new Error(downloadResult.errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
const msgContext: MessageContext = {
|
const msgContext: SendMessageContext = {
|
||||||
peer: await createContext(this.core, {
|
peer: await createContext(this.core, {
|
||||||
user_id: payload.user_id.toString(),
|
user_id: payload.user_id.toString(),
|
||||||
group_id: undefined,
|
group_id: undefined,
|
||||||
|
@@ -1,17 +1,13 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
});
|
||||||
message_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['message_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class DelEssenceMsg extends OneBotAction<Payload, any> {
|
export default class DelEssenceMsg extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.DelEssenceMsg;
|
actionName = ActionName.DelEssenceMsg;
|
||||||
|
@@ -1,18 +1,13 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
|
const SchemaData = Type.Object({
|
||||||
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
notice_id: Type.String()
|
||||||
|
});
|
||||||
|
|
||||||
const SchemaData = {
|
type Payload = Static<typeof SchemaData>;
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['number', 'string'] },
|
|
||||||
notice_id: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'notice_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class DelGroupNotice extends OneBotAction<Payload, any> {
|
export class DelGroupNotice extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.DelGroupNotice;
|
actionName = ActionName.DelGroupNotice;
|
||||||
|
@@ -1,19 +1,15 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
||||||
import { AIVoiceChatType } from "@/core/packet/entities/aiChat";
|
import { AIVoiceChatType } from "@/core/packet/entities/aiChat";
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
character: Type.String(),
|
||||||
properties: {
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
character: { type: ['string'] },
|
text: Type.String(),
|
||||||
group_id: { type: ['number', 'string'] },
|
});
|
||||||
text: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['character', 'group_id', 'text'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetAiRecord extends GetPacketStatusDepends<Payload, string> {
|
export class GetAiRecord extends GetPacketStatusDepends<Payload, string> {
|
||||||
actionName = ActionName.GetAiRecord;
|
actionName = ActionName.GetAiRecord;
|
||||||
|
@@ -1,20 +1,16 @@
|
|||||||
import { ChatType, Peer } from '@/core';
|
import { ChatType, Peer } from '@/core';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { AdapterConfigWrap } from '@/onebot/config/config';
|
import { AdapterConfigWrap } from '@/onebot/config/config';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
});
|
||||||
group_id: { type: ['number', 'string'] }
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetGroupEssence extends OneBotAction<Payload, any> {
|
export class GetGroupEssence extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_GetEssenceMsg;
|
actionName = ActionName.GoCQHTTP_GetEssenceMsg;
|
||||||
|
@@ -1,17 +1,6 @@
|
|||||||
import { GroupNotifyMsgStatus } from '@/core';
|
import { GroupNotifyMsgStatus } from '@/core';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GetGroupIgnoredNotifies extends OneBotAction<void, any> {
|
export class GetGroupIgnoredNotifies extends OneBotAction<void, any> {
|
||||||
actionName = ActionName.GetGroupIgnoredNotifies;
|
actionName = ActionName.GetGroupIgnoredNotifies;
|
||||||
|
|
||||||
|
@@ -2,17 +2,13 @@ import { OB11Group } from '@/onebot';
|
|||||||
import { OB11Construct } from '@/onebot/helper/data';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
});
|
||||||
group_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
class GetGroupInfo extends OneBotAction<Payload, OB11Group> {
|
class GetGroupInfo extends OneBotAction<Payload, OB11Group> {
|
||||||
actionName = ActionName.GetGroupInfo;
|
actionName = ActionName.GetGroupInfo;
|
||||||
|
@@ -2,16 +2,13 @@ import { OB11Group } from '@/onebot';
|
|||||||
import { OB11Construct } from '@/onebot/helper/data';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
// no_cache get时传字符串
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
no_cache: { type: ['boolean', 'string'] },
|
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
const SchemaData = Type.Object({
|
||||||
|
no_cache: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
class GetGroupList extends OneBotAction<Payload, OB11Group[]> {
|
class GetGroupList extends OneBotAction<Payload, OB11Group[]> {
|
||||||
actionName = ActionName.GetGroupList;
|
actionName = ActionName.GetGroupList;
|
||||||
|
@@ -2,19 +2,15 @@ import { OB11GroupMember } from '@/onebot';
|
|||||||
import { OB11Construct } from '@/onebot/helper/data';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
group_id: { type: ['number', 'string'] },
|
no_cache: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||||
user_id: { type: ['number', 'string'] },
|
});
|
||||||
no_cache: { type: ['boolean', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'user_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
class GetGroupMemberInfo extends OneBotAction<Payload, OB11GroupMember> {
|
class GetGroupMemberInfo extends OneBotAction<Payload, OB11GroupMember> {
|
||||||
actionName = ActionName.GetGroupMemberInfo;
|
actionName = ActionName.GetGroupMemberInfo;
|
||||||
|
@@ -2,18 +2,14 @@ import { OB11GroupMember } from '@/onebot';
|
|||||||
import { OB11Construct } from '@/onebot/helper/data';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
no_cache: Type.Optional(Type.Union([Type.Boolean(), Type.String()]))
|
||||||
group_id: { type: ['number', 'string'] },
|
});
|
||||||
no_cache: { type: ['boolean', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetGroupMemberList extends OneBotAction<Payload, OB11GroupMember[]> {
|
export class GetGroupMemberList extends OneBotAction<Payload, OB11GroupMember[]> {
|
||||||
actionName = ActionName.GetGroupMemberList;
|
actionName = ActionName.GetGroupMemberList;
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
import { WebApiGroupNoticeFeed } from '@/core';
|
import { WebApiGroupNoticeFeed } from '@/core';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
interface GroupNotice {
|
interface GroupNotice {
|
||||||
sender_id: number;
|
sender_id: number;
|
||||||
publish_time: number;
|
publish_time: number;
|
||||||
@@ -17,15 +16,11 @@ interface GroupNotice {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
});
|
||||||
group_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
type ApiGroupNotice = GroupNotice & WebApiGroupNoticeFeed;
|
type ApiGroupNotice = GroupNotice & WebApiGroupNoticeFeed;
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
});
|
||||||
group_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetGroupShutList extends OneBotAction<Payload, any> {
|
export class GetGroupShutList extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GetGroupShutList;
|
actionName = ActionName.GetGroupShutList;
|
||||||
|
@@ -1,17 +1,13 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
||||||
// no_cache get时传字符串
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['number', 'string'] },
|
|
||||||
user_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'user_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
const SchemaData = Type.Object({
|
||||||
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GroupPoke extends GetPacketStatusDepends<Payload, any> {
|
export class GroupPoke extends GetPacketStatusDepends<Payload, any> {
|
||||||
actionName = ActionName.GroupPoke;
|
actionName = ActionName.GroupPoke;
|
||||||
|
@@ -1,21 +1,18 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
||||||
import { uri2local } from "@/common/file";
|
import { uri2local } from "@/common/file";
|
||||||
import { ChatType, Peer } from "@/core";
|
import { ChatType, Peer } from "@/core";
|
||||||
import { AIVoiceChatType } from "@/core/packet/entities/aiChat";
|
import { AIVoiceChatType } from "@/core/packet/entities/aiChat";
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
character: Type.String(),
|
||||||
properties: {
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
character: { type: ['string'] },
|
text: Type.String(),
|
||||||
group_id: { type: ['number', 'string'] },
|
});
|
||||||
text: { type: 'string' },
|
|
||||||
},
|
type Payload = Static<typeof SchemaData>;
|
||||||
required: ['character', 'group_id', 'text'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class SendGroupAiRecord extends GetPacketStatusDepends<Payload, {
|
export class SendGroupAiRecord extends GetPacketStatusDepends<Payload, {
|
||||||
message_id: number
|
message_id: number
|
||||||
|
@@ -1,24 +1,20 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
});
|
||||||
message_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['message_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class SetEssenceMsg extends OneBotAction<Payload, any> {
|
export default class SetEssenceMsg extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.SetEssenceMsg;
|
actionName = ActionName.SetEssenceMsg;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<any> {
|
async _handle(payload: Payload): Promise<any> {
|
||||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString()));
|
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
throw new Error('msg not found');
|
throw new Error('msg not found');
|
||||||
}
|
}
|
||||||
|
@@ -1,19 +1,15 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { NTGroupRequestOperateTypes } from '@/core/types';
|
import { NTGroupRequestOperateTypes } from '@/core/types';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
flag: Type.String(),
|
||||||
properties: {
|
approve: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||||
flag: { type: 'string' },
|
reason: Type.String({ default: ' ' }),
|
||||||
approve: { type: ['string', 'boolean'] },
|
});
|
||||||
reason: { type: 'string', nullable: true },
|
|
||||||
},
|
|
||||||
required: ['flag'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class SetGroupAddRequest extends OneBotAction<Payload, null> {
|
export default class SetGroupAddRequest extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupAddRequest;
|
actionName = ActionName.SetGroupAddRequest;
|
||||||
@@ -24,7 +20,7 @@ export default class SetGroupAddRequest extends OneBotAction<Payload, null> {
|
|||||||
const approve = payload.approve?.toString() !== 'false';
|
const approve = payload.approve?.toString() !== 'false';
|
||||||
await this.core.apis.GroupApi.handleGroupRequest(flag,
|
await this.core.apis.GroupApi.handleGroupRequest(flag,
|
||||||
approve ? NTGroupRequestOperateTypes.KAGREE : NTGroupRequestOperateTypes.KREFUSE,
|
approve ? NTGroupRequestOperateTypes.KAGREE : NTGroupRequestOperateTypes.KREFUSE,
|
||||||
payload.reason ?? ' ',
|
payload.reason,
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -1,19 +1,15 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { NTGroupMemberRole } from '@/core/types';
|
import { NTGroupMemberRole } from '@/core/types';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
group_id: { type: ['number', 'string'] },
|
enable: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||||
user_id: { type: ['number', 'string'] },
|
});
|
||||||
enable: { type: ['boolean', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'user_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class SetGroupAdmin extends OneBotAction<Payload, null> {
|
export default class SetGroupAdmin extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupAdmin;
|
actionName = ActionName.SetGroupAdmin;
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
group_id: { type: ['number', 'string'] },
|
duration: Type.Union([Type.Number(), Type.String()], { default: 0 }),
|
||||||
user_id: { type: ['number', 'string'] },
|
});
|
||||||
duration: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'user_id', 'duration'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class SetGroupBan extends OneBotAction<Payload, null> {
|
export default class SetGroupBan extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupBan;
|
actionName = ActionName.SetGroupBan;
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
group_id: { type: ['number', 'string'] },
|
card: Type.Optional(Type.String())
|
||||||
user_id: { type: ['number', 'string'] },
|
});
|
||||||
card: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'user_id', 'card'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class SetGroupCard extends OneBotAction<Payload, null> {
|
export default class SetGroupCard extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupCard;
|
actionName = ActionName.SetGroupCard;
|
||||||
|
@@ -1,19 +1,14 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
|
const SchemaData = Type.Object({
|
||||||
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
reject_add_request: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||||
|
});
|
||||||
|
|
||||||
const SchemaData = {
|
type Payload = Static<typeof SchemaData>;
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['number', 'string'] },
|
|
||||||
user_id: { type: ['number', 'string'] },
|
|
||||||
reject_add_request: { type: ['boolean', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'user_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export default class SetGroupKick extends OneBotAction<Payload, null> {
|
export default class SetGroupKick extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupKick;
|
actionName = ActionName.SetGroupKick;
|
||||||
|
@@ -1,17 +1,14 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
is_dismiss: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||||
group_id: { type: ['number', 'string'] },
|
});
|
||||||
is_dismiss: { type: ['boolean', 'string'] },
|
|
||||||
},
|
type Payload = Static<typeof SchemaData>;
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
export default class SetGroupLeave extends OneBotAction<Payload, any> {
|
export default class SetGroupLeave extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.SetGroupLeave;
|
actionName = ActionName.SetGroupLeave;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
@@ -1,23 +1,21 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
group_name: Type.String(),
|
||||||
group_id: { type: ['number', 'string'] },
|
});
|
||||||
group_name: { type: 'string' },
|
|
||||||
},
|
type Payload = Static<typeof SchemaData>;
|
||||||
required: ['group_id', 'group_name'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
export default class SetGroupName extends OneBotAction<Payload, null> {
|
export default class SetGroupName extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupName;
|
actionName = ActionName.SetGroupName;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<null> {
|
async _handle(payload: Payload): Promise<null> {
|
||||||
let ret = await this.core.apis.GroupApi.setGroupName(payload.group_id.toString(), payload.group_name);
|
const ret = await this.core.apis.GroupApi.setGroupName(payload.group_id.toString(), payload.group_name);
|
||||||
if (ret.result !== 0) {
|
if (ret.result !== 0) {
|
||||||
throw new Error(`设置群名称失败 ErrCode: ${ret.result} ErrMsg: ${ret.errMsg}`);
|
throw new Error(`设置群名称失败 ErrCode: ${ret.result} ErrMsg: ${ret.errMsg}`);
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,13 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
enable: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||||
group_id: { type: ['number', 'string'] },
|
});
|
||||||
enable: { type: ['boolean', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class SetGroupWholeBan extends OneBotAction<Payload, null> {
|
export default class SetGroupWholeBan extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupWholeBan;
|
actionName = ActionName.SetGroupWholeBan;
|
||||||
|
@@ -1,22 +1,13 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
});
|
||||||
message_id: {
|
|
||||||
oneOf: [
|
|
||||||
{ type: 'number' },
|
|
||||||
{ type: 'string' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: ['message_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
class DeleteMsg extends OneBotAction<Payload, void> {
|
class DeleteMsg extends OneBotAction<Payload, void> {
|
||||||
actionName = ActionName.DeleteMsg;
|
actionName = ActionName.DeleteMsg;
|
||||||
|
@@ -1,20 +1,16 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ChatType, Peer } from '@/core/types';
|
import { ChatType, Peer } from '@/core/types';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
group_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
message_id: { type: ['number', 'string'] },
|
user_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
group_id: { type: ['number', 'string'] },
|
});
|
||||||
user_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['message_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
class ForwardSingleMsg extends OneBotAction<Payload, null> {
|
class ForwardSingleMsg extends OneBotAction<Payload, null> {
|
||||||
protected async getTargetPeer(payload: Payload): Promise<Peer> {
|
protected async getTargetPeer(payload: Payload): Promise<Peer> {
|
||||||
|
@@ -1,23 +1,18 @@
|
|||||||
import { OB11Message } from '@/onebot';
|
import { OB11Message } from '@/onebot';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
import { RawMessage } from '@/core';
|
import { RawMessage } from '@/core';
|
||||||
import { AdapterConfigWrap } from '@/onebot/config/config';
|
import { AdapterConfigWrap } from '@/onebot/config/config';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
export type ReturnDataType = OB11Message
|
export type ReturnDataType = OB11Message
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
});
|
||||||
message_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['message_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
class GetMsg extends OneBotAction<Payload, OB11Message> {
|
class GetMsg extends OneBotAction<Payload, OB11Message> {
|
||||||
actionName = ActionName.GetMsg;
|
actionName = ActionName.GetMsg;
|
||||||
|
@@ -1,19 +1,16 @@
|
|||||||
import { ChatType, Peer } from '@/core/types';
|
import { ChatType, Peer } from '@/core/types';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
user_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||||
properties: {
|
group_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||||
user_id: { type: ['number', 'string'] },
|
message_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||||
group_id: { type: ['number', 'string'] },
|
});
|
||||||
message_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type PlayloadType = FromSchema<typeof SchemaData>;
|
type PlayloadType = Static<typeof SchemaData>;
|
||||||
|
|
||||||
class MarkMsgAsRead extends OneBotAction<PlayloadType, null> {
|
class MarkMsgAsRead extends OneBotAction<PlayloadType, null> {
|
||||||
async getPeer(payload: PlayloadType): Promise<Peer> {
|
async getPeer(payload: PlayloadType): Promise<Peer> {
|
||||||
|
@@ -1,19 +1,15 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
properties: {
|
emoji_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
message_id: { type: ['string', 'number'] },
|
set: Type.Optional(Type.Union([Type.Boolean(), Type.String()]))
|
||||||
emoji_id: { type: ['string', 'number'] },
|
});
|
||||||
set: { type: ['boolean', 'string'] }
|
|
||||||
},
|
|
||||||
required: ['message_id', 'emoji_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class SetMsgEmojiLike extends OneBotAction<Payload, any> {
|
export class SetMsgEmojiLike extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.SetMsgEmojiLike;
|
actionName = ActionName.SetMsgEmojiLike;
|
||||||
|
@@ -1,21 +1,18 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
cookies: string,
|
cookies: string,
|
||||||
token: number
|
token: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
domain: Type.String()
|
||||||
properties: {
|
});
|
||||||
domain: { type: 'string' },
|
|
||||||
},
|
type Payload = Static<typeof SchemaData>;
|
||||||
required: ['domain'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GetCredentials extends OneBotAction<Payload, Response> {
|
export class GetCredentials extends OneBotAction<Payload, Response> {
|
||||||
actionName = ActionName.GetCredentials;
|
actionName = ActionName.GetCredentials;
|
||||||
|
@@ -1,21 +1,10 @@
|
|||||||
import { GroupNotifyMsgStatus } from '@/core';
|
import { GroupNotifyMsgStatus } from '@/core';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GetGroupSystemMsg extends OneBotAction<void, any> {
|
export class GetGroupSystemMsg extends OneBotAction<void, any> {
|
||||||
actionName = ActionName.GetGroupSystemMsg;
|
actionName = ActionName.GetGroupSystemMsg;
|
||||||
|
|
||||||
async _handle(payload: void) {
|
async _handle() {
|
||||||
const NTQQUserApi = this.core.apis.UserApi;
|
const NTQQUserApi = this.core.apis.UserApi;
|
||||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||||
// 默认10条 该api未完整实现 包括响应数据规范化 类型规范化
|
// 默认10条 该api未完整实现 包括响应数据规范化 类型规范化
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
user_id: Type.Union([Type.Number(), Type.String()])
|
||||||
properties: {
|
});
|
||||||
user_id: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['user_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class FriendPoke extends GetPacketStatusDepends<Payload, any> {
|
export class FriendPoke extends GetPacketStatusDepends<Payload, any> {
|
||||||
actionName = ActionName.FriendPoke;
|
actionName = ActionName.FriendPoke;
|
||||||
|
@@ -1,21 +1,16 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
cookies: string,
|
cookies: string,
|
||||||
bkn: string
|
bkn: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
domain: Type.String()
|
||||||
properties: {
|
});
|
||||||
domain: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['domain'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetCookies extends OneBotAction<Payload, Response> {
|
export class GetCookies extends OneBotAction<Payload, Response> {
|
||||||
actionName = ActionName.GetCookies;
|
actionName = ActionName.GetCookies;
|
||||||
|
@@ -2,17 +2,14 @@ import { OB11User } from '@/onebot';
|
|||||||
import { OB11Construct } from '@/onebot/helper/data';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
// no_cache get时传字符串
|
const SchemaData = Type.Object({
|
||||||
const SchemaData = {
|
no_cache: Type.Union([Type.Boolean(), Type.String()]),
|
||||||
type: 'object',
|
});
|
||||||
properties: {
|
|
||||||
no_cache: { type: ['boolean', 'string'] },
|
type Payload = Static<typeof SchemaData>;
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
export default class GetFriendList extends OneBotAction<Payload, OB11User[]> {
|
export default class GetFriendList extends OneBotAction<Payload, OB11User[]> {
|
||||||
actionName = ActionName.GetFriendList;
|
actionName = ActionName.GetFriendList;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
@@ -1,23 +1,21 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { AdapterConfigWrap } from '@/onebot/config/config';
|
import { AdapterConfigWrap } from '@/onebot/config/config';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
count: Type.Union([Type.Number(), Type.String()], { default: 10 }),
|
||||||
properties: {
|
});
|
||||||
count: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class GetRecentContact extends OneBotAction<Payload, any> {
|
export default class GetRecentContact extends OneBotAction<Payload, any> {
|
||||||
actionName = ActionName.GetRecentContact;
|
actionName = ActionName.GetRecentContact;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload, adapter: string) {
|
async _handle(payload: Payload, adapter: string) {
|
||||||
const ret = await this.core.apis.UserApi.getRecentContactListSnapShot(+(payload.count || 10));
|
const ret = await this.core.apis.UserApi.getRecentContactListSnapShot(+payload.count);
|
||||||
const network = Object.values(this.obContext.configLoader.configData.network) as Array<AdapterConfigWrap>;
|
const network = Object.values(this.obContext.configLoader.configData.network) as Array<AdapterConfigWrap>;
|
||||||
//烘焙消息
|
//烘焙消息
|
||||||
const msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
|
const msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
|
||||||
|
@@ -1,17 +1,13 @@
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
times: Type.Union([Type.Number(), Type.String()], { default: 1 }),
|
||||||
properties: {
|
user_id: Type.Union([Type.Number(), Type.String()])
|
||||||
user_id: { type: ['number', 'string'] },
|
});
|
||||||
times: { type: ['number', 'string'] },
|
|
||||||
},
|
|
||||||
required: ['user_id', 'times'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class SendLike extends OneBotAction<Payload, null> {
|
export default class SendLike extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.SendLike;
|
actionName = ActionName.SendLike;
|
||||||
@@ -20,7 +16,7 @@ export default class SendLike extends OneBotAction<Payload, null> {
|
|||||||
async _handle(payload: Payload): Promise<null> {
|
async _handle(payload: Payload): Promise<null> {
|
||||||
const qq = payload.user_id.toString();
|
const qq = payload.user_id.toString();
|
||||||
const uid: string = await this.core.apis.UserApi.getUidByUinV2(qq) ?? '';
|
const uid: string = await this.core.apis.UserApi.getUidByUinV2(qq) ?? '';
|
||||||
const result = await this.core.apis.UserApi.like(uid, parseInt(payload.times?.toString()) || 1);
|
const result = await this.core.apis.UserApi.like(uid, +payload.times);
|
||||||
if (result.result !== 0) {
|
if (result.result !== 0) {
|
||||||
throw new Error(`点赞失败 ${result.errMsg}`);
|
throw new Error(`点赞失败 ${result.errMsg}`);
|
||||||
}
|
}
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = Type.Object({
|
||||||
type: 'object',
|
flag: Type.String(),
|
||||||
properties: {
|
approve: Type.Optional(Type.Union([Type.String(), Type.Boolean()])),
|
||||||
flag: { type: 'string' },
|
remark: Type.Optional(Type.String())
|
||||||
approve: { type: ['string', 'boolean'] },
|
});
|
||||||
remark: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['flag'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export default class SetFriendAddRequest extends OneBotAction<Payload, null> {
|
export default class SetFriendAddRequest extends OneBotAction<Payload, null> {
|
||||||
actionName = ActionName.SetFriendAddRequest;
|
actionName = ActionName.SetFriendAddRequest;
|
||||||
|
Reference in New Issue
Block a user