Merge pull request #675 from Akimio521/main

This commit is contained in:
jxxghp
2025-02-12 11:28:06 +08:00
committed by GitHub
2 changed files with 23 additions and 21 deletions

View File

@@ -8,7 +8,7 @@
"author": "thsrite",
"level": 2,
"history": {
"v2.4.3": "修复空签到失败问题",
"v2.4.3": "修复空签到失败问题",
"v2.4.2": "修复PT时间签到失败问题",
"v2.4.1": "修复海胆签到失败问题",
"v2.4": "适配m-team Api地址变化",
@@ -496,6 +496,7 @@
"level": 1,
"v2": true,
"history": {
"v1.3": "将标题、推送内容放入请求体中,避免编码后 URI 过长导致无法推送",
"v1.2": "支持多人消息发送"
}
},
@@ -909,7 +910,6 @@
"v1.4.0": "修复强制更改IP时配置面板延时过长的问题。庆祝v2进入正式版显示了一个没用的参数"
}
},
"SyncCookieCloud": {
"name": "同步CookieCloud",
"description": "同步MoviePilot站点Cookie到本地CookieCloud。",
@@ -955,4 +955,4 @@
"v1.3": "消息限流发送以缓解IYUU服务器压力"
}
}
}
}

View File

@@ -1,5 +1,5 @@
from typing import Any, List, Dict, Tuple
from urllib.parse import quote_plus
from urllib.parse import parse_qs
from app.core.event import eventmanager, Event
from app.log import logger
@@ -16,7 +16,7 @@ class BarkMsg(_PluginBase):
# 插件图标
plugin_icon = "Bark_A.png"
# 插件版本
plugin_version = "1.2"
plugin_version = "1.3"
# 插件作者
plugin_author = "jxxghp"
# 作者主页
@@ -217,23 +217,25 @@ class BarkMsg(_PluginBase):
try:
if not self._server or not self._apikey:
return False, "参数未配置"
for apikey in self._apikey.split():
sc_url = "%s/%s/%s/%s" % (self._server, apikey, quote_plus(title), quote_plus(text))
if self._params:
sc_url = "%s?%s" % (sc_url, self._params)
res = RequestUtils().post_res(sc_url)
if res and res.status_code == 200:
ret_json = res.json()
code = ret_json['code']
message = ret_json['message']
if code == 200:
logger.info(f"{apikey} Bark消息发送成功")
else:
logger.warn(f"{apikey} Bark消息发送失败{message}")
elif res is not None:
logger.warn(f"{apikey} Bark消息发送失败错误码{res.status_code},错误原因:{res.reason}")
req_body = {k: v[0] for k, v in parse_qs(self._params).items()}
req_body.update({
"title": title,
"body": text,
"device_keys": self._apikey.split(),
})
res = RequestUtils().post_res(f"{self._server}/push", json=req_body)
if res and res.status_code == 200:
ret_json = res.json()
code = ret_json['code']
message = ret_json['message']
if code == 200:
logger.info(f"Bark消息发送成功")
else:
logger.warn(f"{apikey} Bark消息发送失败未获取到返回信息")
logger.warn(f"Bark消息发送失败{message}")
elif res is not None:
logger.warn(f"Bark消息发送失败错误码{res.status_code},错误原因:{res.reason}")
else:
logger.warn(f"Bark消息发送失败未获取到返回信息")
except Exception as msg_e:
logger.error(f"Bark消息发送失败{str(msg_e)}")