managarten/services/matrix-stats-bot/src/scheduler/report.scheduler.ts
Claude 7c5e9e3c49
feat(matrix): add Stats Bot and Project Doc Bot services
Complete GDPR-compliant bot suite for Matrix:

matrix-stats-bot (port 3312):
- Analytics reports from Umami
- Commands: !stats, !today, !week, !realtime, !users
- Scheduled daily/weekly reports to Matrix room

matrix-project-doc-bot (port 3313):
- Project documentation with photos, voice, text
- Voice transcription via OpenAI Whisper
- Blog generation with 5 styles (casual, technical, tutorial, social, story)
- Commands: !new, !projects, !switch, !status, !generate, !export
- Uses PostgreSQL + S3 (MinIO) for storage

Changes:
- docker-compose.macmini.yml: Added both Matrix bots
- health-check.sh: Added health checks for both bots

Environment variables required:
- MATRIX_STATS_BOT_TOKEN, MATRIX_PROJECT_DOC_BOT_TOKEN
- OPENAI_API_KEY (for Project Doc Bot)

https://claude.ai/code/session_01E3r5aFW3YLAhEJfsL2ryhv
2026-01-28 00:44:28 +00:00

30 lines
1.1 KiB
TypeScript

import { Injectable, Logger } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';
import { MatrixService } from '../bot/matrix.service';
import { AnalyticsService } from '../analytics/analytics.service';
@Injectable()
export class ReportScheduler {
private readonly logger = new Logger(ReportScheduler.name);
constructor(
private readonly matrixService: MatrixService,
private readonly analyticsService: AnalyticsService
) {}
// Daily report at 9:00 AM Berlin time
@Cron('0 9 * * *', { timeZone: 'Europe/Berlin' })
async sendDailyReport() {
this.logger.log('Sending daily report...');
const report = await this.analyticsService.generateDailyReport();
await this.matrixService.sendScheduledReport(`📅 **Täglicher Report**\n\n${report}`);
}
// Weekly report on Monday at 9:00 AM Berlin time
@Cron('0 9 * * 1', { timeZone: 'Europe/Berlin' })
async sendWeeklyReport() {
this.logger.log('Sending weekly report...');
const report = await this.analyticsService.generateWeeklyReport();
await this.matrixService.sendScheduledReport(`📅 **Wöchentlicher Report**\n\n${report}`);
}
}