feat: 副对话系统 — Webhook 第三方平台接入 (通用/Discord格式支持)

This commit is contained in:
2026-05-16 23:27:04 +08:00
parent 1f5c2508d6
commit 0757ad26b5
4 changed files with 439 additions and 0 deletions
@@ -22,6 +22,7 @@ func Setup(r *gin.Engine, hub *ws.Hub, cfg *config.Config) {
sessionHandler := handler.NewSessionHandler(hub)
memoryHandler := handler.NewMemoryHandler(cfg.AICoreURL)
chatHandler := handler.NewChatHandler(cfg, hub)
webhookHandler := handler.NewWebhookHandler(cfg, hub)
// ========== 公开路由 ==========
api := r.Group("/api/v1")
@@ -86,6 +87,14 @@ func Setup(r *gin.Engine, hub *ws.Hub, cfg *config.Config) {
wsGroup.GET("/chat", chatHandler.HandleWebSocket)
}
// ========== Webhook 路由(第三方平台接入) ==========
webhook := r.Group("/api/v1/webhook")
webhook.Use(webhookHandler.WebhookAuth())
{
webhook.POST("/generic", webhookHandler.HandleGenericWebhook)
webhook.POST("/discord", webhookHandler.HandleDiscordWebhook)
}
// ========== 静态文件服务 (生产环境) ==========
if cfg.Env == "production" {
r.Static("/assets", "./public/assets")