✨ 支持 feishu 通知
This commit is contained in:
parent
fe11c1dd27
commit
f6e97481b1
@ -7,6 +7,7 @@
|
||||
- [x] [pushdeer](https://www.pushdeer.com/)
|
||||
- [x] [bark](https://github.com/Finb/Bark)
|
||||
- [x] [dingtalk](https://open.dingtalk.com/document/robots/custom-robot-access)
|
||||
- [x] [feishu](https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN)
|
||||
- [x] 基站定位
|
||||
- [x] 定时查询流量
|
||||
- [x] 开机通知
|
||||
|
@ -1,5 +1,5 @@
|
||||
return {
|
||||
-- 通知类型 telegram, pushdeer, bark, dingtalk
|
||||
-- 通知类型 telegram, pushdeer, bark, dingtalk, feishu
|
||||
NOTIFY_TYPE = "pushdeer",
|
||||
--
|
||||
-- telegram 通知配置, https://github.com/0wQ/telegram-notify
|
||||
@ -18,6 +18,9 @@ return {
|
||||
-- dingtalk 通知配置, https://open.dingtalk.com/document/robots/custom-robot-access
|
||||
DINGTALK_WEBHOOK = "",
|
||||
--
|
||||
-- feishu 通知配置, https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN
|
||||
FEISHU_WEBHOOK = "",
|
||||
--
|
||||
-- 定时查询流量间隔, 单位毫秒, 设置为 0 关闭
|
||||
QUERY_TRAFFIC_INTERVAL = 1000 * 60 * 60 * 6,
|
||||
--
|
||||
|
@ -99,6 +99,30 @@ local function notifyToDingTalk(msg)
|
||||
return http.request("POST", config.DINGTALK_WEBHOOK, header, json_data).wait()
|
||||
end
|
||||
|
||||
-- 发送到 feishu
|
||||
local function notifyToFeishu(msg)
|
||||
if config.FEISHU_WEBHOOK == nil or config.FEISHU_WEBHOOK == "" then
|
||||
log.error("util_notify.notifyToFeishu", "未配置 `config.FEISHU_WEBHOOK`")
|
||||
return
|
||||
end
|
||||
|
||||
local header = {
|
||||
["Content-Type"] = "application/json; charset=utf-8"
|
||||
}
|
||||
local body = {
|
||||
msg_type = "text",
|
||||
content = {
|
||||
text = msg
|
||||
}
|
||||
}
|
||||
local json_data = json.encode(body)
|
||||
-- LuatOS Bug, json.encode 会将 \n 转换为 \b
|
||||
json_data = string.gsub(json_data, "\\b", "\\n")
|
||||
|
||||
log.info("util_notify.notifyToFeishu", "POST", config.FEISHU_WEBHOOK, json_data)
|
||||
return http.request("POST", config.FEISHU_WEBHOOK, header, json_data).wait()
|
||||
end
|
||||
|
||||
function util_notify.send(msg)
|
||||
log.info("util_notify.send", "发送通知", config.NOTIFY_TYPE)
|
||||
|
||||
@ -147,6 +171,8 @@ function util_notify.send(msg)
|
||||
notify = notifyToBark
|
||||
elseif config.NOTIFY_TYPE == "dingtalk" then
|
||||
notify = notifyToDingTalk
|
||||
elseif config.NOTIFY_TYPE == "feishu" then
|
||||
notify = notifyToFeishu
|
||||
else
|
||||
log.error("util_notify.send", "发送通知失败", "未配置 `config.NOTIFY_TYPE`")
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user