mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-08-14 15:10:20 +02:00
Add files via upload
This commit is contained in:
+16
-2
@@ -98,9 +98,23 @@ func handleDingMessage(ctx context.Context, msg *chatbot.BotCallbackDataModel, h
|
|||||||
userID = msg.ConversationId
|
userID = msg.ConversationId
|
||||||
}
|
}
|
||||||
reply := h.HandleMessage("dingtalk", userID, content)
|
reply := h.HandleMessage("dingtalk", userID, content)
|
||||||
|
// 使用 markdown 类型以便正确展示标题、列表、代码块等格式
|
||||||
|
title := reply
|
||||||
|
if idx := strings.IndexAny(reply, "\n"); idx > 0 {
|
||||||
|
title = strings.TrimSpace(reply[:idx])
|
||||||
|
}
|
||||||
|
if len(title) > 50 {
|
||||||
|
title = title[:50] + "…"
|
||||||
|
}
|
||||||
|
if title == "" {
|
||||||
|
title = "回复"
|
||||||
|
}
|
||||||
body := map[string]interface{}{
|
body := map[string]interface{}{
|
||||||
"msgtype": "text",
|
"msgtype": "markdown",
|
||||||
"text": map[string]string{"content": reply},
|
"markdown": map[string]string{
|
||||||
|
"title": title,
|
||||||
|
"text": reply,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
bodyBytes, _ := json.Marshal(body)
|
bodyBytes, _ := json.Marshal(body)
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, msg.SessionWebhook, bytes.NewReader(bodyBytes))
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, msg.SessionWebhook, bytes.NewReader(bodyBytes))
|
||||||
|
|||||||
Reference in New Issue
Block a user