一、青龙面板配置环境变量
1. 配置通知渠道
支持企业微信应用或飞书机器人。
2. 添加环境变量
名称为 xmqb,值为抓包获取的两个值,中间用#号隔开。
二、添加脚本
import os
import time
import requests
import urllib3
import json
from datetime import datetime
from typing import Optional, Dict, Any, Union
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
class Notifier:
@staticmethod
def send(title: str, content: str):
"""通过青龙面板通知设置发送消息"""
notifier_type = os.environ.get("NOTIFY_TYPE", "").lower()
if not notifier_type:
print("未配置通知环境变量,无法发送通知")
return
try:
if "feishu" in notifier_type:
Notifier.feishu_notify(title, content)
elif "qywx" in notifier_type:
Notifier.qywx_notify(title, content)
else:
print(f"不支持的通知类型:{notifier_type}")
except Exception e:
()
():
fskey = os.environ.get()
fskey:
()
webhook_url =
payload = {
: ,
: {
: {
: {
: title,
: [[{: , : content}]]
}
}
}
}
:
response = requests.post(
webhook_url, headers={: },
data=json.dumps(payload), timeout=, verify=
)
response.status_code != :
()
:
resp_data = response.json()
resp_data.get() != :
()
:
()
Exception e:
()
():
qywx_am = os.environ.get()
qywx_am:
()
parts = qywx_am.split()
(parts) < :
()
corpid, corpsecret, touser, agentid, msg_type = parts[:]
token_url =
:
token_resp = requests.get(token_url, verify=).json()
token_resp.get() != :
()
access_token = token_resp.get()
Exception e:
()
send_url =
payload = {
: touser,
: agentid,
: msg_type == ,
}
msg_type == :
payload[] = {: }
:
payload[] = {
: [
{: title, : , : , : content}
]
}
:
requests.post(send_url, json=payload, timeout=)
()
Exception e:
()

