Merge pull request #14 from AkagiYui/main

feat: add gotify support
This commit is contained in:
Mizore 2023-04-01 15:42:14 +08:00 committed by GitHub
commit 8426373406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -41,6 +41,12 @@ return {
NEXT_SMTP_PROXY_TO_EMAIL = "", NEXT_SMTP_PROXY_TO_EMAIL = "",
NEXT_SMTP_PROXY_SUBJECT = "来自 Air780E 的通知", NEXT_SMTP_PROXY_SUBJECT = "来自 Air780E 的通知",
-- --
-- gotify 通知配置, https://gotify.net/
GOTIFY_API = "",
GOTIFY_TITLE = "Air780E",
GOTIFY_PRIORITY = 8,
GOTIFY_TOKEN = "",
--
-- 定时查询流量间隔, 单位毫秒, 设置为 0 关闭 (建议检查 util_mobile.lua 文件中运营商号码和查询代码是否正确, 以免发错短信导致扣费, 收到查询结果短信发送通知会消耗流量) -- 定时查询流量间隔, 单位毫秒, 设置为 0 关闭 (建议检查 util_mobile.lua 文件中运营商号码和查询代码是否正确, 以免发错短信导致扣费, 收到查询结果短信发送通知会消耗流量)
QUERY_TRAFFIC_INTERVAL = 1000 * 60 * 60 * 6, QUERY_TRAFFIC_INTERVAL = 1000 * 60 * 60 * 6,
-- --

View File

@ -31,6 +31,31 @@ local notify = {
log.info("util_notify", "POST", config.TELEGRAM_PROXY_API) log.info("util_notify", "POST", config.TELEGRAM_PROXY_API)
return util_http.fetch(nil, "POST", config.TELEGRAM_PROXY_API, header, msg) return util_http.fetch(nil, "POST", config.TELEGRAM_PROXY_API, header, msg)
end, end,
-- 发送到 gotify
["gotify"] = function(msg)
if config.GOTIFY_API == nil or config.GOTIFY_API == "" then
log.error("util_notify", "未配置 `config.GOTIFY_API`")
return
end
if config.GOTIFY_TOKEN == nil or config.GOTIFY_TOKEN == "" then
log.error("util_notify", "未配置 `config.GOTIFY_TOKEN`")
return
end
local header = {
["Content-Type"] = "application/json; charset=utf-8"
}
local body = {
title = config.GOTIFY_TITLE,
message = msg,
priority = config.GOTIFY_PRIORITY
}
local json_data = json.encode(body)
json_data = string.gsub(json_data, "\\b", "\\n")
log.info("util_notify", "POST", config.GOTIFY_API)
return util_http.fetch(nil, "POST", config.GOTIFY_API.."/message?token="..config.GOTIFY_TOKEN, header, json_data)
end,
-- 发送到 pushdeer -- 发送到 pushdeer
["pushdeer"] = function(msg) ["pushdeer"] = function(msg)
if config.PUSHDEER_API == nil or config.PUSHDEER_API == "" then if config.PUSHDEER_API == nil or config.PUSHDEER_API == "" then