36 lines
738 B
TypeScript
36 lines
738 B
TypeScript
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<boolean> {
|
|
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) {
|
|
console.error(`飞书推送失败: ${response.statusText}`);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
} |