🎨 改进代码样式

This commit is contained in:
github-actions[bot] 2021-12-13 13:15:16 +00:00
parent 3fba704c77
commit 6b4045db45
7 changed files with 7 additions and 11 deletions

View File

@ -5,10 +5,11 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/FloatTech/ZeroBot-Plugin/control"
"github.com/fumiama/cron" "github.com/fumiama/cron"
zero "github.com/wdvxdr1123/ZeroBot" zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message" "github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
) )
type follower struct { type follower struct {

View File

@ -4,12 +4,13 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/FloatTech/ZeroBot-Plugin/control"
"github.com/FloatTech/ZeroBot-Plugin/utils/rule"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot" zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message" "github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper" "github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/ZeroBot-Plugin/control"
"github.com/FloatTech/ZeroBot-Plugin/utils/rule"
) )
const ( const (

View File

@ -37,5 +37,4 @@ func init() {
} }
log.Printf("[kuji]读取%d条签文", n) log.Printf("[kuji]读取%d条签文", n)
}() }()
} }

View File

@ -7,9 +7,10 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/FloatTech/ZeroBot-Plugin/control"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/FloatTech/ZeroBot-Plugin/control"
zero "github.com/wdvxdr1123/ZeroBot" zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message" "github.com/wdvxdr1123/ZeroBot/message"
) )

View File

@ -16,11 +16,9 @@ func init() {
if err := recover(); err != nil { //产生了panic异常 if err := recover(); err != nil { //产生了panic异常
log.Println(err) log.Println(err)
} }
}() //别忘了(), 调用此匿名函数 }() //别忘了(), 调用此匿名函数
process.SleepAbout1sTo2s() process.SleepAbout1sTo2s()
_ = os.MkdirAll(dbpath, 0755) _ = os.MkdirAll(dbpath, 0755)
model.Initialize(dbfile) model.Initialize(dbfile)
}() }()
} }

View File

@ -38,7 +38,6 @@ func init() {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(fmt.Sprintf("早安成功!你的睡眠时长为%d时%d分%d秒,你是今天第%d个起床的", hour, minute, second, position))) ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(fmt.Sprintf("早安成功!你的睡眠时长为%d时%d分%d秒,你是今天第%d个起床的", hour, minute, second, position)))
} }
db.Close() db.Close()
}) })
engine.OnFullMatch("晚安", isEvening, zero.OnlyGroup).SetBlock(true).SetPriority(prio). engine.OnFullMatch("晚安", isEvening, zero.OnlyGroup).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
@ -56,7 +55,6 @@ func init() {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(fmt.Sprintf("晚安成功!你的清醒时长为%d时%d分%d秒,你是今天第%d个睡觉的", hour, minute, second, position))) ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(fmt.Sprintf("晚安成功!你的清醒时长为%d时%d分%d秒,你是今天第%d个睡觉的", hour, minute, second, position)))
} }
db.Close() db.Close()
}) })
} }

View File

@ -237,7 +237,6 @@ func (vdb *VtbDB) GetVtbList() (uidList []string) {
logrus.Println(fc) logrus.Println(fc)
if err := db.Debug().Model(&FirstCategory{}).Where("first_category_uid = ?", fc.FirstCategoryUid).First(&fc).Error; err != nil { if err := db.Debug().Model(&FirstCategory{}).Where("first_category_uid = ?", fc.FirstCategoryUid).First(&fc).Error; err != nil {
if gorm.IsRecordNotFoundError(err) { if gorm.IsRecordNotFoundError(err) {
db.Debug().Model(&FirstCategory{}).Create(&fc) // newUser not user db.Debug().Model(&FirstCategory{}).Create(&fc) // newUser not user
} }
@ -330,7 +329,6 @@ func (vdb *VtbDB) StoreVtb(uid string) {
if err := db.Debug().Model(&ThirdCategory{}).Where("first_category_uid = ? and second_category_index = ? and third_category_index = ?", if err := db.Debug().Model(&ThirdCategory{}).Where("first_category_uid = ? and second_category_index = ? and third_category_index = ?",
uid, secondIndex, thirdIndex).First(&tc).Error; err != nil { uid, secondIndex, thirdIndex).First(&tc).Error; err != nil {
if gorm.IsRecordNotFoundError(err) { if gorm.IsRecordNotFoundError(err) {
db.Debug().Model(&ThirdCategory{}).Create(&tc) // newUser not user db.Debug().Model(&ThirdCategory{}).Create(&tc) // newUser not user
} }