channels

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 56 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BridgeLogoutURL

func BridgeLogoutURL(raw string) (string, error)

func BridgeStatusURL

func BridgeStatusURL(raw string) (string, error)

func CompiledChannelKeys

func CompiledChannelKeys() []string

func ParseWhatsAppBridgeListenAddr

func ParseWhatsAppBridgeListenAddr(raw string) (string, error)

Types

type ActionCapable

type ActionCapable interface {
	SupportsAction(action string) bool
}

ActionCapable is an optional capability interface for channels that support non-send message actions.

type BaseChannel

type BaseChannel struct {
	// contains filtered or unexported fields
}

func NewBaseChannel

func NewBaseChannel(name string, config interface{}, bus *bus.MessageBus, allowList []string) *BaseChannel

func (*BaseChannel) HandleMessage

func (c *BaseChannel) HandleMessage(senderID, chatID, content string, media []string, metadata map[string]string)

func (*BaseChannel) HealthCheck

func (c *BaseChannel) HealthCheck(ctx context.Context) error

func (*BaseChannel) IsAllowed

func (c *BaseChannel) IsAllowed(senderID string) bool

func (*BaseChannel) IsRunning

func (c *BaseChannel) IsRunning() bool

func (*BaseChannel) Name

func (c *BaseChannel) Name() string

type Channel

type Channel interface {
	Name() string
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	Send(ctx context.Context, msg bus.OutboundMessage) error
	IsRunning() bool
	IsAllowed(senderID string) bool
	HealthCheck(ctx context.Context) error
}

type DingTalkChannel

type DingTalkChannel struct {
	*BaseChannel
	// contains filtered or unexported fields
}

DingTalkChannel implements the Channel interface for DingTalk. It uses WebSocket for receiving messages via stream mode and API for sending

func NewDingTalkChannel

func NewDingTalkChannel(cfg config.DingTalkConfig, messageBus *bus.MessageBus) (*DingTalkChannel, error)

NewDingTalkChannel creates a new DingTalk channel instance

func (*DingTalkChannel) Send

Send sends a message to DingTalk via the chatbot reply API

func (*DingTalkChannel) SendDirectReply

func (c *DingTalkChannel) SendDirectReply(sessionWebhook, content string) error

SendDirectReply sends a direct reply using the session webhook

func (*DingTalkChannel) Start

func (c *DingTalkChannel) Start(ctx context.Context) error

Start initializes the DingTalk channel with Stream Mode

func (*DingTalkChannel) Stop

func (c *DingTalkChannel) Stop(ctx context.Context) error

Stop gracefully stops the DingTalk channel

type DiscordChannel

type DiscordChannel struct {
	*BaseChannel
	// contains filtered or unexported fields
}

func NewDiscordChannel

func NewDiscordChannel(cfg config.DiscordConfig, bus *bus.MessageBus) (*DiscordChannel, error)

func (*DiscordChannel) Send

func (*DiscordChannel) Start

func (c *DiscordChannel) Start(ctx context.Context) error

func (*DiscordChannel) Stop

func (c *DiscordChannel) Stop(ctx context.Context) error

type FeishuChannel

type FeishuChannel struct {
	*BaseChannel
	// contains filtered or unexported fields
}

func NewFeishuChannel

func NewFeishuChannel(cfg config.FeishuConfig, bus *bus.MessageBus) (*FeishuChannel, error)

func (*FeishuChannel) Send

func (*FeishuChannel) Start

func (c *FeishuChannel) Start(ctx context.Context) error

func (*FeishuChannel) Stop

func (c *FeishuChannel) Stop(ctx context.Context) error

func (*FeishuChannel) SupportsAction

func (c *FeishuChannel) SupportsAction(action string) bool

type MaixCamChannel

type MaixCamChannel struct {
	*BaseChannel
	// contains filtered or unexported fields
}

func NewMaixCamChannel

func NewMaixCamChannel(cfg config.MaixCamConfig, bus *bus.MessageBus) (*MaixCamChannel, error)

func (*MaixCamChannel) Send

func (*MaixCamChannel) Start

func (c *MaixCamChannel) Start(ctx context.Context) error

func (*MaixCamChannel) Stop

func (c *MaixCamChannel) Stop(ctx context.Context) error

type MaixCamMessage

