mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-24 17:10:08 +08:00
34 lines
906 B
TypeScript
34 lines
906 B
TypeScript
import { randomUUID } from "crypto";
|
|
export interface NTEventType {
|
|
EventName: string,
|
|
EventFunction: Function,
|
|
ListenerName: string,
|
|
ListenerFunction: Function
|
|
}
|
|
export class NTEvent<T> {
|
|
EventData: NTEventType;
|
|
EventTask: Map<string, Function> = new Map<string, Function>();
|
|
constructor(params: NTEventType) {
|
|
params.ListenerFunction = this.DispatcherListener;
|
|
this.EventData = params;
|
|
}
|
|
async DispatcherListener(...args: any[]) {
|
|
for (let task of this.EventTask.values()) {
|
|
if (task instanceof Promise) {
|
|
await task(...args);
|
|
}
|
|
task(...args);
|
|
}
|
|
}
|
|
async Call(params: T & { checker?: Function }) {
|
|
|
|
}
|
|
async CallWaitTwice(params: T & { checker?: Function }) {
|
|
|
|
}
|
|
async CallWaitVoid(param: T & { checker?: Function }) {
|
|
|
|
}
|
|
}
|
|
|