Compare commits

...

3 Commits

Author SHA1 Message Date
Y_C_Z
ea3c3dedbc
Merge 50d01bb4d8 into 69e4baee87 2025-04-29 11:31:08 +08:00
Mr.King
69e4baee87 通知模块:增加 DoDo机器人推送 (#76)
Some checks failed
Docker Publish / build-and-push (push) Has been cancelled
🐛 通知模块:修复DoDo机器人配置参数大小写错误 (#77)
2025-04-28 20:30:00 +08:00
Y_C_Z
50d01bb4d8
每次转存都清空目标文件夹 2025-04-16 12:13:33 +08:00
2 changed files with 71 additions and 0 deletions

View File

@ -132,6 +132,11 @@ push_config = {
'WXPUSHER_APP_TOKEN': '', # wxpusher 的 appToken 官方文档: https://wxpusher.zjiecode.com/docs/ 管理后台: https://wxpusher.zjiecode.com/admin/
'WXPUSHER_TOPIC_IDS': '', # wxpusher 的 主题ID多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
'WXPUSHER_UIDS': '', # wxpusher 的 用户ID多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
'DODO_BOTTOKEN': '', # DoDo机器人的token DoDo开发平台https://doker.imdodo.com/
'DODO_BOTID': '', # DoDo机器人的id
'DODO_LANDSOURCEID': '', # DoDo机器人所在的群ID
'DODO_SOURCEID': '', # DoDo机器人推送目标用户的ID
}
# fmt: on
@ -829,6 +834,54 @@ def ntfy(title: str, content: str) -> None:
else:
print("Ntfy 推送失败!错误信息:", response.text)
def dodo_bot(title: str, content: str) -> None:
"""
通过 DoDo机器人 推送消息
"""
required_keys = [
'DODO_BOTTOKEN',
'DODO_BOTID',
'DODO_LANDSOURCEID',
'DODO_SOURCEID'
]
if not all(push_config.get(key) for key in required_keys):
missing = [key for key in required_keys if not push_config.get(key)]
print(f"DoDo 服务配置不完整,缺少以下参数: {', '.join(missing)}\n取消推送")
return
print("DoDo 服务启动")
url="https://botopen.imdodo.com/api/v2/personal/message/send"
botID=push_config.get('DODO_BOTID')
botToken=push_config.get('DODO_BOTTOKEN')
islandSourceId=push_config.get('DODO_LANDSOURCEID')
dodoSourceId=push_config.get('DODO_SOURCEID')
headers = {
'Authorization': f'Bot {botID}.{botToken}',
'Content-Type': 'application/json',
'Host': 'botopen.imdodo.com'
}
payload = json.dumps({
"islandSourceId": islandSourceId,
"dodoSourceId": dodoSourceId,
"messageType": 1,
"messageBody": {
"content": f"{title}\n\n{content}"
}
})
try:
response = requests.post(url, headers=headers, data=payload)
if response.status_code == 200:
response = response.json()
if response.get("status") == 0 and response.get("message") == "success":
print(f'DoDo 推送成功!')
else:
print(f'DoDo 推送失败!错误信息:\n{response}')
else:
print("DoDo 推送失败!错误信息:", response.text)
except Exception as e:
print(f"DoDo 推送请求异常: {str(e)}")
def wxpusher_bot(title: str, content: str) -> None:
"""
@ -1043,6 +1096,13 @@ def add_notify_function():
and push_config.get("CHRONOCAT_TOKEN")
):
notify_function.append(chronocat)
if (
push_config.get("DODO_BOTTOKEN")
and push_config.get("DODO_BOTID")
and push_config.get("DODO_LANDSOURCEID")
and push_config.get("DODO_SOURCEID")
):
notify_function.append(dodo_bot)
if push_config.get("WEBHOOK_URL") and push_config.get("WEBHOOK_METHOD"):
notify_function.append(custom_notify)
if push_config.get("NTFY_TOPIC"):

View File

@ -697,6 +697,17 @@ class Quark:
to_pdir_fid = self.savepath_fid[savepath]
dir_file_list = self.ls_dir(to_pdir_fid)["data"]["list"]
# print("dir_file_list: ", dir_file_list)
# 清空目标文件夹
fid_list = [item["fid"] for item in dir_file_list]
if fid_list:
self.delete(fid_list)
recycle_list = self.recycle_list()
record_id_list = [
item["record_id"] for item in recycle_list if item["fid"] in fid_list
]
self.recycle_remove(record_id_list)
# 重新获取目标目录文件列表
dir_file_list = self.ls_dir(to_pdir_fid)
tree.create_node(
savepath,