Skip to content

Commit

Permalink
fix: unsort bug
Browse files Browse the repository at this point in the history
  • Loading branch information
uerax committed Sep 20, 2024
1 parent 5e0aef9 commit 2e220b5
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions bbs/nodeseek.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (

type Nodeseek struct {
C chan string
latest string
latest int64
keyword []string
}

func NewNodeseek() *Nodeseek {
k := []string{"甲骨文", "升级号", "oracle"}
n := &Nodeseek{
C: make(chan string),
latest: "",
latest: 0,
keyword: k,
}
return n
Expand All @@ -40,7 +40,7 @@ func (t *Nodeseek) nodeseek() {
Description string `xml:"description"`
Link string `xml:"link"`
PubDate string `xml:"pubDate"`
Guid string `xml:"guid"`
Guid int64 `xml:"guid"`
}
type Channel struct {
Item []*Item `xml:"item"`
Expand All @@ -66,13 +66,14 @@ func (t *Nodeseek) nodeseek() {
return
}
msg := ""
for i, v := range bbs.Channel.Item {
if t.latest == v.Guid {
break
}
if i == 0 {
t.latest = v.Guid
latest := t.latest
for _, v := range bbs.Channel.Item {
if t.latest > v.Guid {
continue
}
if latest < v.Guid {
latest = v.Guid
}
v.Title = strings.ToLower(strings.TrimSpace(v.Title))
for _, k := range t.keyword {
if strings.Contains(v.Title, k) {
Expand All @@ -82,6 +83,10 @@ func (t *Nodeseek) nodeseek() {
}
}

if latest > t.latest {
t.latest = latest
}

if msg != "" {
t.C <- "*NodeSeek新帖:*\n" + msg
}
Expand Down

0 comments on commit 2e220b5

Please sign in to comment.