智能微秘书自定义参数

This commit is contained in:
Akimio521 2024-02-25 15:42:33 +08:00
parent 0ac09f25fa
commit e7b7df374a

View File

@ -629,31 +629,42 @@ def telegram_bot(title: str, content: str, **kwargs) -> None:
print("tg 推送失败!") print("tg 推送失败!")
def aibotk(title: str, content: str) -> None: def aibotk(title: str, content: str, **kwargs) -> None:
""" """
使用 智能微秘书 推送消息 使用 智能微秘书 推送消息
""" """
if ( if not (
not push_config.get("AIBOTK_KEY") kwargs.get("AIBOTK_KEY")
or not push_config.get("AIBOTK_TYPE") and kwargs.get("AIBOTK_TYPE")
or not push_config.get("AIBOTK_NAME") and kwargs.get("AIBOTK_NAME")
)or (
push_config.get("AIBOTK_KEY")
and push_config.get("AIBOTK_TYPE")
and push_config.get("AIBOTK_NAME")
): ):
print("智能微秘书 的 AIBOTK_KEY 或者 AIBOTK_TYPE 或者 AIBOTK_NAME 未设置!!\n取消推送") print("智能微秘书 的 AIBOTK_KEY 或者 AIBOTK_TYPE 或者 AIBOTK_NAME 未设置!!\n取消推送")
return return
print("智能微秘书 服务启动") print("智能微秘书 服务启动")
if kwargs.get("AIBOTK_KEY") and kwargs.get("AIBOTK_TYPE") and kwargs.get("AIBOTK_NAME"):
if push_config.get("AIBOTK_TYPE") == "room": AIBOTK_KEY = kwargs.get("AIBOTK_KEY")
AIBOTK_TYPE = kwargs.get("AIBOTK_TYPE")
AIBOTK_NAME = kwargs.get("AIBOTK_NAME")
else:
AIBOTK_KEY = push_config.get("AIBOTK_KEY")
AIBOTK_TYPE = push_config.get("AIBOTK_TYPE")
AIBOTK_NAME = push_config.get("AIBOTK_NAME")
if AIBOTK_TYPE == "room":
url = "https://api-bot.aibotk.com/openapi/v1/chat/room" url = "https://api-bot.aibotk.com/openapi/v1/chat/room"
data = { data = {
"apiKey": push_config.get("AIBOTK_KEY"), "apiKey": AIBOTK_KEY,
"roomName": push_config.get("AIBOTK_NAME"), "roomName": AIBOTK_NAME,
"message": {"type": 1, "content": f"【青龙快讯】\n\n{title}\n{content}"}, "message": {"type": 1, "content": f"【青龙快讯】\n\n{title}\n{content}"},
} }
else: else:
url = "https://api-bot.aibotk.com/openapi/v1/chat/contact" url = "https://api-bot.aibotk.com/openapi/v1/chat/contact"
data = { data = {
"apiKey": push_config.get("AIBOTK_KEY"), "apiKey": AIBOTK_KEY,
"name": push_config.get("AIBOTK_NAME"), "name": AIBOTK_NAME,
"message": {"type": 1, "content": f"【青龙快讯】\n\n{title}\n{content}"}, "message": {"type": 1, "content": f"【青龙快讯】\n\n{title}\n{content}"},
} }
body = json.dumps(data).encode(encoding="utf-8") body = json.dumps(data).encode(encoding="utf-8")