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)