瀏覽代碼

:sparkles: 添加时间同步间隔配置项, 开机通知添加开机原因代码

Mizore 1 年之前
父節點
當前提交
98b013c183
共有 2 個文件被更改,包括 14 次插入7 次删除
  1. 5 2
      script/config.lua
  2. 9 5
      script/main.lua

+ 5 - 2
script/config.lua

@@ -1,6 +1,6 @@
 return {
     -- 通知类型, 支持配置多个
-    -- NOTIFY_TYPE = {"custom_post", "telegram", "pushdeer", "bark", "dingtalk", "feishu", "wecom", "pushover", "inotify", "next-smtp-proxy", "gotify", "serial"},
+    -- NOTIFY_TYPE = { "custom_post", "telegram", "pushdeer", "bark", "dingtalk", "feishu", "wecom", "pushover", "inotify", "next-smtp-proxy", "gotify", "serial" },
     NOTIFY_TYPE = "custom_post",
     --
     -- 角色类型, 用于区分主从机, 仅当使用串口转发 NOTIFY_TYPE = "serial" 时才需要配置
@@ -10,7 +10,7 @@ return {
     -- custom_post 通知配置, 自定义 POST 请求, CUSTOM_POST_BODY_TABLE 中的 {msg} 会被替换为通知内容
     CUSTOM_POST_URL = "https://sctapi.ftqq.com/<SENDKEY>.send",
     CUSTOM_POST_CONTENT_TYPE = "application/json",
-    CUSTOM_POST_BODY_TABLE = {["title"] = "这里是标题", ["desp"] = "这里是内容, 会被替换掉:\n{msg}\n{msg}"},
+    CUSTOM_POST_BODY_TABLE = { ["title"] = "这里是标题", ["desp"] = "这里是内容, 会被替换掉:\n{msg}\n{msg}" },
     --
     -- telegram 通知配置, https://github.com/0wQ/telegram-notify 或者自行反代
     TELEGRAM_API = "https://api.telegram.org/bot{token}/sendMessage",
@@ -74,6 +74,9 @@ return {
     -- 定时基站定位间隔, 单位毫秒, 设置为 0 关闭 (定位成功后会追加到通知内容后面, 基站定位本身会消耗流量, 通知内容增加也会导致流量消耗增加)
     LOCATION_INTERVAL = 0,
     --
+    -- 定时同步时间间隔, 单位毫秒, 设置为 0 关闭
+    SNTP_INTERVAL = 1000 * 60 * 60 * 6,
+    --
     -- 定时上报间隔, 单位毫秒, 设置为 0 关闭 (定时触发消息上报)
     REPORT_INTERVAL = 0,
     --

+ 9 - 5
script/main.lua

@@ -119,27 +119,31 @@ sys.taskInit(function()
     util_netled.init()
 
     -- 开机通知
-    if config.BOOT_NOTIFY then sys.timerStart(util_notify.add, 1000 * 5, "#BOOT") end
+    if config.BOOT_NOTIFY then
+        sys.timerStart(util_notify.add, 1000 * 5, "#BOOT_" .. pm.lastReson())
+    end
 
     -- 定时同步时间
     if os.time() < 1714500000 then
         socket.sntp()
     end
-    sys.timerLoopStart(socket.sntp, 1000 * 60 * 30)
+    if type(config.SNTP_INTERVAL) == "number" and config.SNTP_INTERVAL >= 1000 * 60 then
+        sys.timerLoopStart(socket.sntp, config.SNTP_INTERVAL)
+    end
 
     -- 定时查询流量
-    if config.QUERY_TRAFFIC_INTERVAL and config.QUERY_TRAFFIC_INTERVAL >= 1000 * 60 then
+    if type(config.QUERY_TRAFFIC_INTERVAL) == "number" and config.QUERY_TRAFFIC_INTERVAL >= 1000 * 60 then
         sys.timerLoopStart(util_mobile.queryTraffic, config.QUERY_TRAFFIC_INTERVAL)
     end
 
     -- 定时基站定位
-    if config.LOCATION_INTERVAL and config.LOCATION_INTERVAL >= 1000 * 30 then
+    if type(config.LOCATION_INTERVAL) == "number" and config.LOCATION_INTERVAL >= 1000 * 60 then
         util_location.refresh(nil, true)
         sys.timerLoopStart(util_location.refresh, config.LOCATION_INTERVAL)
     end
 
     -- 定时上报
-    if config.REPORT_INTERVAL and config.REPORT_INTERVAL >= 1000 * 30 then
+    if type(config.REPORT_INTERVAL) == "number" and config.REPORT_INTERVAL >= 1000 * 60 then
         sys.timerLoopStart(function() util_notify.add("#ALIVE_REPORT") end, config.REPORT_INTERVAL)
     end