feat(internal/reminder): Signal提醒

This commit is contained in:
mei
2025-10-17 20:18:42 +08:00
parent 887d6c8618
commit 71d0e095c8
7 changed files with 80 additions and 40 deletions
+22
View File
@@ -262,3 +262,25 @@ func triggerLoginRequest(biliClient *bilibili.Client) {
}
}
}
// Enable periodic cookie checks
func StartCookieChecker(cookieCheckTimer *time.Ticker, biliClient *bilibili.Client) {
// check cookie per hour
cookieCheckTimer = time.NewTicker(1 * time.Hour)
go func() {
for {
<-cookieCheckTimer.C
CheckCookieValidity(biliClient)
}
}()
}
func InitBilibili(biliClient *bilibili.Client) {
// try cached cookie
if !LoadCookies(biliClient) {
// if cookie check failed, request qrcode login
LoginWithQRCode(biliClient)
} else {
log.Println("使用已存储的有效cookie登录")
}
}
+22
View File
@@ -0,0 +1,22 @@
package internal
import (
"fmt"
"log"
"time"
"github.com/ssdomei232/goodBaby/configs"
)
func Reminder() {
config, err := configs.GetConfig()
if err != nil {
log.Printf("获取配置文件失败: %v", err)
}
remainingTime := GlobalTimerManager.GetRemainingTime()
if remainingTime <= 48*time.Hour {
sendMsg := fmt.Sprintf("距离摇篮系统触发还有%d小时,请尽快发送Signal", int(remainingTime.Hours()))
sendMailMsg(config.BiliWarnAddress, sendMsg, "GoodBaby提醒")
}
}
-1
View File
@@ -1,4 +1,3 @@
// internal/timer_manager.go
package internal
import (
+19
View File
@@ -0,0 +1,19 @@
package internal
import (
"html/template"
"io/fs"
"net/http"
"github.com/gin-gonic/gin"
)
// loadTemplates loads templates from the embedded file system
func LoadTemplates(filesystem fs.FS) *template.Template {
templ := template.Must(template.New("").ParseFS(filesystem, "*.html"))
return templ
}
func IndexPage(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", nil)
}