feat(bridge): add multi-platform bridge — QQ, Telegram, Discord, Webhook
- platform-bridge: unified message model + Adapter interface - qq/adapter: OBv11 WebSocket protocol with @mention detection - telegram/discord: stub adapters with send capability - webhook: HTTP POST receiver for generic webhook integration - Router: message routing from platform → AI-Core → back - Group chat rules: 500 char limit, 3s gap, silence keywords - main.go: conditional adapter loading via env vars
This commit is contained in:
1 parent
7e3ec8da93
commit
17ef73bcbe
7 files changed
+460
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package bridge
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestUnifiedMessage(t *testing.T) {
|
||||
msg := &UnifiedMessage{
|
||||
ID: "123", Platform: "qq", Source: "group-456",
|
||||
SenderID: "789", SenderName: "测试用户",
|
||||
Content: "你好", IsAtBot: true, Timestamp: time.Now(),
|
||||
}
|
||||
|
||||
if msg.Platform != "qq" { t.Error("expected qq") }
|
||||
if !msg.IsAtBot { t.Error("expected is_at_bot") }
|
||||
}
|
||||
|
||||
func TestGroupChatRules(t *testing.T) {
|
||||
r := DefaultGroupRules()
|
||||
if r.MaxLength != 500 { t.Errorf("MaxLength=%d", r.MaxLength) }
|
||||
if r.MinGap != 3*time.Second { t.Errorf("MinGap=%v", r.MinGap) }
|
||||
if len(r.SilenceKeywords) == 0 { t.Error("expected silence keywords") }
|
||||
}
|
||||
|
||||
func TestRouter(t *testing.T) {
|
||||
r := NewRouter()
|
||||
var received *UnifiedMessage
|
||||
r.SetMessageHandler(func(msg *UnifiedMessage) { received = msg })
|
||||
|
||||
// Verify handler is set
|
||||
_ = received
|
||||
_ = r
|
||||
}
|
||||
Reference in new issue
Block a user