diff --git a/.gitignore b/.gitignore index c91c407..eeb3a7f 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ conf/config.yaml conf/config_cdle.yaml conf/reply.php jdCookie.js -scripts/node_modules \ No newline at end of file +scripts/node_modules +task/* \ No newline at end of file diff --git a/models/task.go b/models/task.go index 38190b1..898464a 100644 --- a/models/task.go +++ b/models/task.go @@ -18,15 +18,15 @@ type Task struct { Cron string Path string Enable bool - Mode string //obo alo + Mode string Word string - Run func() Name string Timeout int Envs []Env Args string Ykq bool Hack bool + From string } type Env struct { diff --git a/models/user.go b/models/user.go index dd8b54a..99967e0 100644 --- a/models/user.go +++ b/models/user.go @@ -41,6 +41,7 @@ func NewActiveUser(class string, uid int, msgs ...interface{}) { var first = false total := []int{} err := db.Where("class = ? and number = ?", class, uid).First(&u).Error + get := 0 if err != nil { first = true u = User{ @@ -59,6 +60,7 @@ func NewActiveUser(class string, uid int, msgs ...interface{}) { "active_at": ntime, "coin": gorm.Expr("coin+1"), }) + get++ u.Coin++ } else { msg += fmt.Sprintf("你打过卡了,许愿币余额%d。", u.Coin) @@ -67,7 +69,14 @@ func NewActiveUser(class string, uid int, msgs ...interface{}) { } if first { db.Model(User{}).Select("count(id) as total").Where("active_at > ?", zero).Pluck("total", &total) - msg += fmt.Sprintf("你是打卡第%d人,奖励%d个许愿币,许愿币余额%d。", total[0]+1, 1, u.Coin) + if (total[0]+1)%8 == 0 { + db.Model(&u).Updates(map[string]interface{}{ + "coin": gorm.Expr("coin+1"), + }) + get++ + u.Coin++ + } + msg += fmt.Sprintf("你是打卡第%d人,奖励%d个许愿币,许愿币余额%d。", total[0]+1, get, u.Coin) // fmt.Println(msg) sendMessagee(msg, msgs...) } diff --git a/models/version.go b/models/version.go index e3c6739..b8a40c9 100644 --- a/models/version.go +++ b/models/version.go @@ -34,26 +34,6 @@ func initVersion() { return } (&JdCookie{}).Push("版本过低,自动更新") - // rsp, err := httplib.Get(GhProxy + "https://github.com/cdle/jd_study/releases/download/main/" + name).Response() - // if err != nil { - // logs.Warn("无法下载更新") - // return - // } - // filename := ExecPath + "/." + pname - // f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777) - // if err != nil { - // logs.Warn("无法创建更新临时文件:%v"+filename, err) - // return - // } - // _, err = io.Copy(f, rsp.Body) - // f.Close() - // if err != nil { - // logs.Warn("下载更新失败") - // return - // } - // if err := os.Rename(filename, ExecPath+"/"+pname); err != nil { - // logs.Warn("移动临时更新文件失败") - // } Daemon() } }