Fix steam & lint (#630)

* fix

* make lint happy
This commit is contained in:
DreamZero 2023-03-20 11:57:46 +08:00 committed by GitHub
parent 6474b36ccd
commit e9eb4c5602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 39 deletions

View File

@ -234,14 +234,13 @@ func init() {
fmt.Println("Usage:") fmt.Println("Usage:")
flag.PrintDefaults() flag.PrintDefaults()
os.Exit(0) os.Exit(0)
} else { }
if *d && !*w { if *d && !*w {
logrus.SetLevel(logrus.DebugLevel) logrus.SetLevel(logrus.DebugLevel)
} }
if *w { if *w {
logrus.SetLevel(logrus.WarnLevel) logrus.SetLevel(logrus.WarnLevel)
} }
}
for _, s := range flag.Args() { for _, s := range flag.Args() {
i, err := strconv.ParseInt(s, 10, 64) i, err := strconv.ParseInt(s, 10, 64)

View File

@ -40,7 +40,7 @@ func randText(text ...string) message.MessageSegment {
} }
// isAtriSleeping 凌晨0点到6点ATRI 在睡觉,不回应任何请求 // isAtriSleeping 凌晨0点到6点ATRI 在睡觉,不回应任何请求
func isAtriSleeping(ctx *zero.Ctx) bool { func isAtriSleeping(*zero.Ctx) bool {
if now := time.Now().Hour(); now >= 1 && now < 6 { if now := time.Now().Hour(); now >= 1 && now < 6 {
return false return false
} }

View File

@ -162,10 +162,11 @@ func init() { // 插件主体
ctx.SendChain(message.Text("请私聊发送 设置 saucenao api key [apikey] 以启用 saucenao 搜图 (方括号不需要输入), key 请前往 https://saucenao.com/user.php?page=search-api 获取")) ctx.SendChain(message.Text("请私聊发送 设置 saucenao api key [apikey] 以启用 saucenao 搜图 (方括号不需要输入), key 请前往 https://saucenao.com/user.php?page=search-api 获取"))
} }
// ascii2d 搜索 // ascii2d 搜索
if result, err := ascii2d.ASCII2d(pic); err != nil { result, err := ascii2d.ASCII2d(pic)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err)) ctx.SendChain(message.Text("ERROR: ", err))
continue continue
} else { }
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))} msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))}
for i := 0; i < len(result) && i < 5; i++ { for i := 0; i < len(result) && i < 5; i++ {
msg = append(msg, ctxext.FakeSenderForwardNode(ctx, msg = append(msg, ctxext.FakeSenderForwardNode(ctx,
@ -184,7 +185,6 @@ func init() { // 插件主体
ctx.SendChain(message.Text("ERROR: 可能被风控了")) ctx.SendChain(message.Text("ERROR: 可能被风控了"))
} }
} }
}
}) })
engine.OnRegex(`^设置\s?saucenao\s?api\s?key\s?([0-9a-f]{40})$`, zero.SuperUserPermission, zero.OnlyPrivate).SetBlock(true). engine.OnRegex(`^设置\s?saucenao\s?api\s?key\s?([0-9a-f]{40})$`, zero.SuperUserPermission, zero.OnlyPrivate).SetBlock(true).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {

View File

@ -236,10 +236,7 @@ func (p *imgpool) add(ctx *zero.Ctx, imgtype string, id int64) error {
return err return err
} }
// 添加插画到对应的数据库table // 添加插画到对应的数据库table
if err := p.db.Insert(imgtype, illust); err != nil { return p.db.Insert(imgtype, illust)
return err
}
return nil
} }
func (p *imgpool) remove(imgtype string, id int64) error { func (p *imgpool) remove(imgtype string, id int64) error {

View File

@ -55,13 +55,13 @@ func timeDuration(time time.Duration) (hour, minute, second int64) {
} }
// 只统计6点到12点的早安 // 只统计6点到12点的早安
func isMorning(ctx *zero.Ctx) bool { func isMorning(*zero.Ctx) bool {
now := time.Now().Hour() now := time.Now().Hour()
return now >= 6 && now <= 12 return now >= 6 && now <= 12
} }
// 只统计21点到凌晨3点的晚安 // 只统计21点到凌晨3点的晚安
func isEvening(ctx *zero.Ctx) bool { func isEvening(*zero.Ctx) bool {
now := time.Now().Hour() now := time.Now().Hour()
return now >= 21 || now <= 3 return now >= 21 || now <= 3
} }

View File

@ -53,9 +53,9 @@ func init() {
// 收集这波用户的streamId然后查当前的状态并建立信息映射表 // 收集这波用户的streamId然后查当前的状态并建立信息映射表
streamIds := make([]string, len(infos)) streamIds := make([]string, len(infos))
localPlayerMap := make(map[int64]*player) localPlayerMap := make(map[int64]*player)
for i, info := range infos { for i := 0; i < len(infos); i++ {
streamIds[i] = strconv.FormatInt(info.SteamID, 10) streamIds[i] = strconv.FormatInt(infos[i].SteamID, 10)
localPlayerMap[info.SteamID] = info localPlayerMap[infos[i].SteamID] = &infos[i]
} }
// 将所有用户状态查一遍 // 将所有用户状态查一遍
playerStatus, err := getPlayerStatus(streamIds...) playerStatus, err := getPlayerStatus(streamIds...)

View File

@ -91,7 +91,7 @@ func (sql *streamDB) findWithGroupID(steamID int64, groupID string) (dbInfo play
} }
// findAll 查询所有库信息 // findAll 查询所有库信息
func (sql *streamDB) findAll() (dbInfos []*player, err error) { func (sql *streamDB) findAll() (dbInfos []player, err error) {
sql.Lock() sql.Lock()
defer sql.Unlock() defer sql.Unlock()
var info player var info player
@ -99,10 +99,10 @@ func (sql *streamDB) findAll() (dbInfos []*player, err error) {
if err != nil || num == 0 { if err != nil || num == 0 {
return return
} }
dbInfos = make([]*player, 0, num) dbInfos = make([]player, 0, num)
err = sql.db.FindFor(TableListenPlayer, &info, "", func() error { err = sql.db.FindFor(TableListenPlayer, &info, "", func() error {
if info.SteamID != 0 { if info.SteamID != 0 {
dbInfos = append(dbInfos, &info) dbInfos = append(dbInfos, info)
} }
return nil return nil
}) })