mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-12 00:16:08 +08:00
通过修改push_config实现自定义推送服务
This commit is contained in:
parent
3a247ab407
commit
ef2d20f54c
|
@ -113,11 +113,14 @@ push_config = {
|
|||
'WEBHOOK_METHOD': '', # 自定义通知 请求方法
|
||||
'WEBHOOK_CONTENT_TYPE': '' # 自定义通知 content-type
|
||||
}
|
||||
|
||||
push_config_keys = tuple(push_config.keys()) # 保存push_config的键
|
||||
|
||||
notify_function = []
|
||||
# fmt: on
|
||||
|
||||
# 首先读取 面板变量 或者 github action 运行变量
|
||||
for k in push_config:
|
||||
for k in push_config_keys:
|
||||
if os.getenv(k):
|
||||
v = os.getenv(k)
|
||||
push_config[k] = v
|
||||
|
@ -895,8 +898,20 @@ def add_notify_function():
|
|||
if push_config.get("WEBHOOK_URL") and push_config.get("WEBHOOK_METHOD"):
|
||||
notify_function.append(custom_notify)
|
||||
|
||||
if not notify_function:
|
||||
print(f"无推送渠道,请检查通知变量是否正确")
|
||||
|
||||
|
||||
def send(title: str, content: str, ignore_default_config: bool = False, **kwargs):
|
||||
if ignore_default_config and kwargs:
|
||||
global push_config
|
||||
push_config = {} # 清空从环境变量获取的配置
|
||||
|
||||
if kwargs:
|
||||
for k in kwargs:
|
||||
if k in push_config_keys:
|
||||
push_config[k] = kwargs.get(k)
|
||||
|
||||
def send(title: str, content: str) -> None:
|
||||
if not content:
|
||||
print(f"{title} 推送内容为空!")
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue
Block a user