feat: add Feishu notifier for message notifications

- Implemented a lightweight notification library with support for multiple channels.
- Added FeishuNotifier class to send messages via Feishu webhook.
- Created README documentation for usage and configuration of Feishu notifier.
- Added TypeScript configuration for the project.
- Included a test script for verifying Feishu message notifications.
This commit is contained in:
2026-01-08 16:43:53 +08:00
commit 6cf949bcd1
14 changed files with 1374 additions and 0 deletions

3
src/core/index.ts Normal file
View File

@@ -0,0 +1,3 @@
export interface Notification {
notify(message: string): void;
}

1
src/index.ts Normal file
View File

@@ -0,0 +1 @@
export * from './notiify/feishu.ts'

34
src/notiify/feishu.ts Normal file
View File

@@ -0,0 +1,34 @@
import { Notification } from '../core/index.ts';
interface FeishuConfig {
webhook: string;
}
export class FeishuNotifier implements Notification {
private webhook: string;
constructor(config: FeishuConfig) {
this.webhook = config.webhook;
}
async notify(message: string): Promise<void> {
const payload = {
msg_type: 'text',
content: {
text: message,
},
};
const response = await fetch(this.webhook, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
if (!response.ok) {
throw new Error(`飞书推送失败: ${response.statusText}`);
}
}
}