mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
feat: 移动群文件
This commit is contained in:
@@ -154,6 +154,13 @@ export class PacketOperationContext {
|
||||
return res.result.resId;
|
||||
}
|
||||
|
||||
async MoveGroupFile(groupUin: number, fileUUID: string, currentParentDirectory: string, targetParentDirectory: string) {
|
||||
const req = trans.MoveGroupFile.build(groupUin, fileUUID, currentParentDirectory, targetParentDirectory);
|
||||
const resp = await this.context.client.sendOidbPacket(req, true);
|
||||
const res = trans.MoveGroupFile.parse(resp);
|
||||
return res.move.retCode;
|
||||
}
|
||||
|
||||
async GetGroupFileUrl(groupUin: number, fileUUID: string) {
|
||||
const req = trans.DownloadGroupFile.build(groupUin, fileUUID);
|
||||
const resp = await this.context.client.sendOidbPacket(req, true);
|
||||
|
35
src/core/packet/transformer/action/MoveGroupFile.ts
Normal file
35
src/core/packet/transformer/action/MoveGroupFile.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import * as proto from '@/core/packet/transformer/proto';
|
||||
import { NapProtoMsg } from '@napneko/nap-proto-core';
|
||||
import { OidbPacket, PacketTransformer } from '@/core/packet/transformer/base';
|
||||
import OidbBase from '@/core/packet/transformer/oidb/oidbBase';
|
||||
|
||||
class MoveGroupFile extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0x6D6Response> {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
build(groupUin: number, fileUUID: string, currentParentDirectory: string, targetParentDirectory: string): OidbPacket {
|
||||
const body = new NapProtoMsg(proto.OidbSvcTrpcTcp0x6D6).encode({
|
||||
move: {
|
||||
groupUin: groupUin,
|
||||
appId: 5,
|
||||
busId: 102,
|
||||
fileId: fileUUID,
|
||||
parentDirectory: currentParentDirectory,
|
||||
targetDirectory: targetParentDirectory,
|
||||
}
|
||||
});
|
||||
return OidbBase.build(0x6D6, 5, body, true, false);
|
||||
}
|
||||
|
||||
parse(data: Buffer) {
|
||||
const oidbBody = OidbBase.parse(data).body;
|
||||
const res = new NapProtoMsg(proto.OidbSvcTrpcTcp0x6D6Response).decode(oidbBody);
|
||||
if (res.move.retCode !== 0) {
|
||||
throw new Error(`sendGroupFileMoveReq error: ${res.move.clientWording} (code=${res.move.retCode})`);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
export default new MoveGroupFile();
|
@@ -6,3 +6,4 @@ export { default as GetStrangerInfo } from './GetStrangerInfo';
|
||||
export { default as SendPoke } from './SendPoke';
|
||||
export { default as SetSpecialTitle } from './SetSpecialTitle';
|
||||
export { default as ImageOCR } from './ImageOCR';
|
||||
export { default as MoveGroupFile } from './MoveGroupFile';
|
||||
|
32
src/onebot/action/extends/MoveGroupFile.ts
Normal file
32
src/onebot/action/extends/MoveGroupFile.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { FileNapCatOneBotUUID } from '@/common/file-uuid';
|
||||
import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
file_id: Type.String(),
|
||||
current_parent_directory: Type.String(),
|
||||
target_parent_directory: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
interface MoveGroupFileResponse {
|
||||
retcode: number;
|
||||
}
|
||||
|
||||
export class MoveGroupFile extends GetPacketStatusDepends<Payload, MoveGroupFileResponse> {
|
||||
override actionName = ActionName.GOCQHTTP_MoveGroupFile;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const contextMsgFile = FileNapCatOneBotUUID.decode(payload.file_id) || FileNapCatOneBotUUID.decodeModelId(payload.file_id);
|
||||
if (contextMsgFile?.fileUUID) {
|
||||
return {
|
||||
retcode: await this.core.apis.PacketApi.pkt.operation.MoveGroupFile(+payload.group_id, contextMsgFile.fileUUID, payload.current_parent_directory, payload.target_parent_directory)
|
||||
};
|
||||
}
|
||||
throw new Error('real fileUUID not found!');
|
||||
}
|
||||
}
|
@@ -109,6 +109,7 @@ import { ClickInlineKeyboardButton } from './extends/ClickInlineKeyboardButton';
|
||||
import { GetPrivateFileUrl } from './file/GetPrivateFileUrl';
|
||||
import { GetUnidirectionalFriendList } from './extends/GetUnidirectionalFriendList';
|
||||
import SetGroupRemark from './extends/SetGroupRemark';
|
||||
import { MoveGroupFile } from './extends/MoveGroupFile';
|
||||
|
||||
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
||||
|
||||
@@ -132,6 +133,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
||||
new SetGroupSign(obContext, core),
|
||||
new SendGroupSign(obContext, core),
|
||||
new GetClientkey(obContext, core),
|
||||
new MoveGroupFile(obContext, core),
|
||||
// onebot11
|
||||
new SendLike(obContext, core),
|
||||
new GetMsg(obContext, core),
|
||||
|
@@ -85,6 +85,7 @@ export const ActionName = {
|
||||
GoCQHTTP_GetGroupRootFiles: 'get_group_root_files',
|
||||
GoCQHTTP_GetGroupFilesByFolder: 'get_group_files_by_folder',
|
||||
GOCQHTTP_GetGroupFileUrl: 'get_group_file_url',
|
||||
GOCQHTTP_MoveGroupFile: 'move_group_file',
|
||||
GOCQHTTP_UploadPrivateFile: 'upload_private_file',
|
||||
// GOCQHTTP_ReloadEventFilter : 'reload_event_filter',
|
||||
GoCQHTTP_DownloadFile: 'download_file',
|
||||
|
Reference in New Issue
Block a user