Skip to content

Commit c9033f5

Browse files
committed
🎨 修改命令
1 parent 5b6f21d commit c9033f5

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

plugin/rsshub/domain/job.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (repo *rssDomain) syncRss(ctx context.Context) (updated map[int64]*RssClien
5858
}
5959
}
6060
var updateChannelView = &RssClientView{Source: cv.Source, Contents: []*RssContent{}}
61-
err = repo.processContentsUpdate(ctx, cv, err, updateChannelView)
61+
err = repo.processContentsUpdate(ctx, cv, updateChannelView)
6262
if err != nil {
6363
logrus.WithContext(ctx).Errorf("[rsshub syncRss] processContentsUpdate error: %v", err)
6464
continue
@@ -94,7 +94,8 @@ func (repo *rssDomain) checkSourceNeedUpdate(ctx context.Context, source *RssSou
9494
}
9595

9696
// processContentsUpdate 处理内容(s)更新
97-
func (repo *rssDomain) processContentsUpdate(ctx context.Context, cv *RssClientView, err error, updateChannelView *RssClientView) error {
97+
func (repo *rssDomain) processContentsUpdate(ctx context.Context, cv *RssClientView, updateChannelView *RssClientView) error {
98+
var err error
9899
for _, content := range cv.Contents {
99100
if content == nil {
100101
continue

plugin/rsshub/domain/model.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ import (
1010
// ======== RSS ========[START]
1111

1212
func genHashForFeedItem(link, guid string) string {
13-
idString := link + "||" + guid
1413
h := fnv.New32()
15-
_, _ = h.Write([]byte(idString))
14+
// 分三次写入数据:link、分隔符、guid
15+
_, _ = h.Write([]byte(link))
16+
_, _ = h.Write([]byte("||"))
17+
_, _ = h.Write([]byte(guid))
18+
1619
encoded := hex.EncodeToString(h.Sum(nil))
1720
return encoded
1821
}

plugin/rsshub/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ func init() {
7474
sendRssUpdateMsg(ctx, groupToFeedsMap)
7575
})
7676
// 添加订阅
77-
engine.OnRegex(`^添加rsshub订阅-(.+)$`, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
78-
routeStr := ctx.State["regex_matched"].([]string)[1]
77+
engine.OnPrefix("添加rsshub订阅-", zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
78+
routeStr := ctx.State["args"].(string)
7979
input := regexpForSQL.ReplaceAllString(routeStr, "")
8080
logrus.Debugf("添加rsshub订阅:raw(%s), replaced(%s)", routeStr, input)
8181
rv, _, isSubExisted, err := rssRepo.Subscribe(context.Background(), ctx.Event.GroupID, input)
@@ -98,8 +98,8 @@ func init() {
9898
ctx.SendChain(message.Text("ERROR: 发送订阅源快照失败,可能被风控了"))
9999
}
100100
})
101-
engine.OnRegex(`^删除rsshub订阅-(.+)$`, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
102-
routeStr := ctx.State["regex_matched"].([]string)[1]
101+
engine.OnPrefix("删除rsshub订阅-", zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
102+
routeStr := ctx.State["args"].(string)
103103
input := regexpForSQL.ReplaceAllString(routeStr, "")
104104
logrus.Debugf("删除rsshub订阅:raw(%s), replaced(%s)", routeStr, input)
105105
err := rssRepo.Unsubscribe(context.Background(), ctx.Event.GroupID, input)

0 commit comments

Comments
 (0)