修复未开启一言时多余空行, 通知渠道改发送前检查

This commit is contained in:
Cp0204 2023-12-27 14:41:53 +08:00 committed by GitHub
parent 18671264bf
commit a3aaee0780
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -841,59 +841,60 @@ def one() -> str:
return res["hitokoto"] + " ----" + res["from"] return res["hitokoto"] + " ----" + res["from"]
if push_config.get("BARK_PUSH"): def add_notify_function():
if push_config.get("BARK_PUSH"):
notify_function.append(bark) notify_function.append(bark)
if push_config.get("CONSOLE"): if push_config.get("CONSOLE"):
notify_function.append(console) notify_function.append(console)
if push_config.get("DD_BOT_TOKEN") and push_config.get("DD_BOT_SECRET"): if push_config.get("DD_BOT_TOKEN") and push_config.get("DD_BOT_SECRET"):
notify_function.append(dingding_bot) notify_function.append(dingding_bot)
if push_config.get("FSKEY"): if push_config.get("FSKEY"):
notify_function.append(feishu_bot) notify_function.append(feishu_bot)
if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"): if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"):
notify_function.append(go_cqhttp) notify_function.append(go_cqhttp)
if push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"): if push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"):
notify_function.append(gotify) notify_function.append(gotify)
if push_config.get("IGOT_PUSH_KEY"): if push_config.get("IGOT_PUSH_KEY"):
notify_function.append(iGot) notify_function.append(iGot)
if push_config.get("PUSH_KEY"): if push_config.get("PUSH_KEY"):
notify_function.append(serverJ) notify_function.append(serverJ)
if push_config.get("DEER_KEY"): if push_config.get("DEER_KEY"):
notify_function.append(pushdeer) notify_function.append(pushdeer)
if push_config.get("CHAT_URL") and push_config.get("CHAT_TOKEN"): if push_config.get("CHAT_URL") and push_config.get("CHAT_TOKEN"):
notify_function.append(chat) notify_function.append(chat)
if push_config.get("PUSH_PLUS_TOKEN"): if push_config.get("PUSH_PLUS_TOKEN"):
notify_function.append(pushplus_bot) notify_function.append(pushplus_bot)
if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"): if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"):
notify_function.append(qmsg_bot) notify_function.append(qmsg_bot)
if push_config.get("QYWX_AM"): if push_config.get("QYWX_AM"):
notify_function.append(wecom_app) notify_function.append(wecom_app)
if push_config.get("QYWX_KEY"): if push_config.get("QYWX_KEY"):
notify_function.append(wecom_bot) notify_function.append(wecom_bot)
if push_config.get("TG_BOT_TOKEN") and push_config.get("TG_USER_ID"): if push_config.get("TG_BOT_TOKEN") and push_config.get("TG_USER_ID"):
notify_function.append(telegram_bot) notify_function.append(telegram_bot)
if ( if (
push_config.get("AIBOTK_KEY") push_config.get("AIBOTK_KEY")
and push_config.get("AIBOTK_TYPE") and push_config.get("AIBOTK_TYPE")
and push_config.get("AIBOTK_NAME") and push_config.get("AIBOTK_NAME")
): ):
notify_function.append(aibotk) notify_function.append(aibotk)
if ( if (
push_config.get("SMTP_SERVER") push_config.get("SMTP_SERVER")
and push_config.get("SMTP_SSL") and push_config.get("SMTP_SSL")
and push_config.get("SMTP_EMAIL") and push_config.get("SMTP_EMAIL")
and push_config.get("SMTP_PASSWORD") and push_config.get("SMTP_PASSWORD")
and push_config.get("SMTP_NAME") and push_config.get("SMTP_NAME")
): ):
notify_function.append(smtp) notify_function.append(smtp)
if push_config.get("PUSHME_KEY"): if push_config.get("PUSHME_KEY"):
notify_function.append(pushme) notify_function.append(pushme)
if ( if (
push_config.get("CHRONOCAT_URL") push_config.get("CHRONOCAT_URL")
and push_config.get("CHRONOCAT_QQ") and push_config.get("CHRONOCAT_QQ")
and push_config.get("CHRONOCAT_TOKEN") and push_config.get("CHRONOCAT_TOKEN")
): ):
notify_function.append(chronocat) notify_function.append(chronocat)
if push_config.get("WEBHOOK_URL") and push_config.get("WEBHOOK_METHOD"): if push_config.get("WEBHOOK_URL") and push_config.get("WEBHOOK_METHOD"):
notify_function.append(custom_notify) notify_function.append(custom_notify)
@ -910,10 +911,9 @@ def send(title: str, content: str) -> None:
return return
hitokoto = push_config.get("HITOKOTO") hitokoto = push_config.get("HITOKOTO")
content += "\n\n" + one() if hitokoto else ""
text = one() if hitokoto else "" add_notify_function()
content += "\n\n" + text
ts = [ ts = [
threading.Thread(target=mode, args=(title, content), name=mode.__name__) threading.Thread(target=mode, args=(title, content), name=mode.__name__)
for mode in notify_function for mode in notify_function