From 11ea228ceaaec2adf5d3950575ecfc3f761097e4 Mon Sep 17 00:00:00 2001 From: Clansty Date: Sun, 15 Dec 2024 17:15:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20napcat=20=E7=BE=A4=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/src/client/NapCatClient/entity.ts | 33 +++++++++++++++----------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/main/src/client/NapCatClient/entity.ts b/main/src/client/NapCatClient/entity.ts index 65f05e3..be2544e 100644 --- a/main/src/client/NapCatClient/entity.ts +++ b/main/src/client/NapCatClient/entity.ts @@ -168,9 +168,27 @@ export class NapCatFriend extends NapCatUser implements Friend { } } +class NapCatGFS implements GroupFs { + public constructor(private client: NapCatClient, private gid: number) { + } + + async upload(file: string | Buffer | Uint8Array, pid?: string, name?: string, callback?: (percentage: string) => void) { + if (typeof file !== 'string') { + throw new Error('TODO'); + } + return await this.client.callApi('upload_group_file', { + group_id: this.gid, + file, + name, + folder_id: pid, + }); + } +} + export class NapCatGroup extends NapCatEntity implements Group { readonly dm = false; name: string; + fs: GroupFs; is_owner = false; is_admin = false; @@ -179,6 +197,7 @@ export class NapCatGroup extends NapCatEntity implements Group { public readonly gid: number) { super(client); this.logger = getLogger(`NapCatGroup - ${client.id} - ${gid}`); + this.fs = new NapCatGFS(client, gid); } public static async create(client: NapCatClient, gid: number) { @@ -248,20 +267,6 @@ export class NapCatGroup extends NapCatEntity implements Group { } } - fs: GroupFs = { - async upload(file: string | Buffer | Uint8Array, pid?: string, name?: string, callback?: (percentage: string) => void) { - if (typeof file !== 'string') { - throw new Error('TODO'); - } - return await this.client.callApi('upload_group_file', { - group_id: this.gid, - file, - name, - folder_id: pid, - }); - }, - }; - async getAllMemberInfo() { // lib bug return await this.client.callApi('get_group_member_list', { group_id: this.gid }) as unknown as WSSendReturn['get_group_member_info'][];