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"`
	AdapterID   string `json:"adapter_id,omitempty"`   // config ID of the adapter instance
	AdapterName string `json:"adapter_name,omitempty"` // config name, e.g. "qq-main"
}

// 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)
