mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
feat: 重命名群文件
This commit is contained in:
@@ -161,6 +161,13 @@ export class PacketOperationContext {
|
|||||||
return res.move.retCode;
|
return res.move.retCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async RenameGroupFile(groupUin: number, fileUUID: string, currentParentDirectory: string, newName: string) {
|
||||||
|
const req = trans.RenameGroupFile.build(groupUin, fileUUID, currentParentDirectory, newName);
|
||||||
|
const resp = await this.context.client.sendOidbPacket(req, true);
|
||||||
|
const res = trans.RenameGroupFile.parse(resp);
|
||||||
|
return res.rename.retCode;
|
||||||
|
}
|
||||||
|
|
||||||
async GetGroupFileUrl(groupUin: number, fileUUID: string) {
|
async GetGroupFileUrl(groupUin: number, fileUUID: string) {
|
||||||
const req = trans.DownloadGroupFile.build(groupUin, fileUUID);
|
const req = trans.DownloadGroupFile.build(groupUin, fileUUID);
|
||||||
const resp = await this.context.client.sendOidbPacket(req, true);
|
const resp = await this.context.client.sendOidbPacket(req, true);
|
||||||
|
34
src/core/packet/transformer/action/RenameGroupFile.ts
Normal file
34
src/core/packet/transformer/action/RenameGroupFile.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
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 RenameGroupFile extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0x6D6Response> {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
build(groupUin: number, fileUUID: string, currentParentDirectory: string, newName: string): OidbPacket {
|
||||||
|
const body = new NapProtoMsg(proto.OidbSvcTrpcTcp0x6D6).encode({
|
||||||
|
rename: {
|
||||||
|
groupUin: groupUin,
|
||||||
|
busId: 102,
|
||||||
|
fileId: fileUUID,
|
||||||
|
parentFolder: currentParentDirectory,
|
||||||
|
newFileName: newName,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return OidbBase.build(0x6D6, 4, body, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
parse(data: Buffer) {
|
||||||
|
const oidbBody = OidbBase.parse(data).body;
|
||||||
|
const res = new NapProtoMsg(proto.OidbSvcTrpcTcp0x6D6Response).decode(oidbBody);
|
||||||
|
if (res.rename.retCode !== 0) {
|
||||||
|
throw new Error(`sendGroupFileRenameReq error: ${res.rename.clientWording} (code=${res.rename.retCode})`);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new RenameGroupFile();
|
@@ -7,3 +7,4 @@ export { default as SendPoke } from './SendPoke';
|
|||||||
export { default as SetSpecialTitle } from './SetSpecialTitle';
|
export { default as SetSpecialTitle } from './SetSpecialTitle';
|
||||||
export { default as ImageOCR } from './ImageOCR';
|
export { default as ImageOCR } from './ImageOCR';
|
||||||
export { default as MoveGroupFile } from './MoveGroupFile';
|
export { default as MoveGroupFile } from './MoveGroupFile';
|
||||||
|
export { default as RenameGroupFile } from './RenameGroupFile';
|
||||||
|
@@ -13,7 +13,7 @@ const SchemaData = Type.Object({
|
|||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
interface MoveGroupFileResponse {
|
interface MoveGroupFileResponse {
|
||||||
retcode: number;
|
ok: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MoveGroupFile extends GetPacketStatusDepends<Payload, MoveGroupFileResponse> {
|
export class MoveGroupFile extends GetPacketStatusDepends<Payload, MoveGroupFileResponse> {
|
||||||
@@ -23,8 +23,9 @@ export class MoveGroupFile extends GetPacketStatusDepends<Payload, MoveGroupFile
|
|||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const contextMsgFile = FileNapCatOneBotUUID.decode(payload.file_id) || FileNapCatOneBotUUID.decodeModelId(payload.file_id);
|
const contextMsgFile = FileNapCatOneBotUUID.decode(payload.file_id) || FileNapCatOneBotUUID.decodeModelId(payload.file_id);
|
||||||
if (contextMsgFile?.fileUUID) {
|
if (contextMsgFile?.fileUUID) {
|
||||||
|
await this.core.apis.PacketApi.pkt.operation.MoveGroupFile(+payload.group_id, contextMsgFile.fileUUID, payload.current_parent_directory, payload.target_parent_directory);
|
||||||
return {
|
return {
|
||||||
retcode: await this.core.apis.PacketApi.pkt.operation.MoveGroupFile(+payload.group_id, contextMsgFile.fileUUID, payload.current_parent_directory, payload.target_parent_directory)
|
ok: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
throw new Error('real fileUUID not found!');
|
throw new Error('real fileUUID not found!');
|
||||||
|
33
src/onebot/action/extends/RenameGroupFile.ts
Normal file
33
src/onebot/action/extends/RenameGroupFile.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
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(),
|
||||||
|
new_name: Type.String(),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
|
interface RenameGroupFileResponse {
|
||||||
|
ok: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RenameGroupFile extends GetPacketStatusDepends<Payload, RenameGroupFileResponse> {
|
||||||
|
override actionName = ActionName.RenameGroupFile;
|
||||||
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
|
async _handle(payload: Payload) {
|
||||||
|
const contextMsgFile = FileNapCatOneBotUUID.decode(payload.file_id) || FileNapCatOneBotUUID.decodeModelId(payload.file_id);
|
||||||
|
if (contextMsgFile?.fileUUID) {
|
||||||
|
await this.core.apis.PacketApi.pkt.operation.RenameGroupFile(+payload.group_id, contextMsgFile.fileUUID, payload.current_parent_directory, payload.new_name);
|
||||||
|
return {
|
||||||
|
ok: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
throw new Error('real fileUUID not found!');
|
||||||
|
}
|
||||||
|
}
|
@@ -111,6 +111,7 @@ import { GetUnidirectionalFriendList } from './extends/GetUnidirectionalFriendLi
|
|||||||
import SetGroupRemark from './extends/SetGroupRemark';
|
import SetGroupRemark from './extends/SetGroupRemark';
|
||||||
import { MoveGroupFile } from './extends/MoveGroupFile';
|
import { MoveGroupFile } from './extends/MoveGroupFile';
|
||||||
import { TransGroupFile } from './extends/TransGroupFile';
|
import { TransGroupFile } from './extends/TransGroupFile';
|
||||||
|
import { RenameGroupFile } from './extends/RenameGroupFile';
|
||||||
|
|
||||||
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
||||||
|
|
||||||
@@ -135,6 +136,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
|||||||
new SendGroupSign(obContext, core),
|
new SendGroupSign(obContext, core),
|
||||||
new GetClientkey(obContext, core),
|
new GetClientkey(obContext, core),
|
||||||
new MoveGroupFile(obContext, core),
|
new MoveGroupFile(obContext, core),
|
||||||
|
new RenameGroupFile(obContext, core),
|
||||||
new TransGroupFile(obContext, core),
|
new TransGroupFile(obContext, core),
|
||||||
// onebot11
|
// onebot11
|
||||||
new SendLike(obContext, core),
|
new SendLike(obContext, core),
|
||||||
|
@@ -132,6 +132,7 @@ export const ActionName = {
|
|||||||
|
|
||||||
MoveGroupFile: 'move_group_file',
|
MoveGroupFile: 'move_group_file',
|
||||||
TransGroupFile: 'trans_group_file',
|
TransGroupFile: 'trans_group_file',
|
||||||
|
RenameGroupFile: 'rename_group_file',
|
||||||
|
|
||||||
GetGuildList: 'get_guild_list',
|
GetGuildList: 'get_guild_list',
|
||||||
GetGuildProfile: 'get_guild_service_profile',
|
GetGuildProfile: 'get_guild_service_profile',
|
||||||
|
Reference in New Issue
Block a user