import { Notifier, NotifyParams, NotifyResult, NotifierParam } from './notifier.types'; const params: NotifierParam[] = [ { key: 'webhook_url', label: 'Webhook URL', type: 'url', required: true, placeholder: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx' }, { key: 'title', label: '标题', type: 'text', default: 'CloudSearch', required: false }, { key: 'content', label: '内容', type: 'text', required: true }, { key: 'level', label: '级别', type: 'text', default: 'info', required: false }, ]; export const wechatWorkBotNotifier: Notifier = { name: 'wechat_work_bot', label: '企业微信机器人', params, async notify(params: NotifyParams): Promise { try { const content = `## ${params.title || 'CloudSearch'}\n${params.content || ''}`; const resp = await fetch(params.webhook_url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ msgtype: 'markdown', markdown: { content }, }), }); const data: any = await resp.json(); if (data.errcode === 0) return { success: true, message: '企业微信推送成功' }; return { success: false, message: data.errmsg || `HTTP ${resp.status}` }; } catch (err: any) { return { success: false, message: err.message }; } }, };