微服务插件用到的内置函数
getRouterPath:获取网络请求路径
getRouterMethod:获取网络请求方法
getRouterHeaders:获取网络请求头
getRouterCookies:获取网络请求携带的cookie
getRouterParams:获取网络请求携带的参数
getRouterBody:获取网络请求携带的body数据
response:响应
示例
`//[open_source: true]
//[create_at: 2023-05-25 20:44:52]
//[title: 青龙推送autMan]
//[author: hdbjlizhe]
//[price: 0.00]
//[router: /send_private_msg]
//[method:post]
//[method:get]
//[version: 1.0.6]
//[service: 282617666]
//[description: 原理很简单,青龙容器中很多脚本支持将运行结果推送到qq框架,此插件是模仿qq框架做成了一个http微服务,这里通过在青龙容器配置文件中配置推送qq参数时,配置为autMan地址为http://autMan地址:端口/send_private_msg,autMan即可接管推送结果,在本插件的配参中可以设置将结果推送到任意对接autMan的渠道。注:此插件生效需重启autMan,推送到个人或群组]
//[param:{"required":false,"key":"otto.qinglong_push_master","bool":true,"placeholder":"","name":"是否推送管理员","desc":""}]
//[param:{"required":false,"key":"otto.qinglong_push_autMan","bool":false,"placeholder":"qqgroup:123,wxgroup:123,tggroup:-100123","name":"推送目标","desc":"格式:qqgroup:123,wxgroup:123,tggroup:-100123"}]
Debug("路由流程")
var router = getRouter()
Debug("路由:" + router)
var method = getMethod()
Debug("方法:" + method)
var params = getRouterParams()
Debug("参数:" + JSON.stringify(params))
var data = getRouterData()
Debug("内容:" + data)
data=data?data:JSON.stringify(params)
var obj = JSON.parse(data)
//去除尾部签名
content = obj.message.replace(/本通知 By:https:\/\/github.com\/whyour\/qinglong/g, "")
//推送到管理员
var pushMasters = get("qinglong_push_master")
if (pushMasters == "true"){
notifyMasters(content)
}
//推送到群或人
var pushGroups = get("qinglong_push_autMan")
Debug(pushGroups)
var pgs = pushGroups.split(",")
for (i = 0; i < pgs.length; i++) {
if (pgs.indexOf("group:") > -1) {
let gps = pgs.split("group:")
push(
{
imType: gps[0],
groupCode: gps[1],
content: content,
}
)
}else if (pgs.indexOf("indiv:") > -1) {
let us = pgs.split("indiv:")
push(
{
imType: us[0],
userID: us[1],
content: content,
}
)
}
}
var j = {
"status": "OK",
"retcode": 0,
}
response(j)`