修复通知异常问题
This commit is contained in:
parent
1e248d72df
commit
2e761c690b
@ -8,6 +8,7 @@ import hashlib
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
@ -280,12 +281,32 @@ def get_tieba_cookies():
|
|||||||
print(f"从环境变量读取到 {len(cookies)} 个账号")
|
print(f"从环境变量读取到 {len(cookies)} 个账号")
|
||||||
return cookies
|
return cookies
|
||||||
|
|
||||||
|
# 添加青龙脚本根目录到Python路径
|
||||||
|
QL_SCRIPTS_DIR = '/ql/scripts' # 青龙脚本默认目录
|
||||||
|
sys.path.append(QL_SCRIPTS_DIR)
|
||||||
|
|
||||||
|
# 添加notify可能存在的其他路径
|
||||||
|
POSSIBLE_PATHS = [
|
||||||
|
'/ql', # 青龙根目录
|
||||||
|
'/ql/data/scripts', # 新版青龙数据目录
|
||||||
|
'/ql/scripts/notify', # 自定义通知目录
|
||||||
|
os.path.dirname(__file__) # 当前脚本目录
|
||||||
|
]
|
||||||
|
|
||||||
|
for path in POSSIBLE_PATHS:
|
||||||
|
if os.path.exists(os.path.join(path, 'notify.py')):
|
||||||
|
sys.path.append(path)
|
||||||
|
break
|
||||||
|
|
||||||
# 发送青龙面板通知
|
# 发送青龙面板通知
|
||||||
def send_notification(title, content):
|
def send_notification(title, content):
|
||||||
try:
|
try:
|
||||||
# 尝试导入青龙的通知模块
|
# 尝试导入青龙的通知模块
|
||||||
from notify import send
|
from notify import send
|
||||||
return send(title, content)
|
return send(title, content)
|
||||||
|
except ImportError:
|
||||||
|
print("⚠️ 无法加载通知模块,请检查路径配置")
|
||||||
|
return lambda title, content: None # 创建空函数防止报错
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"通知发送失败: {e}")
|
print(f"通知发送失败: {e}")
|
||||||
print(f"通知内容: {title}\n{content}")
|
print(f"通知内容: {title}\n{content}")
|
||||||
|
Loading…
Reference in New Issue
Block a user