update 优化发送模版

This commit is contained in:
AprilWind 2024-07-26 12:26:40 +08:00
parent 3f1f74151f
commit 47b8d31a6e
2 changed files with 17 additions and 21 deletions

View File

@ -93,11 +93,7 @@ public class InfoNotifier {
if (webHook.getEnabled()) { if (webHook.getEnabled()) {
String title = notifier.getRegistName() + notifier.getStatusName(); String title = notifier.getRegistName() + notifier.getStatusName();
String message = StringUtils.format(webHook.getTemplate(), title, notifier.getRegistName(), String message = StringUtils.format(webHook.getTemplate(), title, notifier.getRegistName(),
notifier.getInstanceId(), notifier.getStatus(), notifier.getServiceUrl(), DateUtils.getTime()); notifier.getInstanceId(), notifier.getStatusName(), notifier.getStatus(), notifier.getServiceUrl(), DateUtils.getTime());
if (StringUtils.isNotBlank(webHook.getKeywords())) {
//追加关键词到标题中
title += "——" + webHook.getKeywords();
}
try { try {
sendWebHookMessage(webHook, title, message); sendWebHookMessage(webHook, title, message);
log.info("WebHook消息已发送至: {}", webHook.getUrl()); log.info("WebHook消息已发送至: {}", webHook.getUrl());

View File

@ -76,21 +76,21 @@ notify:
to: to:
subject: 系统通知 subject: 系统通知
template: "<html><body> template: "<html><body>
<p>服务名: <b>{}</b> ({})</p> <p><b>服务名称:</b> {}</p >
<p>状态: <b>{}</b> ({})</p> <p><b>实例编号:</b> {}</p >
<p>服务IP: <b>{}</b></p> <p><b>服务状态:</b> {}({})</p >
<p>时间: <b>{}</b></p> <p><b>服务地址:</b> {}</p >
</body></html>" <p><b>发送时间:</b> {}</p >
</body></html>"
web-hook: web-hook:
enabled: false enabled: true
type: 0 type: 2
url: secret: SEC4d035df24951f00445ea16022f0db2d442fdc83b34c6ebe15a427572264f6798
secret: url: https://oapi.dingtalk.com/robot/send?access_token=81a122dbbfbcbe237acdd9e20e421059fc2e0d80bf83ded4099b0fef9f9800ef
keywords:
template: | template: |
#### **{}通知** #### **{}**
- **服务名**: {} - **服务名**: {}
- **实例ID**: {} - **实例编号**: {}
- **状态**: {} - **服务状态**: {}({})
- **服务IP**: {} - **服务地址**: {}
- **时间**: {} - **发送时间**: {}