mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:21:09 +02:00
♻️ refactor: migrate 19 Matrix bots to shared HealthController
- All bots now use HealthController from @manacore/matrix-bot-common - Deleted 19 duplicate health.controller.ts files - Added IConfigService interface for @nestjs/config v3/v4 compatibility - matrix-stats-bot migrated to use BaseMatrixService as example - All 19 bots pass type-check This consolidation eliminates ~400 lines of duplicate health check code. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
145b0b6599
commit
83f2d63f56
62 changed files with 483 additions and 331 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { Logger, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { Logger, type OnModuleInit, type OnModuleDestroy } from '@nestjs/common';
|
||||
import {
|
||||
MatrixClient,
|
||||
SimpleFsStorageProvider,
|
||||
|
|
@ -8,7 +7,7 @@ import {
|
|||
} from 'matrix-bot-sdk';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { MatrixBotConfig, MatrixRoomEvent, isTextMessage, isAudioMessage } from './types';
|
||||
import { type MatrixBotConfig, type MatrixRoomEvent, isTextMessage, isAudioMessage } from './types';
|
||||
import { markdownToHtml } from '../markdown/markdown-formatter';
|
||||
|
||||
/**
|
||||
|
|
@ -42,13 +41,20 @@ import { markdownToHtml } from '../markdown/markdown-formatter';
|
|||
* }
|
||||
* ```
|
||||
*/
|
||||
/**
|
||||
* Interface for config service to support both @nestjs/config v3 and v4
|
||||
*/
|
||||
export interface IConfigService {
|
||||
get<T = unknown>(propertyPath: string): T | undefined;
|
||||
}
|
||||
|
||||
export abstract class BaseMatrixService implements OnModuleInit, OnModuleDestroy {
|
||||
protected readonly logger = new Logger(this.constructor.name);
|
||||
protected client!: MatrixClient;
|
||||
protected botUserId: string = '';
|
||||
protected botUserId = '';
|
||||
protected readonly allowedRooms: string[];
|
||||
|
||||
constructor(protected configService: ConfigService) {
|
||||
constructor(protected configService: IConfigService) {
|
||||
this.allowedRooms = this.getConfig().allowedRooms;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export { BaseMatrixService } from './base-matrix.service';
|
||||
export { BaseMatrixService, type IConfigService } from './base-matrix.service';
|
||||
export {
|
||||
type MatrixBotConfig,
|
||||
type MatrixRoomEvent,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
// Base Matrix Service
|
||||
export {
|
||||
BaseMatrixService,
|
||||
type IConfigService,
|
||||
type MatrixBotConfig,
|
||||
type MatrixRoomEvent,
|
||||
type MatrixMessageEvent,
|
||||
|
|
@ -46,12 +47,7 @@ export {
|
|||
} from './message';
|
||||
|
||||
// Markdown Utilities
|
||||
export {
|
||||
markdownToHtml,
|
||||
escapeHtml,
|
||||
formatNumberedList,
|
||||
formatBulletList,
|
||||
} from './markdown';
|
||||
export { markdownToHtml, escapeHtml, formatNumberedList, formatBulletList } from './markdown';
|
||||
|
||||
// Keyword Detection
|
||||
export {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue