update: 填补类型声明

This commit is contained in:
ningmengchongshui 2024-06-14 11:01:30 +08:00
parent 503942cc0d
commit 19a54257a6
2 changed files with 82 additions and 22 deletions

View File

@ -8,6 +8,7 @@ import moment from 'moment'
import path from 'node:path' import path from 'node:path'
import Runtime from './plugins/runtime.js' import Runtime from './plugins/runtime.js'
import Handler from './plugins/handler.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 * https://oicqjs.github.io/oicq/interfaces/GroupMessageEvent.html
* @param e icqq Events * @param e icqq Events
*/ */
async deal(e) { async deal(e: EventType) {
/** /**
* *
*/ */
@ -658,7 +659,7 @@ class PluginsLoader {
* , * ,
* @param e * @param e
*/ */
reply(e) { reply(e: EventType) {
/** /**
* *
*/ */
@ -927,7 +928,7 @@ class PluginsLoader {
* @param e * @param e
* @returns * @returns
*/ */
checkLimit(e) { checkLimit(e: EventType) {
/** 禁言中 */ /** 禁言中 */
if (e.isGroup && e?.group?.mute_left > 0) return false 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 * @param e
* @returns * @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 * @param e
* @returns * @returns
*/ */
onlyReplyAt(e) { onlyReplyAt(e: EventType) {
if (!e.message || e.isPrivate) return true if (!e.message || e.isPrivate) return true
let groupCfg = cfg.getGroup(e.group_id) let groupCfg = cfg.getGroup(String(e.group_id))
/** 模式0未开启前缀 */ /** 模式0未开启前缀 */
if (groupCfg.onlyReplyAt == 0 || !groupCfg.botAlias) return true if (groupCfg.onlyReplyAt == 0 || !groupCfg.botAlias) return true
@ -1042,7 +1043,7 @@ class PluginsLoader {
* @param e * @param e
* @returns * @returns
*/ */
checkGuildMsg(e) { checkGuildMsg(e: EventType) {
return cfg.getOther().disableGuildMsg && e.detail_type == 'guild' return cfg.getOther().disableGuildMsg && e.detail_type == 'guild'
} }
@ -1051,7 +1052,7 @@ class PluginsLoader {
* @param e * @param e
* @returns * @returns
*/ */
checkBlack(e) { checkBlack(e: EventType) {
/** /**
* *
*/ */

View File

@ -1,5 +1,6 @@
import { type GroupMessage, Client } from 'icqq' import { type GroupMessage } from 'icqq'
import { PrivateMessage } from 'oicq' // import { Client } from 'icqq'
// import { PrivateMessage } from 'oicq'
interface EventTypeBase { interface EventTypeBase {
/** /**
@ -29,7 +30,7 @@ interface EventTypeBase {
file: any; file: any;
/** /**
*/ */
bot: typeof Client.prototype; bot: any;
/** /**
* *
*/ */
@ -42,10 +43,38 @@ interface EventTypeBase {
* *
*/ */
logText: any; 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; recallMsg: (...arg: any[]) => any;
getMemberMap: any; getMemberMap: any;
quit: any; quit: any;
mute_left: any
pickMember: any
sendMsg: any
}; };
/** /**
* *
*/ */
atBot: any; atBot: any;
/**
*
*/
isPrivate?: any
/**
*
*/
hasAlias?: any
/**
*
*/
replyNew?: any
/**
*
*/
isGuild?: any
/**
*
*/
friend?: any
} }
interface EventTypePrivate extends EventTypeBase, PrivateMessage { export interface EventType extends EventTypeBase, GroupMessage { }
isGroup: false;
}
export type EventType = EventTypeGroup | EventTypePrivate;
/** /**
* *