ソースを参照

:sparkles: 支持 inotify 通知, resolve #4

Mizore 2 年 前
コミット
0056c62f50
2 ファイル変更19 行追加1 行削除
  1. 3 1
      script/config.lua
  2. 16 0
      script/util_notify.lua

+ 3 - 1
script/config.lua

@@ -1,6 +1,6 @@
 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",
     --
     -- telegram 通知配置, https://github.com/0wQ/telegram-notify
@@ -29,6 +29,8 @@ return {
     PUSHOVER_API_TOKEN = "",
     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_API = "",
     NEXT_SMTP_PROXY_USER = "",

+ 16 - 0
script/util_notify.lua

@@ -174,6 +174,22 @@ local notify = {
         log.info("util_notify", "POST", url)
         return util_http.fetch(nil, "POST", url, header, json_data)
     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"] = function(msg)
         if config.NEXT_SMTP_PROXY_API == nil or config.NEXT_SMTP_PROXY_API == "" then