feat: 群聊提醒 — 提醒关联平台/频道/适配器,到期发回原群聊
- reminder_create 新增 platform/channel_type/channel_id/adapter_name 参数 - Gateway Reminder 模型 + DB 迁移 + CRUD 全部支持新字段 - 提醒到期时:群聊提醒 → platform-bridge 发回原群聊 - 非群聊提醒 → 走 Web 端推送 - Thinker 新增 PushPlatformMessage 方法 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -397,6 +397,17 @@ func (t *Thinker) TriggerReminderMessage(userID, sessionID, message string) {
|
||||
}
|
||||
}
|
||||
|
||||
// PushPlatformMessage pushes a message to a platform channel via the platform pusher.
|
||||
func (t *Thinker) PushPlatformMessage(target ProactiveTarget, message string) {
|
||||
t.mu.Lock()
|
||||
pusher := t.platformMessagePusher
|
||||
t.mu.Unlock()
|
||||
if pusher != nil {
|
||||
log.Printf("[平台推送] target=%s/%s group=%s msg=%s", target.Platform, target.ChatType, target.GroupID, message)
|
||||
pusher(target, message)
|
||||
}
|
||||
}
|
||||
|
||||
// ThinkerConfig 后台思考配置
|
||||
type ThinkerConfig struct {
|
||||
Enabled bool
|
||||
|
||||
@@ -38,7 +38,7 @@ type Reminder struct {
|
||||
}
|
||||
|
||||
// CreateReminder calls POST /api/v1/internal/reminders on the Gateway.
|
||||
func (c *GatewayClient) CreateReminder(ctx context.Context, userID, title, description, remindAt, repeatType, sessionID string) (*Reminder, error) {
|
||||
func (c *GatewayClient) CreateReminder(ctx context.Context, userID, title, description, remindAt, repeatType, sessionID, platform, channelType, channelID, adapterName string) (*Reminder, error) {
|
||||
body := map[string]interface{}{
|
||||
"user_id": userID,
|
||||
"title": title,
|
||||
@@ -46,6 +46,10 @@ func (c *GatewayClient) CreateReminder(ctx context.Context, userID, title, descr
|
||||
"remind_at": remindAt,
|
||||
"repeat_type": repeatType,
|
||||
"session_id": sessionID,
|
||||
"platform": platform,
|
||||
"channel_type": channelType,
|
||||
"channel_id": channelID,
|
||||
"adapter_name": adapterName,
|
||||
}
|
||||
reqBody, _ := json.Marshal(body)
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ func NewReminderCreateTool(gw *GatewayClient, adminID string) *ReminderCreateToo
|
||||
func (t *ReminderCreateTool) Definition() ToolDefinition {
|
||||
return ToolDefinition{
|
||||
Name: "reminder_create",
|
||||
Description: "创建一个定时提醒。可用于提醒用户做某事、定时通知等。支持重复类型(none/daily/weekly/monthly)。时间格式为 ISO8601(如 2026-06-23T08:00:00+08:00)。",
|
||||
Description: "创建一个定时提醒。时间格式为 ISO8601(如 2026-06-23T08:00:00+08:00)。如果在群聊中创建提醒,请传入 platform/channel_id/channel_type/adapter_name 以便提醒时发回原群聊。",
|
||||
Parameters: map[string]interface{}{
|
||||
"type": "object",
|
||||
"properties": map[string]interface{}{
|
||||
@@ -28,6 +28,10 @@ func (t *ReminderCreateTool) Definition() ToolDefinition {
|
||||
"description": map[string]string{"type": "string", "description": "提醒详细描述(可选)"},
|
||||
"remind_at": map[string]string{"type": "string", "description": "提醒时间,ISO8601 格式,如 2026-06-23T08:00:00+08:00"},
|
||||
"repeat_type": map[string]string{"type": "string", "description": "重复类型:none(不重复), daily(每天), weekly(每周), monthly(每月),默认 none"},
|
||||
"platform": map[string]string{"type": "string", "description": "(群聊提醒时必填)平台类型,如 obv11"},
|
||||
"channel_type": map[string]string{"type": "string", "description": "(群聊提醒时必填)频道类型:group"},
|
||||
"channel_id": map[string]string{"type": "string", "description": "(群聊提醒时必填)群号"},
|
||||
"adapter_name": map[string]string{"type": "string", "description": "(群聊提醒时必填)适配器名,如 obv11-main"},
|
||||
},
|
||||
"required": []string{"title", "remind_at"},
|
||||
},
|
||||
@@ -47,7 +51,11 @@ func (t *ReminderCreateTool) Execute(ctx context.Context, args map[string]interf
|
||||
return &ToolResult{Success: false, Error: "title 和 remind_at 为必填项"}, nil
|
||||
}
|
||||
|
||||
reminder, err := t.gw.CreateReminder(ctx, t.adminID, title, description, remindAt, repeatType, "")
|
||||
platform, _ := args["platform"].(string)
|
||||
channelType, _ := args["channel_type"].(string)
|
||||
channelID, _ := args["channel_id"].(string)
|
||||
adapterName, _ := args["adapter_name"].(string)
|
||||
reminder, err := t.gw.CreateReminder(ctx, t.adminID, title, description, remindAt, repeatType, "", platform, channelType, channelID, adapterName)
|
||||
if err != nil {
|
||||
return &ToolResult{Success: false, Error: err.Error()}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user