feat: add reply comment functionality for Xiaohongshu feeds

- Implemented handleReplyComment method in mcp_handlers.go to manage replying to comments on feeds.
- Introduced ReplyCommentArgs struct in mcp_server.go for handling parameters related to comment replies.
- Registered a new MCP tool for replying to comments in the registerTools function.
- Added ReplyCommentToFeed method in service.go to interact with the Xiaohongshu platform for comment replies.
- Enhanced error handling for missing parameters in the reply process.
This commit is contained in:
chekayo
2025-10-09 23:49:40 +08:00
parent 408c641959
commit cff1705c5b
3 changed files with 130 additions and 3 deletions

View File

@@ -443,6 +443,21 @@ func (s *XiaohongshuService) UnfavoriteFeed(ctx context.Context, feedID, xsecTok
return &ActionResult{FeedID: feedID, Success: true, Message: "取消收藏成功或未收藏"}, nil
}
// ReplyCommentToFeed 回复笔记评论
func (s *XiaohongshuService) ReplyCommentToFeed(ctx context.Context, feedID, xsecToken, commentID, userID, content string) (*ActionResult, error) {
b := newBrowser()
defer b.Close()
page := b.NewPage()
defer page.Close()
action := xiaohongshu.NewCommentFeedAction(page)
if err := action.ReplyToComment(ctx, feedID, xsecToken, commentID, userID, content); err != nil {
return nil, err
}
return &ActionResult{FeedID: feedID, Success: true, Message: "回复评论成功"}, nil
}
func newBrowser() *headless_browser.Browser {
return browser.NewBrowser(configs.IsHeadless(), browser.WithBinPath(configs.GetBinPath()))
}