type MaixCamMessage struct {
	Type      string                 `json:"type"`
	Tips      string                 `json:"tips"`
	Timestamp float64                `json:"timestamp"`
	Data      map[string]interface{} `json:"data"`
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(cfg *config.Config, messageBus *bus.MessageBus) (*Manager, error)

func (*Manager) CheckHealth

func (m *Manager) CheckHealth(ctx context.Context) map[string]error

func (*Manager) GetChannel

func (m *Manager) GetChannel(name string) (Channel, bool)

func (*Manager) GetEnabledChannels

func (m *Manager) GetEnabledChannels() []string

func (*Manager) RestartChannel

func (m *Manager) RestartChannel(ctx context.Context, name string) error

func (*Manager) SendToChannel

func (m *Manager) SendToChannel(ctx context.Context, channelName, chatID, content string) error

func (*Manager) StartAll

func (m *Manager) StartAll(ctx context.Context) error

func (*Manager) StopAll

func (m *Manager) StopAll(ctx context.Context) error

type QQChannel

type QQChannel struct {
	*BaseChannel
	// contains filtered or unexported fields
}

func NewQQChannel

func NewQQChannel(cfg config.QQConfig, messageBus *bus.MessageBus) (*QQChannel, error)

func (*QQChannel) Send

func (c *QQChannel) Send(ctx context.Context, msg bus.OutboundMessage) error

func (*QQChannel) Start

func (c *QQChannel) Start(ctx context.Context) error

func (*QQChannel) Stop

func (c *QQChannel) Stop(ctx context.Context) error

type TelegramChannel

type TelegramChannel struct {
	*BaseChannel
	// contains filtered or unexported fields
}

func NewTelegramChannel

func NewTelegramChannel(cfg config.TelegramConfig, bus *bus.MessageBus) (*TelegramChannel, error)

func (*TelegramChannel) HealthCheck

func (c *TelegramChannel) HealthCheck(ctx context.Context) error

func (*TelegramChannel) Send

func (*TelegramChannel) Start

func (c *TelegramChannel) Start(ctx context.Context) error

func (*TelegramChannel) Stop

func (c *TelegramChannel) Stop(ctx context.Context) error

func (*TelegramChannel) SupportsAction

func (c *TelegramChannel) SupportsAction(action string) bool

type WeixinAccountSnapshot added in v1.0.1

type WeixinAccountSnapshot struct {
	BotID           string `json:"bot_id"`
	IlinkUserID     string `json:"ilink_user_id,omitempty"`
	ContextToken    string `json:"context_token,omitempty"`
	GetUpdatesBuf   string `json:"get_updates_buf,omitempty"`
	Connected       bool   `json:"connected"`
	LastEvent       string `json:"last_event,omitempty"`
	LastError       string `json:"last_error,omitempty"`
	UpdatedAt       string `json:"updated_at,omitempty"`
	Default         bool   `json:"default"`
	LastInboundAt   string `json:"last_inbound_at,omitempty"`
	LastInboundChat string `json:"last_inbound_chat,omitempty"`
	LastInboundText string `json:"last_inbound_text,omitempty"`
}

type WeixinChannel added in v1.0.1

type WeixinChannel struct {
	*BaseChannel
	// contains filtered or unexported fields
}

func NewWeixinChannel added in v1.0.1

func NewWeixinChannel(cfg config.WeixinConfig, messageBus *bus.MessageBus) (*WeixinChannel, error)

func (*WeixinChannel) CancelPendingLogin added in v1.0.1

func (c *WeixinChannel) CancelPendingLogin(loginID string) bool

func (*WeixinChannel) ListAccounts added in v1.0.1

func (c *WeixinChannel) ListAccounts() []WeixinAccountSnapshot

func (*WeixinChannel) PendingLoginByID added in v1.0.1

func (c *WeixinChannel) PendingLoginByID(loginID string) *WeixinPendingLogin

func (*WeixinChannel) PendingLogins added in v1.0.1

func (c *WeixinChannel) PendingLogins() []*WeixinPendingLogin

func (*WeixinChannel) RefreshLoginStatuses added in v1.0.1

func (c *WeixinChannel) RefreshLoginStatuses(ctx context.Context) ([]*WeixinPendingLogin, error)

func (*WeixinChannel) RemoveAccount added in v1.0.1

func (c *WeixinChannel) RemoveAccount(botID string) error

func (*WeixinChannel) Send added in v1.0.1

func (*WeixinChannel) SetConfigPath added in v1.0.1

func (c *WeixinChannel) SetConfigPath(path string)

func (*WeixinChannel) SetDefaultAccount added in v1.0.1

func (c *WeixinChannel) SetDefaultAccount(botID string) error

func (*WeixinChannel) Start added in v1.0.1

func (c *WeixinChannel) Start(ctx context.Context) error

func (*WeixinChannel) StartLogin added in v1.0.1

func (c *WeixinChannel) StartLogin(ctx context.Context) (*WeixinPendingLogin, error)

func (*WeixinChannel) Stop added in v1.0.1

func (c *WeixinChannel) Stop(ctx context.Context) error

func (*WeixinChannel) SupportsAction added in v1.0.1

func (c *WeixinChannel) SupportsAction(action string) bool

type WeixinPendingLogin added in v1.0.1

type WeixinPendingLogin struct {
	LoginID          string `json:"login_id,omitempty"`
	QRCode           string `json:"qr_code,omitempty"`
	QRCodeImgContent string `json:"qr_code_img_content,omitempty"`
	Status           string `json:"status,omitempty"`
	LastError        string `json:"last_error,omitempty"`
	UpdatedAt        string `json:"updated_at,omitempty"`
}

type WhatsAppBridgeService

type WhatsAppBridgeService struct {
	// contains filtered or unexported fields
}

func NewWhatsAppBridgeService

func NewWhatsAppBridgeService(addr, stateDir string, printQR bool) *WhatsAppBridgeService

func (*WhatsAppBridgeService) RegisterRoutes

func (s *WhatsAppBridgeService) RegisterRoutes(mux *http.ServeMux, basePath string)

func (*WhatsAppBridgeService) ServeLogout

func (s *WhatsAppBridgeService) ServeLogout(w http.ResponseWriter, r *http.Request)

func (*WhatsAppBridgeService) ServeStatus

func (s *WhatsAppBridgeService) ServeStatus(w http.ResponseWriter, r *http.Request)

func (*WhatsAppBridgeService) ServeWS

func (*WhatsAppBridgeService) Start

func (*WhatsAppBridgeService) StartEmbedded

func (s *WhatsAppBridgeService) StartEmbedded(ctx context.Context) error

func (*WhatsAppBridgeService) StatusSnapshot

func (s *WhatsAppBridgeService) StatusSnapshot() WhatsAppBridgeStatus

func (*WhatsAppBridgeService) Stop

func (s *WhatsAppBridgeService) Stop()

type WhatsAppBridgeStatus

type WhatsAppBridgeStatus struct {
	State            string `json:"state"`
	Connected        bool   `json:"connected"`
	LoggedIn         bool   `json:"logged_in"`
	BridgeAddr       string `json:"bridge_addr"`
	UserJID          string `json:"user_jid,omitempty"`
	PushName         string `json:"push_name,omitempty"`
	Platform         string `json:"platform,omitempty"`
	QRCode           string `json:"qr_code,omitempty"`
	QRAvailable      bool   `json:"qr_available"`
	LastEvent        string `json:"last_event,omitempty"`
	LastError        string `json:"last_error,omitempty"`
	UpdatedAt        string `json:"updated_at"`
	InboundCount     int    `json:"inbound_count"`
	OutboundCount    int    `json:"outbound_count"`
	ReadReceiptCount int    `json:"read_receipt_count"`
	LastInboundAt    string `json:"last_inbound_at,omitempty"`
	LastOutboundAt   string `json:"last_outbound_at,omitempty"`
	LastReadAt       string `json:"last_read_at,omitempty"`
	LastInboundFrom  string `json:"last_inbound_from,omitempty"`
	LastOutboundTo   string `json:"last_outbound_to,omitempty"`
	LastInboundText  string `json:"last_inbound_text,omitempty"`
	LastOutboundText string `json:"last_outbound_text,omitempty"`
}

type WhatsAppChannel

type WhatsAppChannel struct {
	*BaseChannel
	// contains filtered or unexported fields
}

func NewWhatsAppChannel

func NewWhatsAppChannel(cfg config.WhatsAppConfig, bus *bus.MessageBus) (*WhatsAppChannel, error)

func (*WhatsAppChannel) Send

func (*WhatsAppChannel) Start

func (c *WhatsAppChannel) Start(ctx context.Context) error

func (*WhatsAppChannel) Stop

func (c *WhatsAppChannel) Stop(ctx context.Context) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL