This commit is contained in:
cdle 2021-08-21 09:24:30 +08:00
parent 72e74e6bcf
commit 0064d5e304
4 changed files with 14 additions and 24 deletions

3
.gitignore vendored
View File

@ -21,4 +21,5 @@ conf/config.yaml
conf/config_cdle.yaml
conf/reply.php
jdCookie.js
scripts/node_modules
scripts/node_modules
task/*

View File

@ -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 {

View File

@ -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...)
}

View File

@ -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()
}
}