diff --git a/src/core/plugins.loader.ts b/src/core/plugins.loader.ts index f7f230e..4326d20 100644 --- a/src/core/plugins.loader.ts +++ b/src/core/plugins.loader.ts @@ -8,6 +8,7 @@ import moment from 'moment' import path from 'node:path' import Runtime from './plugins/runtime.js' import Handler from './plugins/handler.js' +import { EventType } from './plugins/types.js' /** * 加载插件 @@ -267,7 +268,7 @@ class PluginsLoader { * 参数文档 https://oicqjs.github.io/oicq/interfaces/GroupMessageEvent.html * @param e icqq Events */ - async deal(e) { + async deal(e: EventType) { /** * */ @@ -658,7 +659,7 @@ class PluginsLoader { * 处理回复,捕获发送失败异常 * @param e */ - reply(e) { + reply(e: EventType) { /** * */ @@ -927,7 +928,7 @@ class PluginsLoader { * @param e * @returns */ - checkLimit(e) { + checkLimit(e: EventType) { /** 禁言中 */ if (e.isGroup && e?.group?.mute_left > 0) return false /** @@ -938,7 +939,7 @@ class PluginsLoader { /** * */ - let config = cfg.getGroup(e.group_id) + let config = cfg.getGroup(String(e.group_id)) /** * @@ -984,7 +985,7 @@ class PluginsLoader { * @param e * @returns */ - setLimit(e) { + setLimit(e: EventType) { /** * */ @@ -992,7 +993,7 @@ class PluginsLoader { /** * */ - let config = cfg.getGroup(e.group_id) + let config = cfg.getGroup(String(e.group_id)) /** * @@ -1017,10 +1018,10 @@ class PluginsLoader { * @param e * @returns */ - onlyReplyAt(e) { + onlyReplyAt(e: EventType) { if (!e.message || e.isPrivate) return true - let groupCfg = cfg.getGroup(e.group_id) + let groupCfg = cfg.getGroup(String(e.group_id)) /** 模式0,未开启前缀 */ if (groupCfg.onlyReplyAt == 0 || !groupCfg.botAlias) return true @@ -1042,7 +1043,7 @@ class PluginsLoader { * @param e * @returns */ - checkGuildMsg(e) { + checkGuildMsg(e: EventType) { return cfg.getOther().disableGuildMsg && e.detail_type == 'guild' } @@ -1051,7 +1052,7 @@ class PluginsLoader { * @param e * @returns */ - checkBlack(e) { + checkBlack(e: EventType) { /** * */ diff --git a/src/core/plugins/types.ts b/src/core/plugins/types.ts index 01bbe84..d202da8 100644 --- a/src/core/plugins/types.ts +++ b/src/core/plugins/types.ts @@ -1,5 +1,6 @@ -import { type GroupMessage, Client } from 'icqq' -import { PrivateMessage } from 'oicq' +import { type GroupMessage } from 'icqq' +// import { Client } from 'icqq' +// import { PrivateMessage } from 'oicq' interface EventTypeBase { /** @@ -29,7 +30,7 @@ interface EventTypeBase { file: any; /** */ - bot: typeof Client.prototype; + bot: any; /** * */ @@ -42,10 +43,38 @@ interface EventTypeBase { * */ logText: any; -} + /** + * + */ + isSr?: boolean + /** + * + */ + isGs?: boolean + /** + * + */ + self_id?: any + /** + * + */ + game?: any + + /** + * + */ + logFnc?: any + + /** + * + */ + detail_type?: any + + /** + * + */ + at?: any -interface EventTypeGroup extends EventTypeBase, GroupMessage { - isGroup: true; /** * 群号 */ @@ -53,7 +82,7 @@ interface EventTypeGroup extends EventTypeBase, GroupMessage { /** * 群名 */ - group_name:string + group_name: string /** * */ @@ -62,18 +91,48 @@ interface EventTypeGroup extends EventTypeBase, GroupMessage { recallMsg: (...arg: any[]) => any; getMemberMap: any; quit: any; + mute_left: any + + pickMember: any + + + sendMsg: any }; /** * */ atBot: any; + + /** + * + */ + + isPrivate?: any + + /** + * + */ + hasAlias?: any + + /** + * + */ + + replyNew?: any + + /** + * + */ + + isGuild?: any + + /** + * + */ + friend?: any } -interface EventTypePrivate extends EventTypeBase, PrivateMessage { - isGroup: false; -} - -export type EventType = EventTypeGroup | EventTypePrivate; +export interface EventType extends EventTypeBase, GroupMessage { } /** * 函数式回调类型