- 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
35 lines
848 B
Go
35 lines
848 B
Go
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
|
|
}
|