From c9033f59d290cddb2c2af4704f3bac24d342208c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com> Date: Tue, 16 Sep 2025 23:21:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=E4=BF=AE=E6=94=B9=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/rsshub/domain/job.go | 5 +++-- plugin/rsshub/domain/model.go | 7 +++++-- plugin/rsshub/main.go | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/plugin/rsshub/domain/job.go b/plugin/rsshub/domain/job.go index b6e4fb64..1763743a 100644 --- a/plugin/rsshub/domain/job.go +++ b/plugin/rsshub/domain/job.go @@ -58,7 +58,7 @@ func (repo *rssDomain) syncRss(ctx context.Context) (updated map[int64]*RssClien } } var updateChannelView = &RssClientView{Source: cv.Source, Contents: []*RssContent{}} - err = repo.processContentsUpdate(ctx, cv, err, updateChannelView) + err = repo.processContentsUpdate(ctx, cv, updateChannelView) if err != nil { logrus.WithContext(ctx).Errorf("[rsshub syncRss] processContentsUpdate error: %v", err) continue @@ -94,7 +94,8 @@ func (repo *rssDomain) checkSourceNeedUpdate(ctx context.Context, source *RssSou } // processContentsUpdate 处理内容(s)更新 -func (repo *rssDomain) processContentsUpdate(ctx context.Context, cv *RssClientView, err error, updateChannelView *RssClientView) error { +func (repo *rssDomain) processContentsUpdate(ctx context.Context, cv *RssClientView, updateChannelView *RssClientView) error { + var err error for _, content := range cv.Contents { if content == nil { continue diff --git a/plugin/rsshub/domain/model.go b/plugin/rsshub/domain/model.go index 8c7d34ce..3e3e2cd6 100644 --- a/plugin/rsshub/domain/model.go +++ b/plugin/rsshub/domain/model.go @@ -10,9 +10,12 @@ import ( // ======== RSS ========[START] func genHashForFeedItem(link, guid string) string { - idString := link + "||" + guid h := fnv.New32() - _, _ = h.Write([]byte(idString)) + // 分三次写入数据:link、分隔符、guid + _, _ = h.Write([]byte(link)) + _, _ = h.Write([]byte("||")) + _, _ = h.Write([]byte(guid)) + encoded := hex.EncodeToString(h.Sum(nil)) return encoded } diff --git a/plugin/rsshub/main.go b/plugin/rsshub/main.go index 7803d4ef..ff4cce10 100644 --- a/plugin/rsshub/main.go +++ b/plugin/rsshub/main.go @@ -74,8 +74,8 @@ func init() { sendRssUpdateMsg(ctx, groupToFeedsMap) }) // 添加订阅 - engine.OnRegex(`^添加rsshub订阅-(.+)$`, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) { - routeStr := ctx.State["regex_matched"].([]string)[1] + engine.OnPrefix("添加rsshub订阅-", zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) { + routeStr := ctx.State["args"].(string) input := regexpForSQL.ReplaceAllString(routeStr, "") logrus.Debugf("添加rsshub订阅:raw(%s), replaced(%s)", routeStr, input) rv, _, isSubExisted, err := rssRepo.Subscribe(context.Background(), ctx.Event.GroupID, input) @@ -98,8 +98,8 @@ func init() { ctx.SendChain(message.Text("ERROR: 发送订阅源快照失败,可能被风控了")) } }) - engine.OnRegex(`^删除rsshub订阅-(.+)$`, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) { - routeStr := ctx.State["regex_matched"].([]string)[1] + engine.OnPrefix("删除rsshub订阅-", zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) { + routeStr := ctx.State["args"].(string) input := regexpForSQL.ReplaceAllString(routeStr, "") logrus.Debugf("删除rsshub订阅:raw(%s), replaced(%s)", routeStr, input) err := rssRepo.Unsubscribe(context.Background(), ctx.Event.GroupID, input)