feat: 添加定时发布功能 (#377)
- publish_content 和 publish_with_video 支持 schedule_at 参数 - 支持 ISO8601 格式时间,范围为 1 小时至 14 天 - 优化页面导航等待策略,提升发布稳定性 Co-authored-by: tanjun <tanjun@tanjundeMac-mini.local> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,18 +17,20 @@ func boolPtr(b bool) *bool { return &b }
|
||||
|
||||
// PublishContentArgs 发布内容的参数
|
||||
type PublishContentArgs struct {
|
||||
Title string `json:"title" jsonschema:"内容标题(小红书限制:最多20个中文字或英文单词)"`
|
||||
Content string `json:"content" jsonschema:"正文内容,不包含以#开头的标签内容,所有话题标签都用tags参数来生成和提供即可"`
|
||||
Images []string `json:"images" jsonschema:"图片路径列表(至少需要1张图片)。支持两种方式:1. HTTP/HTTPS图片链接(自动下载);2. 本地图片绝对路径(推荐,如:/Users/user/image.jpg)"`
|
||||
Tags []string `json:"tags,omitempty" jsonschema:"话题标签列表(可选参数),如 [美食, 旅行, 生活]"`
|
||||
Title string `json:"title" jsonschema:"内容标题(小红书限制:最多20个中文字或英文单词)"`
|
||||
Content string `json:"content" jsonschema:"正文内容,不包含以#开头的标签内容,所有话题标签都用tags参数来生成和提供即可"`
|
||||
Images []string `json:"images" jsonschema:"图片路径列表(至少需要1张图片)。支持两种方式:1. HTTP/HTTPS图片链接(自动下载);2. 本地图片绝对路径(推荐,如:/Users/user/image.jpg)"`
|
||||
Tags []string `json:"tags,omitempty" jsonschema:"话题标签列表(可选参数),如 [美食, 旅行, 生活]"`
|
||||
ScheduleAt string `json:"schedule_at,omitempty" jsonschema:"定时发布时间(可选),ISO8601格式如 2024-01-20T10:30:00+08:00,支持1小时至14天内。不填则立即发布"`
|
||||
}
|
||||
|
||||
// PublishVideoArgs 发布视频的参数(仅支持本地单个视频文件)
|
||||
type PublishVideoArgs struct {
|
||||
Title string `json:"title" jsonschema:"内容标题(小红书限制:最多20个中文字或英文单词)"`
|
||||
Content string `json:"content" jsonschema:"正文内容,不包含以#开头的标签内容,所有话题标签都用tags参数来生成和提供即可"`
|
||||
Video string `json:"video" jsonschema:"本地视频绝对路径(仅支持单个视频文件,如:/Users/user/video.mp4)"`
|
||||
Tags []string `json:"tags,omitempty" jsonschema:"话题标签列表(可选参数),如 [美食, 旅行, 生活]"`
|
||||
Title string `json:"title" jsonschema:"内容标题(小红书限制:最多20个中文字或英文单词)"`
|
||||
Content string `json:"content" jsonschema:"正文内容,不包含以#开头的标签内容,所有话题标签都用tags参数来生成和提供即可"`
|
||||
Video string `json:"video" jsonschema:"本地视频绝对路径(仅支持单个视频文件,如:/Users/user/video.mp4)"`
|
||||
Tags []string `json:"tags,omitempty" jsonschema:"话题标签列表(可选参数),如 [美食, 旅行, 生活]"`
|
||||
ScheduleAt string `json:"schedule_at,omitempty" jsonschema:"定时发布时间(可选),ISO8601格式如 2024-01-20T10:30:00+08:00,支持1小时至14天内。不填则立即发布"`
|
||||
}
|
||||
|
||||
// SearchFeedsArgs 搜索内容的参数
|
||||
@@ -207,10 +209,11 @@ func registerTools(server *mcp.Server, appServer *AppServer) {
|
||||
withPanicRecovery("publish_content", func(ctx context.Context, req *mcp.CallToolRequest, args PublishContentArgs) (*mcp.CallToolResult, any, error) {
|
||||
// 转换参数格式到现有的 handler
|
||||
argsMap := map[string]interface{}{
|
||||
"title": args.Title,
|
||||
"content": args.Content,
|
||||
"images": convertStringsToInterfaces(args.Images),
|
||||
"tags": convertStringsToInterfaces(args.Tags),
|
||||
"title": args.Title,
|
||||
"content": args.Content,
|
||||
"images": convertStringsToInterfaces(args.Images),
|
||||
"tags": convertStringsToInterfaces(args.Tags),
|
||||
"schedule_at": args.ScheduleAt,
|
||||
}
|
||||
result := appServer.handlePublishContent(ctx, argsMap)
|
||||
return convertToMCPResult(result), nil, nil
|
||||
@@ -377,10 +380,11 @@ func registerTools(server *mcp.Server, appServer *AppServer) {
|
||||
},
|
||||
withPanicRecovery("publish_with_video", func(ctx context.Context, req *mcp.CallToolRequest, args PublishVideoArgs) (*mcp.CallToolResult, any, error) {
|
||||
argsMap := map[string]interface{}{
|
||||
"title": args.Title,
|
||||
"content": args.Content,
|
||||
"video": args.Video,
|
||||
"tags": convertStringsToInterfaces(args.Tags),
|
||||
"title": args.Title,
|
||||
"content": args.Content,
|
||||
"video": args.Video,
|
||||
"tags": convertStringsToInterfaces(args.Tags),
|
||||
"schedule_at": args.ScheduleAt,
|
||||
}
|
||||
result := appServer.handlePublishVideo(ctx, argsMap)
|
||||
return convertToMCPResult(result), nil, nil
|
||||
|
||||
Reference in New Issue
Block a user