diff --git a/main.go b/main.go index b6edd3cd..31268437 100644 --- a/main.go +++ b/main.go @@ -234,13 +234,12 @@ func init() { fmt.Println("Usage:") flag.PrintDefaults() os.Exit(0) - } else { - if *d && !*w { - logrus.SetLevel(logrus.DebugLevel) - } - if *w { - logrus.SetLevel(logrus.WarnLevel) - } + } + if *d && !*w { + logrus.SetLevel(logrus.DebugLevel) + } + if *w { + logrus.SetLevel(logrus.WarnLevel) } for _, s := range flag.Args() { diff --git a/plugin/atri/atri.go b/plugin/atri/atri.go index e2385f71..0b533113 100644 --- a/plugin/atri/atri.go +++ b/plugin/atri/atri.go @@ -40,7 +40,7 @@ func randText(text ...string) message.MessageSegment { } // isAtriSleeping 凌晨0点到6点,ATRI 在睡觉,不回应任何请求 -func isAtriSleeping(ctx *zero.Ctx) bool { +func isAtriSleeping(*zero.Ctx) bool { if now := time.Now().Hour(); now >= 1 && now < 6 { return false } diff --git a/plugin/saucenao/searcher.go b/plugin/saucenao/searcher.go index 10107efd..e51b692d 100644 --- a/plugin/saucenao/searcher.go +++ b/plugin/saucenao/searcher.go @@ -162,27 +162,27 @@ func init() { // 插件主体 ctx.SendChain(message.Text("请私聊发送 设置 saucenao api key [apikey] 以启用 saucenao 搜图 (方括号不需要输入), key 请前往 https://saucenao.com/user.php?page=search-api 获取")) } // ascii2d 搜索 - if result, err := ascii2d.ASCII2d(pic); err != nil { + result, err := ascii2d.ASCII2d(pic) + if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) continue - } else { - msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))} - for i := 0; i < len(result) && i < 5; i++ { - msg = append(msg, ctxext.FakeSenderForwardNode(ctx, - message.Image(result[i].Thumb), - message.Text(fmt.Sprintf( - "标题: %s\n图源: %s\n画师: %s\n画师链接: %s\n图片链接: %s", - result[i].Name, - result[i].Type, - result[i].AuthNm, - result[i].Author, - result[i].Link, - ))), - ) - } - if id := ctx.Send(msg).ID(); id == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) - } + } + msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))} + for i := 0; i < len(result) && i < 5; i++ { + msg = append(msg, ctxext.FakeSenderForwardNode(ctx, + message.Image(result[i].Thumb), + message.Text(fmt.Sprintf( + "标题: %s\n图源: %s\n画师: %s\n画师链接: %s\n图片链接: %s", + result[i].Name, + result[i].Type, + result[i].AuthNm, + result[i].Author, + result[i].Link, + ))), + ) + } + if id := ctx.Send(msg).ID(); id == 0 { + ctx.SendChain(message.Text("ERROR: 可能被风控了")) } } }) diff --git a/plugin/setutime/setu_geter.go b/plugin/setutime/setu_geter.go index b01370e0..b03c3328 100644 --- a/plugin/setutime/setu_geter.go +++ b/plugin/setutime/setu_geter.go @@ -236,10 +236,7 @@ func (p *imgpool) add(ctx *zero.Ctx, imgtype string, id int64) error { return err } // 添加插画到对应的数据库table - if err := p.db.Insert(imgtype, illust); err != nil { - return err - } - return nil + return p.db.Insert(imgtype, illust) } func (p *imgpool) remove(imgtype string, id int64) error { diff --git a/plugin/sleep_manage/sleep_manage.go b/plugin/sleep_manage/sleep_manage.go index 0b346e2f..d7d5b2be 100644 --- a/plugin/sleep_manage/sleep_manage.go +++ b/plugin/sleep_manage/sleep_manage.go @@ -55,13 +55,13 @@ func timeDuration(time time.Duration) (hour, minute, second int64) { } // 只统计6点到12点的早安 -func isMorning(ctx *zero.Ctx) bool { +func isMorning(*zero.Ctx) bool { now := time.Now().Hour() return now >= 6 && now <= 12 } // 只统计21点到凌晨3点的晚安 -func isEvening(ctx *zero.Ctx) bool { +func isEvening(*zero.Ctx) bool { now := time.Now().Hour() return now >= 21 || now <= 3 } diff --git a/plugin/steam/listenter.go b/plugin/steam/listenter.go index 9cf2ca34..97682655 100644 --- a/plugin/steam/listenter.go +++ b/plugin/steam/listenter.go @@ -53,9 +53,9 @@ func init() { // 收集这波用户的streamId,然后查当前的状态,并建立信息映射表 streamIds := make([]string, len(infos)) localPlayerMap := make(map[int64]*player) - for i, info := range infos { - streamIds[i] = strconv.FormatInt(info.SteamID, 10) - localPlayerMap[info.SteamID] = info + for i := 0; i < len(infos); i++ { + streamIds[i] = strconv.FormatInt(infos[i].SteamID, 10) + localPlayerMap[infos[i].SteamID] = &infos[i] } // 将所有用户状态查一遍 playerStatus, err := getPlayerStatus(streamIds...) diff --git a/plugin/steam/store.go b/plugin/steam/store.go index 16c93444..171a60f7 100644 --- a/plugin/steam/store.go +++ b/plugin/steam/store.go @@ -91,7 +91,7 @@ func (sql *streamDB) findWithGroupID(steamID int64, groupID string) (dbInfo play } // findAll 查询所有库信息 -func (sql *streamDB) findAll() (dbInfos []*player, err error) { +func (sql *streamDB) findAll() (dbInfos []player, err error) { sql.Lock() defer sql.Unlock() var info player @@ -99,10 +99,10 @@ func (sql *streamDB) findAll() (dbInfos []*player, err error) { if err != nil || num == 0 { return } - dbInfos = make([]*player, 0, num) + dbInfos = make([]player, 0, num) err = sql.db.FindFor(TableListenPlayer, &info, "", func() error { if info.SteamID != 0 { - dbInfos = append(dbInfos, &info) + dbInfos = append(dbInfos, info) } return nil })