Skip to content

Commit

Permalink
✨ 优化通知配置
Browse files Browse the repository at this point in the history
- 使用深拷贝避免修改原始配置数据
- 默认启用控制台通知配置
  • Loading branch information
Cp0204 committed Dec 4, 2024
1 parent d6593e9 commit 35fc993
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
拉库命令:

```
ql repo https://github.com/Cp0204/ChinaTelecomMonitor.git "telecom_monitor" "" "telecom_class"
ql repo https://github.com/Cp0204/ChinaTelecomMonitor.git "telecom_monitor" "" "telecom_class|notify"
```

| 环境变量 | 示例 | 备注 |
Expand Down
3 changes: 2 additions & 1 deletion notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def console(title: str, content: str) -> None:
"""
使用 控制台 推送消息。
"""
print(f"{title}\n\n{content}")
if str(push_config.get("CONSOLE")).lower() != "false":
print(f"{title}\n\n{content}")


def dingding_bot(title: str, content: str) -> None:
Expand Down
4 changes: 2 additions & 2 deletions telecom_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def send_notify(title, body):

# 如未配置 push_config 则使用青龙环境通知设置
if CONFIG_DATA.get("push_config"):
CONFIG_DATA["push_config"]["CONSOLE"] = True
notify.push_config = CONFIG_DATA["push_config"]
notify.push_config = CONFIG_DATA["push_config"].copy()
notify.push_config["CONSOLE"] = notify.push_config.get("CONSOLE", True)
notify.send(title, body)
except Exception as e:
if e:
Expand Down

0 comments on commit 35fc993

Please sign in to comment.