From 14a23d5bf2a3531d64495c361e490caa90fc49db Mon Sep 17 00:00:00 2001 From: ningmengchongshui <916415899@qq.com> Date: Wed, 12 Jun 2024 22:36:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/plugins/index.ts | 14 +++++++- src/core/plugins/types.ts | 67 ++++++++++++++++++++++++++++++++------- 2 files changed, 68 insertions(+), 13 deletions(-) diff --git a/src/core/plugins/index.ts b/src/core/plugins/index.ts index 9f7cf20..677fc37 100644 --- a/src/core/plugins/index.ts +++ b/src/core/plugins/index.ts @@ -72,11 +72,23 @@ export class Plugin { name: PluginSuperType['name'] = 'your-plugin' dsc: PluginSuperType['dsc'] = '无' task: PluginSuperType['task'] = null + /** + * 指令集 + */ rule: PluginSuperType['rule'] = [] + /** + * 事件 + */ event: PluginSuperType['event'] = 'message' + /** + * 优先级 + */ priority: PluginSuperType['priority'] = 9999 namespace: PluginSuperType['namespace'] = null handler: PluginSuperType['handler'] = null + /** + * 事件 + */ e: EventType /** @@ -159,7 +171,7 @@ export class Plugin { * @returns */ conKey(isGroup = false) { - if (isGroup) { + if (isGroup && this.e.isGroup) { return `${this.name}.${this.group_id || this.groupId || this.e.group_id}` } else { return `${this.name}.${this.user_id || this.userId || this.e.user_id}` diff --git a/src/core/plugins/types.ts b/src/core/plugins/types.ts index bc737ce..8e93a61 100644 --- a/src/core/plugins/types.ts +++ b/src/core/plugins/types.ts @@ -1,31 +1,74 @@ -import { type GroupMessage } from 'icqq' +import { type GroupMessage, Client } from 'icqq' +import { PrivateMessage } from 'oicq' -/** - * 机器人事件类型 - */ -export interface EventType extends GroupMessage { +interface EventTypeBase { /** * 是否是主人 */ - isMaster: boolean + isMaster: boolean; /** - * 群聊 + * 是否是群里 */ - group: { - recallMsg: (...arg) => any - } + isGroup: boolean; /** * 用户消息 */ - msg: string + msg: string; /** * 消息发送 * @param arg * @returns */ - reply: (...arg) => Promise + reply: (...arg: any[]) => Promise; + /** + * @deprecated 已废弃 + */ + file: any; + /** + * @deprecated 已废弃 + */ + bot: typeof Client.prototype; + /** + * + */ + approve: any; + /** + * + */ + member: any; + /** + * + */ + logText: any; } +interface EventTypeGroup extends EventTypeBase, GroupMessage { + isGroup: true; + /** + * 群号 + */ + group_id: number; + /** + * @deprecated 已废弃 + */ + group: { + is_owner: any; + recallMsg: (...arg: any[]) => any; + getMemberMap: any; + quit: any; + }; + /** + * + */ + atBot: any; +} + +interface EventTypePrivate extends EventTypeBase, PrivateMessage { + isGroup: false; +} + +export type EventType = EventTypeGroup | EventTypePrivate; + /** * 函数式回调类型 */