Skip to content

Commit e020bf0

Browse files
committed
✨ 添加rsshub推送
1 parent e6a4dfc commit e020bf0

File tree

13 files changed

+1294
-0
lines changed

13 files changed

+1294
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,17 @@ print("run[CQ:image,file="+j["img"]+"]")
12841284

12851285
- [x] 打劫[对方Q号|@对方QQ]
12861286

1287+
</details>
1288+
<details>
1289+
<summary>RSSHub</summary>
1290+
1291+
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/rsshub"`
1292+
1293+
- [x] 添加rsshub订阅-/bookfere/weekly
1294+
- [x] 删除rsshub订阅-/bookfere/weekly
1295+
- [x] 查看rsshub订阅列表
1296+
- [x] rsshub同步 (使用job执行定时任务------记录在"@every 10m"触发的指令)
1297+
12871298
</details>
12881299
<details>
12891300
<summary>在线代码运行</summary>

go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ require (
3838
github.com/kanrichan/resvg-go v0.0.2-0.20231001163256-63db194ca9f5
3939
github.com/lithammer/fuzzysearch v1.1.8
4040
github.com/liuzl/gocc v0.0.0-20231231122217-0372e1059ca5
41+
github.com/mmcdole/gofeed v1.3.0
4142
github.com/mroth/weightedrand v1.0.0
4243
github.com/notnil/chess v1.9.0
4344
github.com/pkg/errors v0.9.1
@@ -54,8 +55,10 @@ require (
5455
)
5556

5657
require (
58+
github.com/PuerkitoBio/goquery v1.8.0 // indirect
5759
github.com/adamzy/cedar-go v0.0.0-20170805034717-80a9c64b256d // indirect
5860
github.com/ajstarks/svgo v0.0.0-20200320125537-f189e35d30ca // indirect
61+
github.com/andybalholm/cascadia v1.3.1 // indirect
5962
github.com/antchfx/xpath v1.3.3 // indirect
6063
github.com/dustin/go-humanize v1.0.1 // indirect
6164
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 // indirect
@@ -70,10 +73,14 @@ require (
7073
github.com/jfreymuth/oggvorbis v1.0.1 // indirect
7174
github.com/jfreymuth/vorbis v1.0.0 // indirect
7275
github.com/jinzhu/inflection v1.0.0 // indirect
76+
github.com/json-iterator/go v1.1.12 // indirect
7377
github.com/liuzl/cedar-go v0.0.0-20170805034717-80a9c64b256d // indirect
7478
github.com/liuzl/da v0.0.0-20180704015230-14771aad5b1d // indirect
7579
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
7680
github.com/mattn/go-isatty v0.0.20 // indirect
81+
github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23 // indirect
82+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
83+
github.com/modern-go/reflect2 v1.0.2 // indirect
7784
github.com/ncruces/go-strftime v0.1.9 // indirect
7885
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
7986
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect

go.sum

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ github.com/FloatTech/zbpctrl v1.7.0/go.mod h1:xmM4dSwHA02Gei3ogCRiG+RTrw/7Z69Pfr
2020
github.com/FloatTech/zbputils v1.7.2-0.20250812085410-2741050f465f h1:5jnrFe9FTydb/pcUhxkWHuQVCwmYIZmneOkvmgHOwGI=
2121
github.com/FloatTech/zbputils v1.7.2-0.20250812085410-2741050f465f/go.mod h1:HG/yZwExV3b1Vqu4chbqwhfX4hx7gDS07QO436JkwIg=
2222
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
23+
github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U=
24+
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
2325
github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7 h1:S/ferNiehVjNaBMNNBxUjLtVmP/YWD6Yh79RfPv4ehU=
2426
github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w=
2527
github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 h1:bBmmB7he0iVN4m5mcehfheeRUEer/Avo4ujnxI3uCqs=
@@ -31,6 +33,8 @@ github.com/adamzy/cedar-go v0.0.0-20170805034717-80a9c64b256d/go.mod h1:PRWNwWq0
3133
github.com/ajstarks/svgo v0.0.0-20200320125537-f189e35d30ca h1:kWzLcty5V2rzOqJM7Tp/MfSX0RMSI1x4IOLApEefYxA=
3234
github.com/ajstarks/svgo v0.0.0-20200320125537-f189e35d30ca/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
3335
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
36+
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
37+
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
3438
github.com/antchfx/htmlquery v1.3.4 h1:Isd0srPkni2iNTWCwVj/72t7uCphFeor5Q8nCzj1jdQ=
3539
github.com/antchfx/htmlquery v1.3.4/go.mod h1:K9os0BwIEmLAvTqaNSua8tXLWRWZpocZIH73OzWQbwM=
3640
github.com/antchfx/xpath v1.3.3 h1:tmuPQa1Uye0Ym1Zn65vxPgfltWb/Lxu2jeqIGteJSRs=
@@ -108,6 +112,7 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4er
108112
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
109113
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
110114
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
115+
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
111116
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
112117
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
113118
github.com/hajimehoshi/go-mp3 v0.3.0/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
@@ -128,6 +133,8 @@ github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/
128133
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
129134
github.com/jozsefsallai/gophersauce v1.0.1 h1:BA3ovtQRrAb1qYU9JoRLbDHpxnDunlNcEkEfhCvDDCM=
130135
github.com/jozsefsallai/gophersauce v1.0.1/go.mod h1:YVEI7djliMTmZ1Vh01YPF8bUHi+oKhe3yXgKf1T49vg=
136+
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
137+
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
131138
github.com/kanrichan/resvg-go v0.0.2-0.20231001163256-63db194ca9f5 h1:BXnB1Gz4y/zwQh+ZFNy7rgd+ZfMOrwRr4uZSHEI+ieY=
132139
github.com/kanrichan/resvg-go v0.0.2-0.20231001163256-63db194ca9f5/go.mod h1:c9+VS9GaommgIOzNWb5ze4lYwfT8BZ2UDyGiuQTT7yc=
133140
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
@@ -150,6 +157,15 @@ github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/
150157
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
151158
github.com/mewkiz/flac v1.0.7/go.mod h1:yU74UH277dBUpqxPouHSQIar3G1X/QIclVbFahSd1pU=
152159
github.com/mewkiz/pkg v0.0.0-20190919212034-518ade7978e2/go.mod h1:3E2FUC/qYUfM8+r9zAwpeHJzqRVVMIYnpzD/clwWxyA=
160+
github.com/mmcdole/gofeed v1.3.0 h1:5yn+HeqlcvjMeAI4gu6T+crm7d0anY85+M+v6fIFNG4=
161+
github.com/mmcdole/gofeed v1.3.0/go.mod h1:9TGv2LcJhdXePDzxiuMnukhV2/zb6VtnZt1mS+SjkLE=
162+
github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23 h1:Zr92CAlFhy2gL+V1F+EyIuzbQNbSgP4xhTODZtrXUtk=
163+
github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23/go.mod h1:v+25+lT2ViuQ7mVxcncQ8ch1URund48oH+jhjiwEgS8=
164+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
165+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
166+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
167+
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
168+
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
153169
github.com/mroth/weightedrand v1.0.0 h1:V8JeHChvl2MP1sAoXq4brElOcza+jxLkRuwvtQu8L3E=
154170
github.com/mroth/weightedrand v1.0.0/go.mod h1:3p2SIcC8al1YMzGhAIoXD+r9olo/g/cdJgAD905gyNE=
155171
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
@@ -179,6 +195,7 @@ github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
179195
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
180196
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
181197
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
198+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
182199
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
183200
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
184201
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
@@ -240,6 +257,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
240257
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
241258
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
242259
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
260+
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
243261
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
244262
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
245263
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
@@ -265,6 +283,7 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w
265283
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
266284
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
267285
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
286+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
268287
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
269288
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
270289
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -290,6 +309,7 @@ golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
290309
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
291310
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
292311
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
312+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
293313
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
294314
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
295315
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ import (
132132
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/realcugan" // realcugan清晰术
133133
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/reborn" // 投胎
134134
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/robbery" // 打劫群友的ATRI币
135+
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/rsshub" // RSSHub订阅姬
135136
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode" // 在线运行代码
136137
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/saucenao" // 以图搜图
137138
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/score" // 分数

plugin/rsshub/domain/job.go

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
// Package domain rsshub领域逻辑
2+
package domain
3+
4+
import (
5+
"context"
6+
7+
"github.com/mmcdole/gofeed"
8+
"github.com/sirupsen/logrus"
9+
)
10+
11+
// syncRss 同步所有频道
12+
// 返回:更新的频道&订阅信息 map[int64]*RssClientView
13+
// 1. 获取所有频道
14+
// 2. 遍历所有频道,检查频道是否更新
15+
// 3. 如果更新,获取更新的内容,但是返回的数据
16+
func (repo *rssDomain) syncRss(ctx context.Context) (updated map[int64]*RssClientView, err error) {
17+
updated = make(map[int64]*RssClientView)
18+
// 获取所有频道
19+
sources, err := repo.storage.GetSources(ctx)
20+
if err != nil {
21+
return
22+
}
23+
// 遍历所有源,获取每个channel对应的rss内容
24+
rssView := make([]*RssClientView, len(sources))
25+
for i, channel := range sources {
26+
var feed *gofeed.Feed
27+
// 从site获取rss内容
28+
feed, err = repo.rssHubClient.FetchFeed(channel.RssHubFeedPath)
29+
// 如果获取失败,则跳过
30+
if err != nil {
31+
logrus.WithContext(ctx).Errorf("[rsshub syncRss] fetch path(%+v) error: %v", channel.RssHubFeedPath, err)
32+
continue
33+
}
34+
rv := convertFeedToRssView(0, channel.RssHubFeedPath, feed)
35+
rssView[i] = rv
36+
}
37+
// 检查频道是否更新
38+
for _, cv := range rssView {
39+
if cv == nil {
40+
continue
41+
}
42+
var needUpdate bool
43+
needUpdate, err = repo.checkSourceNeedUpdate(ctx, cv.Source)
44+
if err != nil {
45+
logrus.WithContext(ctx).Errorf("[rsshub syncRss] checkSourceNeedUpdate error: %v", err)
46+
err = nil
47+
continue
48+
}
49+
// 保存
50+
logrus.WithContext(ctx).Infof("[rsshub syncRss] cv %+v, need update(real): %v", cv.Source, needUpdate)
51+
// 如果需要更新,更新channel 和 content
52+
if needUpdate {
53+
err = repo.storage.UpsertSource(ctx, cv.Source)
54+
if err != nil {
55+
logrus.WithContext(ctx).Errorf("[rsshub syncRss] upsert source error: %v", err)
56+
err = nil
57+
// continue
58+
}
59+
}
60+
var updateChannelView = &RssClientView{Source: cv.Source, Contents: []*RssContent{}}
61+
err = repo.processContentsUpdate(ctx, cv, err, updateChannelView)
62+
if err != nil {
63+
logrus.WithContext(ctx).Errorf("[rsshub syncRss] processContentsUpdate error: %v", err)
64+
continue
65+
}
66+
if len(updateChannelView.Contents) == 0 {
67+
logrus.WithContext(ctx).Infof("[rsshub syncRss] cv %s, no new content", cv.Source.RssHubFeedPath)
68+
continue
69+
}
70+
updateChannelView.Sort()
71+
updated[updateChannelView.Source.ID] = updateChannelView
72+
logrus.WithContext(ctx).Debugf("[rsshub syncRss] cv %s, new contents: %v", cv.Source.RssHubFeedPath, len(updateChannelView.Contents))
73+
}
74+
return
75+
}
76+
77+
// checkSourceNeedUpdate 检查频道是否需要更新
78+
func (repo *rssDomain) checkSourceNeedUpdate(ctx context.Context, source *RssSource) (needUpdate bool, err error) {
79+
var sourceInDB *RssSource
80+
sourceInDB, err = repo.storage.GetSourceByRssHubFeedLink(ctx, source.RssHubFeedPath)
81+
if err != nil {
82+
return
83+
}
84+
if sourceInDB == nil {
85+
logrus.WithContext(ctx).Errorf("[rsshub syncRss] source not found: %v", source.RssHubFeedPath)
86+
return
87+
}
88+
source.ID = sourceInDB.ID
89+
// 检查是否需要更新到db
90+
if sourceInDB.IfNeedUpdate(source) {
91+
needUpdate = true
92+
}
93+
return
94+
}
95+
96+
// processContentsUpdate 处理内容(s)更新
97+
func (repo *rssDomain) processContentsUpdate(ctx context.Context, cv *RssClientView, err error, updateChannelView *RssClientView) error {
98+
for _, content := range cv.Contents {
99+
if content == nil {
100+
continue
101+
}
102+
content.RssSourceID = cv.Source.ID
103+
var existed bool
104+
existed, err = repo.processContentItemUpdate(ctx, content)
105+
if err != nil {
106+
logrus.WithContext(ctx).Errorf("[rsshub syncRss] upsert content error: %v", err)
107+
err = nil
108+
continue
109+
}
110+
if !existed {
111+
updateChannelView.Contents = append(updateChannelView.Contents, content)
112+
logrus.WithContext(ctx).Infof("[rsshub syncRss] cv %s, add new content: %v", cv.Source.RssHubFeedPath, content.Title)
113+
}
114+
}
115+
return err
116+
}
117+
118+
// processContentItemUpdate 处理单个内容更新
119+
func (repo *rssDomain) processContentItemUpdate(ctx context.Context, content *RssContent) (existed bool, err error) {
120+
existed, err = repo.storage.IsContentHashIDExist(ctx, content.HashID)
121+
if err != nil {
122+
return
123+
}
124+
// 不需要更新&不需要发送
125+
if existed {
126+
return
127+
}
128+
// 保存
129+
err = repo.storage.UpsertContent(ctx, content)
130+
if err != nil {
131+
logrus.WithContext(ctx).Errorf("[rsshub syncRss] upsert content error: %v", err)
132+
return
133+
}
134+
return
135+
}

0 commit comments

Comments
 (0)