This repository has been archived on 2026-08-12. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Cyrene/backend/platform-bridge/internal/bridge/adapter.go
T
AskaEth 6bf59f7eee feat: 频道自动发现 — platform-bridge定时刷新频道路由 + ai-core周期同步
platform-bridge:
- QQ adapter: FetchGroups/FetchFriends 从NapCat API获取
- ChannelLister接口 + ChannelInfo结构体
- GET /api/v1/channels 端点 + cachedChannels缓存
- StartChannelRefresh 每10分钟自动刷新

ai-core:
- channel_sync.go: 每5分钟从platform-bridge拉取频道
- 自动更新thinker的platformChannels + botUIDs
- 不再依赖PLATFORM_CHANNELS环境变量手动配置

修复:
- SendMessage显式设AutoEscape:false
- PLATFORM_BRIDGE_URL默认端口8082→8095
- OBv11Params.AutoEscape去掉omitempty

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 13:12:54 +08:00

45 lines
1.4 KiB
Go

package bridge
import "context"
// PlatformAdapter is the interface every platform adapter must implement.
type PlatformAdapter interface {
PlatformName() string
// Message conversion.
ToUnified(rawMessage interface{}) (*UnifiedMessage, error)
FromUnified(response *UnifiedResponse) ([]PlatformMessage, error)
// Capabilities.
Capabilities() PlatformCapabilities
// Connection management.
Connect(ctx context.Context) error
Disconnect(ctx context.Context) error
IsConnected() bool
HealthCheck() error
}
// ProactiveSender is an optional interface for adapters that can
// proactively send messages (e.g., OBv11 bot sending without prior request).
type ProactiveSender interface {
SendProactive(chatType string, userID, groupID int64, content string) error
}
// ChannelInfo describes a known chat channel (group or private).
type ChannelInfo struct {
Platform string `json:"platform"`
ChannelType string `json:"channel_type"` // "group", "private"
ChannelID string `json:"channel_id"`
ChannelName string `json:"channel_name,omitempty"`
}
// ChannelLister is an optional interface for adapters that can enumerate
// their channels (groups and friends) from the platform API.
type ChannelLister interface {
ListChannels() []ChannelInfo
}
// MessageHandler receives unified messages from adapters for processing.
type MessageHandler func(msg *UnifiedMessage) (*UnifiedResponse, error)