Introduced a new eslint.config.js using neostandard and added related devDependencies. Updated codebase for consistent formatting, spacing, and function declarations. Minor refactoring and cleanup across multiple files to improve readability and maintain code style compliance.
29 lines
814 B
TypeScript
29 lines
814 B
TypeScript
import 'reflect-metadata';
|
|
import { Container, injectable } from 'inversify';
|
|
import { NapCatCore } from '../..';
|
|
import { TypedEventEmitter } from './typeEvent';
|
|
|
|
export const container = new Container();
|
|
|
|
export const ReceiverServiceRegistry = new Map<string, new (...args: any[]) => ServiceBase>();
|
|
|
|
export abstract class ServiceBase {
|
|
get core (): NapCatCore {
|
|
return container.get(NapCatCore);
|
|
}
|
|
|
|
get event () {
|
|
return container.get(TypedEventEmitter);
|
|
}
|
|
|
|
abstract handler (seq: number, hex_data: string): Promise<void> | void;
|
|
}
|
|
|
|
export function ReceiveService (serviceName: string) {
|
|
return function <T extends new (...args: any[]) => ServiceBase>(constructor: T) {
|
|
injectable()(constructor);
|
|
ReceiverServiceRegistry.set(serviceName, constructor);
|
|
return constructor;
|
|
};
|
|
}
|