Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion plugin/atri/atri.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
38 changes: 19 additions & 19 deletions plugin/saucenao/searcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: 可能被风控了"))
}
}
})
Expand Down
5 changes: 1 addition & 4 deletions plugin/setutime/setu_geter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions plugin/sleep_manage/sleep_manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions plugin/steam/listenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
6 changes: 3 additions & 3 deletions plugin/steam/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ 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
num, err := sql.db.Count(TableListenPlayer)
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
})
Expand Down