Files
Memoh/internal/channel/adapters/local/cli.go
T
BBQ 5a35ef34ac feat: channel gateway implementation and multi-bot refactor
- Refactor channel manager with support for Sender/Receiver interfaces and hot-swappable adapters.
- Implement identity routing and pre-authentication logic for inbound messages.
- Update database schema to support bot pre-auth keys and extended channel session metadata.
- Add Telegram and Feishu channel configuration and adapter enhancements.
- Update Swagger documentation and internal handlers for channel management.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-06 14:41:54 +08:00

37 lines
719 B
Go

package local
import (
"context"
"fmt"
"strings"
"github.com/memohai/memoh/internal/channel"
)
type CLIAdapter struct {
hub *channel.SessionHub
}
func NewCLIAdapter(hub *channel.SessionHub) *CLIAdapter {
return &CLIAdapter{hub: hub}
}
func (a *CLIAdapter) Type() channel.ChannelType {
return CLIType
}
func (a *CLIAdapter) Send(ctx context.Context, cfg channel.ChannelConfig, msg channel.OutboundMessage) error {
if a.hub == nil {
return fmt.Errorf("cli hub not configured")
}
target := strings.TrimSpace(msg.Target)
if target == "" {
return fmt.Errorf("cli target is required")
}
if msg.Message.IsEmpty() {
return fmt.Errorf("message is required")
}
a.hub.Publish(target, msg)
return nil
}