mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5f56c8a7d4 | ||
![]() |
309d8a9f18 | ||
![]() |
2981799803 | ||
![]() |
00f8e1c0da | ||
![]() |
e9482e2ec4 | ||
![]() |
9bff327377 | ||
![]() |
ae009f98c1 | ||
![]() |
77505a6f5b | ||
![]() |
19c729aa23 |
@@ -4,7 +4,7 @@
|
|||||||
"name": "NapCatQQ",
|
"name": "NapCatQQ",
|
||||||
"slug": "NapCat.Framework",
|
"slug": "NapCat.Framework",
|
||||||
"description": "高性能的 OneBot 11 协议实现",
|
"description": "高性能的 OneBot 11 协议实现",
|
||||||
"version": "2.2.30",
|
"version": "",
|
||||||
"icon": "./logo.png",
|
"icon": "./logo.png",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
"name": "napcat",
|
"name": "napcat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "2.2.30",
|
"version": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:framework": "vite build --mode framework",
|
"build:framework": "vite build --mode framework",
|
||||||
"build:shell": "vite build --mode shell",
|
"build:shell": "vite build --mode shell",
|
||||||
|
@@ -25,29 +25,31 @@ export async function solveAsyncProblem<T extends (...args: any[]) => Promise<an
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class FileNapCatOneBotUUID {
|
export class FileNapCatOneBotUUID {
|
||||||
static encodeModelId(peer: Peer, modelId: string): string {
|
static encodeModelId(peer: Peer, modelId: string, fileId: string): string {
|
||||||
return `NapCatOneBot-ModelIdFile-${peer.chatType}-${peer.peerUid}-${modelId}`;
|
return `NapCatOneBot|ModelIdFile|${peer.chatType}|${peer.peerUid}|${modelId}|${fileId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static decodeModelId(uuid: string): undefined | {
|
static decodeModelId(uuid: string): undefined | {
|
||||||
peer: Peer,
|
peer: Peer,
|
||||||
modelId: string
|
modelId: string,
|
||||||
|
fileId: string
|
||||||
} {
|
} {
|
||||||
if (!uuid.startsWith('NapCatOneBot-ModelIdFile-')) return undefined;
|
if (!uuid.startsWith('NapCatOneBot|ModelIdFile|')) return undefined;
|
||||||
const data = uuid.split('-');
|
const data = uuid.split('|');
|
||||||
if (data.length !== 5) return undefined;
|
if (data.length !== 6) return undefined;
|
||||||
const [, , chatType, peerUid, modelId] = data;
|
const [, , chatType, peerUid, modelId,fileId] = data;
|
||||||
return {
|
return {
|
||||||
peer: {
|
peer: {
|
||||||
chatType: chatType as any,
|
chatType: chatType as any,
|
||||||
peerUid: peerUid,
|
peerUid: peerUid,
|
||||||
},
|
},
|
||||||
modelId,
|
modelId,
|
||||||
|
fileId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static encode(peer: Peer, msgId: string, elementId: string): string {
|
static encode(peer: Peer, msgId: string, elementId: string): string {
|
||||||
return `NapCatOneBot-MsgFile-${peer.chatType}-${peer.peerUid}-${msgId}-${elementId}`;
|
return `NapCatOneBot|MsgFile|${peer.chatType}|${peer.peerUid}|${msgId}|${elementId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static decode(uuid: string): undefined | {
|
static decode(uuid: string): undefined | {
|
||||||
@@ -55,8 +57,8 @@ export class FileNapCatOneBotUUID {
|
|||||||
msgId: string,
|
msgId: string,
|
||||||
elementId: string
|
elementId: string
|
||||||
} {
|
} {
|
||||||
if (!uuid.startsWith('NapCatOneBot-MsgFile-')) return undefined;
|
if (!uuid.startsWith('NapCatOneBot|MsgFile|')) return undefined;
|
||||||
const data = uuid.split('-');
|
const data = uuid.split('|');
|
||||||
if (data.length !== 6) return undefined;
|
if (data.length !== 6) return undefined;
|
||||||
const [, , chatType, peerUid, msgId, elementId] = data;
|
const [, , chatType, peerUid, msgId, elementId] = data;
|
||||||
return {
|
return {
|
||||||
@@ -138,19 +140,19 @@ export function isEqual(obj1: any, obj2: any) {
|
|||||||
export function getDefaultQQVersionConfigInfo(): QQVersionConfigType {
|
export function getDefaultQQVersionConfigInfo(): QQVersionConfigType {
|
||||||
if (os.platform() === 'linux') {
|
if (os.platform() === 'linux') {
|
||||||
return {
|
return {
|
||||||
baseVersion: '3.2.12-27254',
|
baseVersion: '3.2.12-27597',
|
||||||
curVersion: '3.2.12-27254',
|
curVersion: '3.2.12-27597',
|
||||||
prevVersion: '',
|
prevVersion: '',
|
||||||
onErrorVersions: [],
|
onErrorVersions: [],
|
||||||
buildId: '27254',
|
buildId: '27597',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
baseVersion: '9.9.15-27391',
|
baseVersion: '9.9.15-27597',
|
||||||
curVersion: '9.9.15-27391',
|
curVersion: '9.9.15-27597',
|
||||||
prevVersion: '',
|
prevVersion: '',
|
||||||
onErrorVersions: [],
|
onErrorVersions: [],
|
||||||
buildId: '27391',
|
buildId: '27597',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,6 +71,6 @@ export class QQBasicInfoWrapper {
|
|||||||
// else
|
// else
|
||||||
this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`);
|
this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`);
|
||||||
this.context.logger.log(`[QQ版本兼容性检测] ${fullVersion} 版本兼容性不佳,可能会导致一些功能无法正常使用`,);
|
this.context.logger.log(`[QQ版本兼容性检测] ${fullVersion} 版本兼容性不佳,可能会导致一些功能无法正常使用`,);
|
||||||
return { appid: systemPlatform === 'linux' ? '537240795' : '537240709', qua: this.getQUAInternal() };
|
return { appid: systemPlatform === 'linux' ? '537243600' : '537243441', qua: this.getQUAInternal() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const napCatVersion = '2.2.30';
|
export const napCatVersion = '';
|
||||||
|
36
src/core/external/appid.json
vendored
36
src/core/external/appid.json
vendored
@@ -1,39 +1,7 @@
|
|||||||
{
|
{
|
||||||
"3.2.12-27187": {
|
"3.2.12-27597": {
|
||||||
"appid": 537240645,
|
|
||||||
"qua": "V1_LNX_NQ_3.2.12_27187_GW_B"
|
|
||||||
},
|
|
||||||
"3.2.12-27206": {
|
|
||||||
"appid": 537240645,
|
|
||||||
"qua": "V1_LNX_NQ_3.2.12_27206_GW_B"
|
|
||||||
},
|
|
||||||
"3.2.12-27254": {
|
|
||||||
"appid": 537240795,
|
|
||||||
"qua": "V1_LNX_NQ_3.2.12_27254_GW_B"
|
|
||||||
},
|
|
||||||
"3.2.12-27556": {
|
|
||||||
"appid": 537243600,
|
"appid": 537243600,
|
||||||
"qua": "V1_LNX_NQ_3.2.12_27556_GW_B"
|
"qua": "V1_LNX_NQ_3.2.12_27597_GW_B"
|
||||||
},
|
|
||||||
"9.9.15-27187": {
|
|
||||||
"appid": 537240610,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27187_GW_B"
|
|
||||||
},
|
|
||||||
"9.9.15-27206": {
|
|
||||||
"appid": 537240610,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27206_GW_B"
|
|
||||||
},
|
|
||||||
"9.9.15-27254": {
|
|
||||||
"appid": 537240709,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27254_GW_B"
|
|
||||||
},
|
|
||||||
"9.9.15-27333": {
|
|
||||||
"appid": 537240709,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27333_GW_B"
|
|
||||||
},
|
|
||||||
"9.9.15-27391": {
|
|
||||||
"appid": 537240709,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27333_GW_B"
|
|
||||||
},
|
},
|
||||||
"9.9.15-27597": {
|
"9.9.15-27597": {
|
||||||
"appid": 537243441,
|
"appid": 537243441,
|
||||||
|
@@ -1,23 +0,0 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import BaseAction from '../BaseAction';
|
|
||||||
import { ActionName } from '../types';
|
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['string', 'number'] },
|
|
||||||
file_id: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'file_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class DelGroupFile extends BaseAction<Payload, any> {
|
|
||||||
actionName = ActionName.DelGroupFile;
|
|
||||||
payloadSchema = SchemaData;
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
|
||||||
return await this.core.apis.GroupApi.DelGroupFile(payload.group_id.toString(), [payload.file_id]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,24 +0,0 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import BaseAction from '../BaseAction';
|
|
||||||
import { ActionName } from '../types';
|
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['string', 'number'] },
|
|
||||||
folder_id: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'folder_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class DelGroupFileFolder extends BaseAction<Payload, any> {
|
|
||||||
actionName = ActionName.DelGroupFileFolder;
|
|
||||||
payloadSchema = SchemaData;
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
|
||||||
return (await this.core.apis.GroupApi.DelGroupFileFolder(
|
|
||||||
payload.group_id.toString(), payload.folder_id)).groupFileCommonResult;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import BaseAction from '../BaseAction';
|
|
||||||
import { ActionName } from '../types';
|
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['string', 'number'] },
|
|
||||||
},
|
|
||||||
required: ['group_id'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GetGroupFileCount extends BaseAction<Payload, { count: number }> {
|
|
||||||
actionName = ActionName.GetGroupFileCount;
|
|
||||||
payloadSchema = SchemaData;
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
|
||||||
const ret = await this.core.apis.GroupApi.getGroupFileCount([payload.group_id?.toString()]);
|
|
||||||
return { count: ret.groupFileCounts[0] };
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,50 +0,0 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import BaseAction from '../BaseAction';
|
|
||||||
import { ActionName } from '../types';
|
|
||||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['string', 'number'] },
|
|
||||||
start_index: { type: ['string', 'number'] },
|
|
||||||
file_count: { type: ['string', 'number'] },
|
|
||||||
folder_id: { type: ['string', 'number'] },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'start_index', 'file_count'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GetGroupFileList extends BaseAction<Payload, { FileList: Array<any> }> {
|
|
||||||
actionName = ActionName.GetGroupFileList;
|
|
||||||
payloadSchema = SchemaData;
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
|
||||||
let param = {};
|
|
||||||
if (payload.folder_id) {
|
|
||||||
param = {
|
|
||||||
folderId: payload.folder_id.toString(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const ret = await this.core.apis.MsgApi.getGroupFileList(payload.group_id.toString(), {
|
|
||||||
sortType: 1,
|
|
||||||
fileCount: +payload.file_count,
|
|
||||||
startIndex: +payload.start_index,
|
|
||||||
sortOrder: 2,
|
|
||||||
showOnlinedocFolder: 0,
|
|
||||||
...param
|
|
||||||
}).catch(() => {
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
ret.forEach((e) => {
|
|
||||||
const fileModelId = e?.fileInfo?.fileModelId;
|
|
||||||
if (fileModelId)
|
|
||||||
e.fileInfo!.fileId = FileNapCatOneBotUUID.encodeModelId({
|
|
||||||
chatType: 2,
|
|
||||||
peerUid: payload.group_id.toString()
|
|
||||||
}, fileModelId);
|
|
||||||
});
|
|
||||||
return { FileList: ret };
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import BaseAction from '../BaseAction';
|
|
||||||
import { ActionName } from '../types';
|
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['string', 'number'] },
|
|
||||||
folder_name: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'folder_name'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class SetGroupFileFolder extends BaseAction<Payload, any> {
|
|
||||||
actionName = ActionName.SetGroupFileFolder;
|
|
||||||
payloadSchema = SchemaData;
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
|
||||||
return (await this.core.apis.GroupApi.CreatGroupFileFolder(payload.group_id.toString(), payload.folder_name)).resultWithGroupItem;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,10 +1,6 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
|
||||||
import { NapCatCore } from '@/core';
|
|
||||||
import { SetGroupFileFolder } from '@/onebot/action/file/SetGroupFileFolder';
|
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
@@ -16,17 +12,10 @@ const SchemaData = {
|
|||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export class CreateGroupFileFolder extends BaseAction<Payload, null> {
|
export class CreateGroupFileFolder extends BaseAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_CreateGroupFileFolder;
|
actionName = ActionName.GoCQHTTP_CreateGroupFileFolder;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
constructor(obContext: NapCatOneBot11Adapter, core: NapCatCore,
|
|
||||||
private ncSetGroupFileFolderImpl: SetGroupFileFolder) {
|
|
||||||
super(obContext, core);
|
|
||||||
}
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
await this.ncSetGroupFileFolderImpl._handle(payload);
|
return (await this.core.apis.GroupApi.CreatGroupFileFolder(payload.group_id.toString(), payload.folder_name)).resultWithGroupItem;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,7 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NapCatCore } from '@/core';
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
|
||||||
import { DelGroupFile } from '@/onebot/action/file/DelGroupFile';
|
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
@@ -16,17 +13,12 @@ const SchemaData = {
|
|||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export class DeleteGroupFile extends BaseAction<Payload, null> {
|
export class DeleteGroupFile extends BaseAction<Payload, any> {
|
||||||
actionName = ActionName.GOCQHTTP_DeleteGroupFile;
|
actionName = ActionName.GOCQHTTP_DeleteGroupFile;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
constructor(obContext: NapCatOneBot11Adapter, core: NapCatCore,
|
|
||||||
private ncDelGroupFileImpl: DelGroupFile) {
|
|
||||||
super(obContext, core);
|
|
||||||
}
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
await this.ncDelGroupFileImpl._handle(payload);
|
const data = FileNapCatOneBotUUID.decodeModelId(payload.file_id);
|
||||||
return null;
|
if (!data) throw new Error('Invalid file_id');
|
||||||
|
return await this.core.apis.GroupApi.DelGroupFile(payload.group_id.toString(), [data.fileId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import BaseAction from '../BaseAction';
|
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NapCatCore } from '@/core';
|
import BaseAction from '../BaseAction';
|
||||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
|
||||||
import { DelGroupFileFolder } from '@/onebot/action/file/DelGroupFileFolder';
|
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -16,17 +13,11 @@ const SchemaData = {
|
|||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export class DeleteGroupFileFolder extends BaseAction<Payload, null> {
|
export class DeleteGroupFileFolder extends BaseAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_DeleteGroupFileFolder;
|
actionName = ActionName.GoCQHTTP_DeleteGroupFileFolder;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
constructor(obContext: NapCatOneBot11Adapter, core: NapCatCore,
|
|
||||||
private ncDelGroupFileFolderImpl: DelGroupFileFolder) {
|
|
||||||
super(obContext, core);
|
|
||||||
}
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
await this.ncDelGroupFileFolderImpl._handle(payload);
|
return (await this.core.apis.GroupApi.DelGroupFileFolder(
|
||||||
return null;
|
payload.group_id.toString(), payload.folder_id)).groupFileCommonResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,43 +1,27 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NapCatOneBot11Adapter, OB11GroupFile } from '@/onebot';
|
|
||||||
import { NapCatCore } from '@/core';
|
|
||||||
import { GetGroupRootFiles } from '@/onebot/action/go-cqhttp/GetGroupRootFiles';
|
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Entities } from '@/onebot/entities';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
group_id: { type: ['string', 'number'] },
|
group_id: { type: ['string', 'number'] },
|
||||||
folder_id: { type: 'string' },
|
folder_id: { type: 'string' },
|
||||||
|
file_count: { type: ['string', 'number'] },
|
||||||
},
|
},
|
||||||
required: ['group_id', 'folder_id'],
|
required: ['group_id', 'folder_id'],
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetGroupFilesByFolder extends BaseAction<Payload, {
|
export class GetGroupFilesByFolder extends BaseAction<any, any> {
|
||||||
files: OB11GroupFile[],
|
|
||||||
folders: [] // QQ does not allow nested folders
|
|
||||||
}> {
|
|
||||||
actionName = ActionName.GoCQHTTP_GetGroupFilesByFolder;
|
actionName = ActionName.GoCQHTTP_GetGroupFilesByFolder;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
constructor(obContext: NapCatOneBot11Adapter, core: NapCatCore,
|
|
||||||
private getGroupRootFilesImpl: GetGroupRootFiles) {
|
|
||||||
super(obContext, core);
|
|
||||||
}
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const folder = (await this.getGroupRootFilesImpl._handle({ group_id: payload.group_id }))
|
|
||||||
.folders.find(folder => folder.folder_id === payload.folder_id);
|
|
||||||
if (!folder) {
|
|
||||||
throw new Error('Folder not found');
|
|
||||||
}
|
|
||||||
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: folder.total_file_count,
|
fileCount: +(payload.file_count ?? 50),
|
||||||
startIndex: 0,
|
startIndex: 0,
|
||||||
sortOrder: 2,
|
sortOrder: 2,
|
||||||
showOnlinedocFolder: 0,
|
showOnlinedocFolder: 0,
|
||||||
|
@@ -1,15 +1,14 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NapCatOneBot11Adapter, OB11GroupFile, OB11GroupFileFolder } from '@/onebot';
|
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot';
|
||||||
import { NapCatCore } from '@/core';
|
|
||||||
import { GetGroupFileCount } from '@/onebot/action/file/GetGroupFileCount';
|
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Entities } from '@/onebot/entities';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
group_id: { type: ['string', 'number'] },
|
group_id: { type: ['string', 'number'] },
|
||||||
|
file_count: { type: ['string', 'number'] },
|
||||||
},
|
},
|
||||||
required: ['group_id'],
|
required: ['group_id'],
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
@@ -22,16 +21,10 @@ export class GetGroupRootFiles extends BaseAction<Payload, {
|
|||||||
}> {
|
}> {
|
||||||
actionName = ActionName.GoCQHTTP_GetGroupRootFiles;
|
actionName = ActionName.GoCQHTTP_GetGroupRootFiles;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
constructor(obContext: NapCatOneBot11Adapter, core: NapCatCore,
|
|
||||||
private ncGetGroupFileCountImpl: GetGroupFileCount) {
|
|
||||||
super(obContext, core);
|
|
||||||
}
|
|
||||||
|
|
||||||
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: (await this.ncGetGroupFileCountImpl._handle({ group_id: payload.group_id.toString() })).count,
|
fileCount: +(payload.file_count ?? 50),
|
||||||
startIndex: 0,
|
startIndex: 0,
|
||||||
sortOrder: 2,
|
sortOrder: 2,
|
||||||
showOnlinedocFolder: 0,
|
showOnlinedocFolder: 0,
|
||||||
|
@@ -55,12 +55,7 @@ import { GoCQHTTPHandleQuickAction } from './go-cqhttp/QuickAction';
|
|||||||
import { GetGroupIgnoredNotifies } from './group/GetGroupIgnoredNotifies';
|
import { GetGroupIgnoredNotifies } from './group/GetGroupIgnoredNotifies';
|
||||||
import { GetOnlineClient } from './go-cqhttp/GetOnlineClient';
|
import { GetOnlineClient } from './go-cqhttp/GetOnlineClient';
|
||||||
import { IOCRImage, OCRImage } from './extends/OCRImage';
|
import { IOCRImage, OCRImage } from './extends/OCRImage';
|
||||||
import { GetGroupFileCount } from './file/GetGroupFileCount';
|
|
||||||
import { GetGroupFileList } from './file/GetGroupFileList';
|
|
||||||
import { TranslateEnWordToZn } from './extends/TranslateEnWordToZn';
|
import { TranslateEnWordToZn } from './extends/TranslateEnWordToZn';
|
||||||
import { SetGroupFileFolder } from './file/SetGroupFileFolder';
|
|
||||||
import { DelGroupFile } from './file/DelGroupFile';
|
|
||||||
import { DelGroupFileFolder } from './file/DelGroupFileFolder';
|
|
||||||
import { SetQQProfile } from './go-cqhttp/SetQQProfile';
|
import { SetQQProfile } from './go-cqhttp/SetQQProfile';
|
||||||
import { ShareGroupEx, SharePeer } from './extends/ShareContact';
|
import { ShareGroupEx, SharePeer } from './extends/ShareContact';
|
||||||
import { CreateCollection } from './extends/CreateCollection';
|
import { CreateCollection } from './extends/CreateCollection';
|
||||||
@@ -92,11 +87,6 @@ import { GetGroupFilesByFolder } from '@/onebot/action/go-cqhttp/GetGroupFilesBy
|
|||||||
export type ActionMap = Map<string, BaseAction<any, any>>;
|
export type ActionMap = Map<string, BaseAction<any, any>>;
|
||||||
|
|
||||||
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore): ActionMap {
|
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore): ActionMap {
|
||||||
const ncDelGroupFile = new DelGroupFile(obContext, core);
|
|
||||||
const ncSetGroupFileFolder = new SetGroupFileFolder(obContext, core);
|
|
||||||
const ncDelGroupFileFolder = new DelGroupFileFolder(obContext, core);
|
|
||||||
const ncGetGroupFileCount = new GetGroupFileCount(obContext, core);
|
|
||||||
const goCqHttpGetGroupRootFiles = new GetGroupRootFiles(obContext, core, ncGetGroupFileCount);
|
|
||||||
|
|
||||||
const actionHandlers = [
|
const actionHandlers = [
|
||||||
new GetGroupInfoEx(obContext, core),
|
new GetGroupInfoEx(obContext, core),
|
||||||
@@ -113,11 +103,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
|||||||
new MarkPrivateMsgAsRead(obContext, core),
|
new MarkPrivateMsgAsRead(obContext, core),
|
||||||
new SetQQAvatar(obContext, core),
|
new SetQQAvatar(obContext, core),
|
||||||
new TranslateEnWordToZn(obContext, core),
|
new TranslateEnWordToZn(obContext, core),
|
||||||
ncGetGroupFileCount,
|
new GetGroupRootFiles(obContext, core),
|
||||||
new GetGroupFileList(obContext, core),
|
|
||||||
ncSetGroupFileFolder,
|
|
||||||
ncDelGroupFile,
|
|
||||||
ncDelGroupFileFolder,
|
|
||||||
// onebot11
|
// onebot11
|
||||||
new SendLike(obContext, core),
|
new SendLike(obContext, core),
|
||||||
new GetMsg(obContext, core),
|
new GetMsg(obContext, core),
|
||||||
@@ -185,12 +171,11 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
|||||||
new SetInputStatus(obContext, core),
|
new SetInputStatus(obContext, core),
|
||||||
new GetCSRF(obContext, core),
|
new GetCSRF(obContext, core),
|
||||||
new DelGroupNotice(obContext, core),
|
new DelGroupNotice(obContext, core),
|
||||||
new DeleteGroupFile(obContext, core, ncDelGroupFile),
|
new DeleteGroupFile(obContext, core),
|
||||||
new CreateGroupFileFolder(obContext, core, ncSetGroupFileFolder),
|
new CreateGroupFileFolder(obContext, core),
|
||||||
new DeleteGroupFileFolder(obContext, core, ncDelGroupFileFolder),
|
new DeleteGroupFileFolder(obContext, core),
|
||||||
new GetGroupFileSystemInfo(obContext, core),
|
new GetGroupFileSystemInfo(obContext, core),
|
||||||
goCqHttpGetGroupRootFiles,
|
new GetGroupFilesByFolder(obContext, core),
|
||||||
new GetGroupFilesByFolder(obContext, core, goCqHttpGetGroupRootFiles),
|
|
||||||
];
|
];
|
||||||
const actionMap = new Map();
|
const actionMap = new Map();
|
||||||
for (const action of actionHandlers) {
|
for (const action of actionHandlers) {
|
||||||
|
@@ -213,7 +213,7 @@ export class OneBotGroupApi {
|
|||||||
async parseGroupMemberIncreaseEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
async parseGroupMemberIncreaseEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||||
const groupElement = grayTipElement?.groupElement;
|
const groupElement = grayTipElement?.groupElement;
|
||||||
if (!groupElement) return undefined;
|
if (!groupElement) return undefined;
|
||||||
const member = await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.memberUid);
|
const member = await this.core.apis.UserApi.getUserDetailInfo(groupElement.memberUid);
|
||||||
const memberUin = member?.uin;
|
const memberUin = member?.uin;
|
||||||
const adminMember = await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid);
|
const adminMember = await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid);
|
||||||
if (memberUin) {
|
if (memberUin) {
|
||||||
|
@@ -109,7 +109,7 @@ export class OB11Entities {
|
|||||||
static file(peerId: string, file: Exclude<GroupFileInfoUpdateParamType['item'][0]['fileInfo'], undefined>): OB11GroupFile {
|
static file(peerId: string, file: Exclude<GroupFileInfoUpdateParamType['item'][0]['fileInfo'], undefined>): OB11GroupFile {
|
||||||
return {
|
return {
|
||||||
group_id: parseInt(peerId),
|
group_id: parseInt(peerId),
|
||||||
file_id: FileNapCatOneBotUUID.encodeModelId({ chatType: 2, peerUid: peerId }, file.fileModelId),
|
file_id: FileNapCatOneBotUUID.encodeModelId({ chatType: 2, peerUid: peerId }, file.fileModelId, file.fileId),
|
||||||
file_name: file.fileName,
|
file_name: file.fileName,
|
||||||
busid: file.busId,
|
busid: file.busId,
|
||||||
size: parseInt(file.fileSize),
|
size: parseInt(file.fileSize),
|
||||||
|
@@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
undefined,
|
undefined,
|
||||||
SettingButton('V2.2.30', 'napcat-update-button', 'secondary'),
|
SettingButton('V', 'napcat-update-button', 'secondary'),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
@@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
void 0,
|
void 0,
|
||||||
SettingButton("V2.2.30", "napcat-update-button", "secondary")
|
SettingButton("V", "napcat-update-button", "secondary")
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
Reference in New Issue
Block a user