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

This commit is contained in:
Cp0204 2024-01-25 13:14:26 +08:00 committed by GitHub
parent 7f3e60423b
commit 35c6475534
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -841,60 +841,61 @@ def one() -> str:
return res["hitokoto"] + " ----" + res["from"] return res["hitokoto"] + " ----" + res["from"]
if push_config.get("BARK_PUSH"): def add_notify_function():
notify_function.append(bark) if push_config.get("BARK_PUSH"):
if push_config.get("CONSOLE"): notify_function.append(bark)
notify_function.append(console) if push_config.get("CONSOLE"):
if push_config.get("DD_BOT_TOKEN") and push_config.get("DD_BOT_SECRET"): notify_function.append(console)
notify_function.append(dingding_bot) if push_config.get("DD_BOT_TOKEN") and push_config.get("DD_BOT_SECRET"):
if push_config.get("FSKEY"): notify_function.append(dingding_bot)
notify_function.append(feishu_bot) if push_config.get("FSKEY"):
if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"): notify_function.append(feishu_bot)
notify_function.append(go_cqhttp) if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"):
if push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"): notify_function.append(go_cqhttp)
notify_function.append(gotify) if push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"):
if push_config.get("IGOT_PUSH_KEY"): notify_function.append(gotify)
notify_function.append(iGot) if push_config.get("IGOT_PUSH_KEY"):
if push_config.get("PUSH_KEY"): notify_function.append(iGot)
notify_function.append(serverJ) if push_config.get("PUSH_KEY"):
if push_config.get("DEER_KEY"): notify_function.append(serverJ)
notify_function.append(pushdeer) if push_config.get("DEER_KEY"):
if push_config.get("CHAT_URL") and push_config.get("CHAT_TOKEN"): notify_function.append(pushdeer)
notify_function.append(chat) if push_config.get("CHAT_URL") and push_config.get("CHAT_TOKEN"):
if push_config.get("PUSH_PLUS_TOKEN"): notify_function.append(chat)
notify_function.append(pushplus_bot) if push_config.get("PUSH_PLUS_TOKEN"):
if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"): notify_function.append(pushplus_bot)
notify_function.append(qmsg_bot) if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"):
if push_config.get("QYWX_AM"): notify_function.append(qmsg_bot)
notify_function.append(wecom_app) if push_config.get("QYWX_AM"):
if push_config.get("QYWX_KEY"): notify_function.append(wecom_app)
notify_function.append(wecom_bot) if push_config.get("QYWX_KEY"):
if push_config.get("TG_BOT_TOKEN") and push_config.get("TG_USER_ID"): notify_function.append(wecom_bot)
notify_function.append(telegram_bot) if push_config.get("TG_BOT_TOKEN") and push_config.get("TG_USER_ID"):
if ( notify_function.append(telegram_bot)
push_config.get("AIBOTK_KEY") if (
and push_config.get("AIBOTK_TYPE") push_config.get("AIBOTK_KEY")
and push_config.get("AIBOTK_NAME") and push_config.get("AIBOTK_TYPE")
): and push_config.get("AIBOTK_NAME")
notify_function.append(aibotk) ):
if ( notify_function.append(aibotk)
push_config.get("SMTP_SERVER") if (
and push_config.get("SMTP_SSL") push_config.get("SMTP_SERVER")
and push_config.get("SMTP_EMAIL") and push_config.get("SMTP_SSL")
and push_config.get("SMTP_PASSWORD") and push_config.get("SMTP_EMAIL")
and push_config.get("SMTP_NAME") and push_config.get("SMTP_PASSWORD")
): and push_config.get("SMTP_NAME")
notify_function.append(smtp) ):
if push_config.get("PUSHME_KEY"): notify_function.append(smtp)
notify_function.append(pushme) if push_config.get("PUSHME_KEY"):
if ( notify_function.append(pushme)
push_config.get("CHRONOCAT_URL") if (
and push_config.get("CHRONOCAT_QQ") push_config.get("CHRONOCAT_URL")
and push_config.get("CHRONOCAT_TOKEN") and push_config.get("CHRONOCAT_QQ")
): and push_config.get("CHRONOCAT_TOKEN")
notify_function.append(chronocat) ):
if push_config.get("WEBHOOK_URL") and push_config.get("WEBHOOK_METHOD"): notify_function.append(chronocat)
notify_function.append(custom_notify) if push_config.get("WEBHOOK_URL") and push_config.get("WEBHOOK_METHOD"):
notify_function.append(custom_notify)
def send(title: str, content: str) -> None: def send(title: str, content: str) -> None:
@ -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