mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 06:20:08 +08:00
🎨 修改命令
This commit is contained in:
parent
5b6f21d0ae
commit
c9033f59d2
@ -58,7 +58,7 @@ func (repo *rssDomain) syncRss(ctx context.Context) (updated map[int64]*RssClien
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var updateChannelView = &RssClientView{Source: cv.Source, Contents: []*RssContent{}}
|
var updateChannelView = &RssClientView{Source: cv.Source, Contents: []*RssContent{}}
|
||||||
err = repo.processContentsUpdate(ctx, cv, err, updateChannelView)
|
err = repo.processContentsUpdate(ctx, cv, updateChannelView)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithContext(ctx).Errorf("[rsshub syncRss] processContentsUpdate error: %v", err)
|
logrus.WithContext(ctx).Errorf("[rsshub syncRss] processContentsUpdate error: %v", err)
|
||||||
continue
|
continue
|
||||||
@ -94,7 +94,8 @@ func (repo *rssDomain) checkSourceNeedUpdate(ctx context.Context, source *RssSou
|
|||||||
}
|
}
|
||||||
|
|
||||||
// processContentsUpdate 处理内容(s)更新
|
// 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 {
|
for _, content := range cv.Contents {
|
||||||
if content == nil {
|
if content == nil {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@ -10,9 +10,12 @@ import (
|
|||||||
// ======== RSS ========[START]
|
// ======== RSS ========[START]
|
||||||
|
|
||||||
func genHashForFeedItem(link, guid string) string {
|
func genHashForFeedItem(link, guid string) string {
|
||||||
idString := link + "||" + guid
|
|
||||||
h := fnv.New32()
|
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))
|
encoded := hex.EncodeToString(h.Sum(nil))
|
||||||
return encoded
|
return encoded
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,8 +74,8 @@ func init() {
|
|||||||
sendRssUpdateMsg(ctx, groupToFeedsMap)
|
sendRssUpdateMsg(ctx, groupToFeedsMap)
|
||||||
})
|
})
|
||||||
// 添加订阅
|
// 添加订阅
|
||||||
engine.OnRegex(`^添加rsshub订阅-(.+)$`, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnPrefix("添加rsshub订阅-", zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||||
routeStr := ctx.State["regex_matched"].([]string)[1]
|
routeStr := ctx.State["args"].(string)
|
||||||
input := regexpForSQL.ReplaceAllString(routeStr, "")
|
input := regexpForSQL.ReplaceAllString(routeStr, "")
|
||||||
logrus.Debugf("添加rsshub订阅:raw(%s), replaced(%s)", routeStr, input)
|
logrus.Debugf("添加rsshub订阅:raw(%s), replaced(%s)", routeStr, input)
|
||||||
rv, _, isSubExisted, err := rssRepo.Subscribe(context.Background(), ctx.Event.GroupID, input)
|
rv, _, isSubExisted, err := rssRepo.Subscribe(context.Background(), ctx.Event.GroupID, input)
|
||||||
@ -98,8 +98,8 @@ func init() {
|
|||||||
ctx.SendChain(message.Text("ERROR: 发送订阅源快照失败,可能被风控了"))
|
ctx.SendChain(message.Text("ERROR: 发送订阅源快照失败,可能被风控了"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
engine.OnRegex(`^删除rsshub订阅-(.+)$`, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnPrefix("删除rsshub订阅-", zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||||
routeStr := ctx.State["regex_matched"].([]string)[1]
|
routeStr := ctx.State["args"].(string)
|
||||||
input := regexpForSQL.ReplaceAllString(routeStr, "")
|
input := regexpForSQL.ReplaceAllString(routeStr, "")
|
||||||
logrus.Debugf("删除rsshub订阅:raw(%s), replaced(%s)", routeStr, input)
|
logrus.Debugf("删除rsshub订阅:raw(%s), replaced(%s)", routeStr, input)
|
||||||
err := rssRepo.Unsubscribe(context.Background(), ctx.Event.GroupID, input)
|
err := rssRepo.Unsubscribe(context.Background(), ctx.Event.GroupID, input)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user