Skip to content

Commit 3190b07

Browse files
committed
消息内容可为空
1 parent a449145 commit 3190b07

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

notifier.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def _send_wecom(config: dict, title: str, content: str):
9696
agentid=config['agentid']
9797
)
9898

99-
message = f"{title}\n{content}"
99+
message = title if not content or not content.strip() else f"{title}\n{content}"
100100
result = wn.send_msg(message)
101101
return True
102102

@@ -106,7 +106,7 @@ def _send_wecom_webhook(config: dict, title: str, content: str):
106106
from ANotify import Nwecom
107107

108108
wn_webhook = Nwecom.WxWebhookNotify(config['webhook_url'])
109-
message = f"{title}\n{content}"
109+
message = title if not content or not content.strip() else f"{title}\n{content}"
110110
result = wn_webhook.send_msg(message)
111111
return True
112112

@@ -121,7 +121,7 @@ def _send_feishu(config: dict, title: str, content: str):
121121
)
122122

123123
receiver_type = getattr(Nfeishu.ReceiverType, config['receiver_type'])
124-
message = f"{title}\n\n{content}"
124+
message = title if not content or not content.strip() else f"{title}\n\n{content}"
125125
result = feishu.send_msg(receiver_type, config['receiver_id'], message)
126126
return True
127127

@@ -131,7 +131,7 @@ def _send_feishu_webhook(config: dict, title: str, content: str):
131131
from ANotify import Nfeishu
132132

133133
feishu_webhook = Nfeishu.FeishuWebhookNotify(config['webhook_url'])
134-
message = f"{title}\n\n{content}"
134+
message = title if not content or not content.strip() else f"{title}\n\n{content}"
135135
result = feishu_webhook.send_msg(message)
136136
return True
137137

@@ -141,7 +141,7 @@ def _send_dingtalk_webhook(config: dict, title: str, content: str):
141141
from ANotify import Ndingtalk
142142

143143
dingtalk_webhook = Ndingtalk.DingtalkWebhookNotify(config['webhook_url'])
144-
message = f"{title}\n\n{content}"
144+
message = title if not content or not content.strip() else f"{title}\n\n{content}"
145145
result = dingtalk_webhook.send_msg(message)
146146
return True
147147

static/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ <h2>创建通知任务</h2>
130130
</div>
131131

132132
<div class="form-group">
133-
<label for="content">通知内容 *</label>
134-
<textarea id="content" name="content" placeholder="请输入通知内容" required></textarea>
133+
<label for="content">通知内容</label>
134+
<textarea id="content" name="content" placeholder="请输入通知内容(可选)"></textarea>
135135
<small style="color: var(--text-muted); display: block; margin-top: 5px; line-height: 1.5;">
136136
支持变量: {{date}} 日期, {{time}} 时间, {{datetime}} 完整时间<br>
137137
{{year}} 年, {{month}} 月, {{day}} 日, {{weekday_cn}} 星期, {{timestamp}} 时间戳
@@ -427,8 +427,8 @@ <h2>编辑任务</h2>
427427
</div>
428428

429429
<div class="form-group">
430-
<label for="editContent">通知内容 *</label>
431-
<textarea id="editContent" name="content" placeholder="请输入通知内容" required></textarea>
430+
<label for="editContent">通知内容</label>
431+
<textarea id="editContent" name="content" placeholder="请输入通知内容(可选)"></textarea>
432432
<small style="color: var(--text-muted); display: block; margin-top: 5px; line-height: 1.5;">
433433
支持变量: {{date}} 日期, {{time}} 时间, {{datetime}} 完整时间<br>
434434
{{year}} 年, {{month}} 月, {{day}} 日, {{weekday_cn}} 星期, {{timestamp}} 时间戳

static/js/app.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,9 +1133,10 @@ async function submitTaskForm(e) {
11331133
}
11341134

11351135
const scheduledTimeValue = formData.get('scheduledTime');
1136+
const contentValue = formData.get('content') || '';
11361137
const taskData = {
11371138
title: formData.get('title'),
1138-
content: formData.get('content'),
1139+
content: contentValue.trim(),
11391140
// 重复任务不提交 scheduled_time,由后端根据 cron_expression 计算
11401141
scheduled_time: isRecurring ? undefined : (scheduledTimeValue ? (scheduledTimeValue.length === 16 ? `${scheduledTimeValue}:00` : scheduledTimeValue) : null),
11411142
is_recurring: isRecurring,
@@ -1609,9 +1610,10 @@ async function handleEditTaskSubmit(e) {
16091610
if (channelSelect.disabled) {
16101611
// 多渠道任务:只更新标题、内容和时间
16111612
const scheduledTimeValue = formData.get('scheduledTime');
1613+
const contentValue = formData.get('content') || '';
16121614
const taskData = {
16131615
title: formData.get('title'),
1614-
content: formData.get('content'),
1616+
content: contentValue.trim(),
16151617
scheduled_time: scheduledTimeValue ? `${scheduledTimeValue}:00` : null
16161618
};
16171619

@@ -1674,9 +1676,10 @@ async function handleEditTaskSubmit(e) {
16741676

16751677
// 构建任务数据
16761678
const scheduledTimeValue = formData.get('scheduledTime');
1679+
const contentValue = formData.get('content') || '';
16771680
const taskData = {
16781681
title: formData.get('title'),
1679-
content: formData.get('content'),
1682+
content: contentValue.trim(),
16801683
channel: channelType,
16811684
scheduled_time: scheduledTimeValue ? `${scheduledTimeValue}:00` : null,
16821685
channel_config: channelConfig

version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version: 0.9.0
1+
version: 0.9.1

0 commit comments

Comments
 (0)