diff --git a/src/core/api.ts b/src/core/api.ts index 01e3417..112b533 100644 --- a/src/core/api.ts +++ b/src/core/api.ts @@ -91,6 +91,19 @@ export class QQBotApi extends EventEmitter { } } + /** + * delete请求 + * @param url 请求地址 + * @param options 请求参数 + */ + async delete (url: string) { + try { + return await got.delete(url, { headers: this.headers }) + } catch (error: any) { + logger.error(`[got] 请求错误: ${JSON.stringify(error.response.body)}`) + } + } + /** * 获取调用凭证 * @param clientSecret 开发者的Secret @@ -340,6 +353,18 @@ export class QQBotApi extends EventEmitter { return JSON.parse(result.body) as SendMessageResponse } + /** + * 撤回消息 + * @param openid 用户、群openid + * @param type 请求路径类型 + * @param message_id 消息id + */ + async recallMessage (openid: string, type: PathType, message_id: string) { + const url = this.buildUrl(openid, type, V2ApiType.Message) + const result = await this.delete(`${url}/${message_id}`) as any + return result.status === 200 + } + /** * 构建发送文本消息请求参数 */ diff --git a/src/core/index.ts b/src/core/index.ts index ac69a55..0a700f9 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -350,6 +350,10 @@ export class AdapterQQBot implements KarinAdapter { return { account_uid: 'input', account_uin: 'input', account_name: 'input' } } + async RecallMessage (contact: Contact, message_id: string) { + return await this.super.recallMessage(contact.peer, contact.scene === 'group' ? PathType.Groups : PathType.Friends, message_id) + } + async GetEssenceMessageList (): Promise { throw new Error('Method not implemented.') } async DownloadForwardMessage (): Promise { throw new Error('Method not implemented.') } async SetEssenceMessage (): Promise { throw new Error('Method not implemented.') } @@ -363,7 +367,6 @@ export class AdapterQQBot implements KarinAdapter { async UploadForwardMessage (): Promise { throw new Error('Method not implemented.') } async sendForwardMessage (): Promise { throw new Error('Method not implemented.') } async SendMessageByResId (): Promise { throw new Error('Method not implemented.') } - async RecallMessage (): Promise { throw new Error('Method not implemented.') } async GetMessage (): Promise { throw new Error('Method not implemented.') } async GetHistoryMessage (): Promise { throw new Error('Method not implemented.') } async VoteUser (): Promise { throw new Error('Method not implemented.') }