Files
skills/notify/feishu/index.ts
xiongxiao 884b1cd2dc init
2026-03-17 14:27:33 +08:00

39 lines
967 B
TypeScript

const FEISHU_NOTIFY_WEBHOOK_URL = process.env.FEISHU_NOTIFY_WEBHOOK_URL;
export async function feishuNotify(message: string) {
if (!FEISHU_NOTIFY_WEBHOOK_URL) {
console.warn('Feishu notify webhook URL is not set.');
return;
}
try {
const response = await fetch(FEISHU_NOTIFY_WEBHOOK_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
msg_type: 'text',
content: {
text: message,
},
}),
});
if (!response.ok) {
console.error('Failed to send Feishu notification:', response.statusText);
}
} catch (error) {
console.error('Error sending Feishu notification:', error);
}
}
if (import.meta.main) {
const args = process.argv.slice(2);
if (args.length > 0) {
const message = args.join(' \n');
feishuNotify(message);
} else {
console.warn('No message provided for Feishu notification.');
}
}