支持 inotify 通知, resolve #4

This commit is contained in:
Mizore 2023-02-17 16:33:39 +08:00
parent 9562eec323
commit 0056c62f50
2 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,6 @@
return { return {
-- 通知类型, 支持配置多个 -- 通知类型, 支持配置多个
-- NOTIFY_TYPE = {"telegram", "pushdeer", "bark", "dingtalk", "feishu", "wecom", "pushover", "next-smtp-proxy"}, -- NOTIFY_TYPE = {"telegram", "pushdeer", "bark", "dingtalk", "feishu", "wecom", "pushover", "inotify", "next-smtp-proxy"},
NOTIFY_TYPE = "pushdeer", NOTIFY_TYPE = "pushdeer",
-- --
-- telegram 通知配置, https://github.com/0wQ/telegram-notify -- telegram 通知配置, https://github.com/0wQ/telegram-notify
@ -29,6 +29,8 @@ return {
PUSHOVER_API_TOKEN = "", PUSHOVER_API_TOKEN = "",
PUSHOVER_USER_KEY = "", PUSHOVER_USER_KEY = "",
-- --
-- inotify 通知配置, https://github.com/xpnas/Inotify 或者使用合宙提供的 https://push.luatos.org
INOTIFY_API = "https://push.luatos.org/XXXXXX.send",
-- next-smtp-proxy 通知配置, https://github.com/0wQ/next-smtp-proxy -- next-smtp-proxy 通知配置, https://github.com/0wQ/next-smtp-proxy
NEXT_SMTP_PROXY_API = "", NEXT_SMTP_PROXY_API = "",
NEXT_SMTP_PROXY_USER = "", NEXT_SMTP_PROXY_USER = "",

View File

@ -174,6 +174,22 @@ local notify = {
log.info("util_notify", "POST", url) log.info("util_notify", "POST", url)
return util_http.fetch(nil, "POST", url, header, json_data) return util_http.fetch(nil, "POST", url, header, json_data)
end, end,
-- 发送到 inotify
["inotify"] = function(msg)
if config.INOTIFY_API == nil or config.INOTIFY_API == "" then
log.error("util_notify", "未配置 `config.INOTIFY_API`")
return
end
if not config.INOTIFY_API:endsWith(".send") then
log.error("util_notify", "`config.INOTIFY_API` 必须以 `.send` 结尾")
return
end
local url = config.INOTIFY_API .. "/" .. string.urlEncode(msg)
log.info("util_notify", "GET", url)
return util_http.fetch(nil, "GET", url)
end,
-- 发送到 next-smtp-proxy -- 发送到 next-smtp-proxy
["next-smtp-proxy"] = function(msg) ["next-smtp-proxy"] = function(msg)
if config.NEXT_SMTP_PROXY_API == nil or config.NEXT_SMTP_PROXY_API == "" then if config.NEXT_SMTP_PROXY_API == nil or config.NEXT_SMTP_PROXY_API == "" then