-
Notifications
You must be signed in to change notification settings - Fork 2k
添加rsshub #1203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
添加rsshub #1203
Conversation
plugin/rsshub/domain/job.go
Outdated
} | ||
|
||
// processContentsUpdate 处理内容(s)更新 | ||
func (repo *rssDomain) processContentsUpdate(ctx context.Context, cv *RssClientView, err error, updateChannelView *RssClientView) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个err放在入参有什么用
plugin/rsshub/domain/model.go
Outdated
func genHashForFeedItem(link, guid string) string { | ||
idString := link + "||" + guid | ||
h := fnv.New32() | ||
_, _ = h.Write([]byte(idString)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接write三次不就好了,不用拼接
plugin/rsshub/domain/rssHub.go
Outdated
) | ||
|
||
// RssDomain RssRepo定义 | ||
type RssDomain interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里用接口有什么用呢
plugin/rsshub/domain/storageRepo.go
Outdated
) | ||
|
||
// RepoStorage 定义RepoStorage接口 | ||
type RepoStorage interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你有很多实现吗?没有的话感觉没必要用接口
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
经过分析 ZeroBot-Plugin 的 RSSHub 插件代码,RssDomain 和 RepoStorage 接口的设计非常有意义,体现了良好的软件架构设计原则:
RssDomain 接口的意义
-
业务逻辑抽象:RssDomain 接口定义了 RSS 订阅的核心业务操作,包括订阅、取消订阅、获取订阅列表和同步功能,将业务逻辑与具体实现分离。
-
领域驱动设计:符合 DDD(领域驱动设计)原则,RssDomain 作为领域服务,封装了 RSS 订阅的核心业务规则和流程。
-
依赖倒置:RssDomain 依赖于 RepoStorage 接口而非具体实现,使得数据存储层可以灵活替换。
-
单一职责:每个方法都专注于一个明确的业务功能,职责清晰。
RepoStorage 接口的意义
-
接口隔离原则:RepoStorage 组合了多个细粒度接口(RepoContent、RepoSource、RepoSubscribe、RepoMultiQuery),遵循接口隔离原则,客户端只需要依赖它们需要的方法。
-
数据访问抽象:将数据存储操作抽象为接口,使得可以轻松切换不同的存储实现(如 SQLite、MySQL、PostgreSQL等)。
-
职责分离:
- RepoContent:管理 RSS 内容文章
- RepoSource:管理 RSS 源信息
- RepoSubscribe:管理订阅关系
- RepoMultiQuery:处理复杂的多表查询
-
可测试性:接口设计使得可以轻松创建 mock 实现进行单元测试。
架构优势
- 可维护性:清晰的层次结构使得代码易于理解和维护
- 可扩展性:可以轻松添加新的存储实现或业务功能
- 可测试性:接口使得单元测试和集成测试更加容易
- 松耦合:业务层和数据层解耦,降低系统复杂性
总结
RssDomain 和 RepoStorage 接口的设计非常有意义,体现了现代软件工程的优秀实践:
- 遵循 SOLID 原则
- 采用领域驱动设计
- 实现清晰的架构分层
- 提供良好的扩展性和维护性
这种设计使得 RSSHub 插件能够灵活应对需求变化,并且易于测试和维护。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ai说啥你就听啥吗,现在的ai只会顺着你的话往下说,你换一种问法,他就给出不同的答案。😂你要是真的接很多个数据库那用接口我不说啥,但是我们这个只有一个数据库。要不你就把它打包成一个外部包,然后引入进来,这样的话你这个外部包之后可以接其他数据库。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plugin/rsshub/main.go
Outdated
sendRssUpdateMsg(ctx, groupToFeedsMap) | ||
}) | ||
// 添加订阅 | ||
engine.OnRegex(`^添加rsshub订阅-(.+)$`, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用OnPrefix
plugin/rsshub/main.go
Outdated
ctx.SendChain(message.Text("ERROR: 发送订阅源快照失败,可能被风控了")) | ||
} | ||
}) | ||
engine.OnRegex(`^删除rsshub订阅-(.+)$`, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
你怎么merge崩了 |
没merge完
Sent from my iPhone
…------------------ 原始邮件 ------------------
发件人: fumiama ***@***.***>
发送时间: 2025年9月30日 17:08
收件人: FloatTech/ZeroBot-Plugin ***@***.***>
抄送: himawari ***@***.***>, Author ***@***.***>
主题: Re: [FloatTech/ZeroBot-Plugin] 添加rsshub (PR #1203)
fumiama left a comment (FloatTech/ZeroBot-Plugin#1203)
你怎么merge崩了
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
No description provided.