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; + /** * 函数式回调类型 */