Documentation
¶
Index ¶
- type ATMessageEventData
- type BaseChannel
- type BaseChannelConfig
- type BaseChannelImpl
- func (c *BaseChannelImpl) AccountID() string
- func (c *BaseChannelImpl) IsAllowed(senderID string) bool
- func (c *BaseChannelImpl) IsRunning() bool
- func (c *BaseChannelImpl) Name() string
- func (c *BaseChannelImpl) PublishInbound(ctx context.Context, msg *bus.InboundMessage) error
- func (c *BaseChannelImpl) SendStream(chatID string, stream <-chan *bus.StreamMessage) error
- func (c *BaseChannelImpl) Start(ctx context.Context) error
- func (c *BaseChannelImpl) Stop() error
- func (c *BaseChannelImpl) WaitForStop() <-chan struct{}
- type C2CMessageEventData
- type DingTalkChannel
- func (c *DingTalkChannel) Send(msg *bus.OutboundMessage) error
- func (c *DingTalkChannel) SendDirectReply(sessionWebhook, content string) error
- func (c *DingTalkChannel) SendStream(chatID string, stream <-chan *bus.StreamMessage) error
- func (c *DingTalkChannel) Start(ctx context.Context) error
- func (c *DingTalkChannel) Stop() error
- type DiscordChannel
- type DiscordConfig
- type FeishuChannel
- type GoogleChatChannel
- func (c *GoogleChatChannel) HandleWebhook(ctx context.Context, event *chat.DeprecatedEvent) error
- func (c *GoogleChatChannel) InitService(ctx context.Context) error
- func (c *GoogleChatChannel) Send(msg *bus.OutboundMessage) error
- func (c *GoogleChatChannel) SendWithWebhook(webhookURL string, msg *bus.OutboundMessage) error
- func (c *GoogleChatChannel) Start(ctx context.Context) error
- func (c *GoogleChatChannel) Stop() error
- type GoogleChatConfig
- type GroupATMessageEventData
- type HelloData
- type InfoflowChannel
- type InfoflowConfig
- type Manager
- func (m *Manager) DispatchOutbound(ctx context.Context) error
- func (m *Manager) Get(name string) (BaseChannel, bool)
- func (m *Manager) List() []string
- func (m *Manager) Register(channel BaseChannel) error
- func (m *Manager) RegisterWithName(channel BaseChannel, name string) error
- func (m *Manager) SetupFromConfig(cfg *config.Config) error
- func (m *Manager) Start(ctx context.Context) error
- func (m *Manager) Status(name string) (map[string]interface{}, error)
- func (m *Manager) Stop() error
- type QQChannel
- type ReadyData
- type SlackChannel
- type SlackConfig
- type TeamsActor
- type TeamsAttachment
- type TeamsChannel
- func (c *TeamsChannel) HandleWebhook(ctx context.Context, webhookMsg *TeamsWebhookMessage) error
- func (c *TeamsChannel) Send(msg *bus.OutboundMessage) error
- func (c *TeamsChannel) SendAdaptiveCard(msg *bus.OutboundMessage, card map[string]interface{}) error
- func (c *TeamsChannel) SendWithWebhook(webhookURL string, msg *bus.OutboundMessage) error
- func (c *TeamsChannel) Start(ctx context.Context) error
- func (c *TeamsChannel) Stop() error
- type TeamsConfig
- type TeamsConversation
- type TeamsEntity
- type TeamsWebhookMessage
- type TelegramChannel
- type TelegramConfig
- type WSPayload
- type WeWorkChannel
- type WhatsAppChannel
- type WhatsAppConfig
- type WhatsAppMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ATMessageEventData ¶
type ATMessageEventData struct {
ID string `json:"id"`
Content string `json:"content"`
Timestamp string `json:"timestamp"`
Author struct {
ID string `json:"id"`
Username string `json:"username"`
} `json:"author"`
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id"`
}
ATMessageEventData 频道 @消息事件数据
type BaseChannel ¶
type BaseChannel interface {
// Name 返回通道名称
Name() string
// AccountID 返回通道账号ID
AccountID() string
// Start 启动通道
Start(ctx context.Context) error
// Stop 停止通道
Stop() error
// Send 发送消息
Send(msg *bus.OutboundMessage) error
// SendStream 发送流式消息
SendStream(chatID string, stream <-chan *bus.StreamMessage) error
// IsAllowed 检查发送者是否允许
IsAllowed(senderID string) bool
}
BaseChannel 通道基础接口
type BaseChannelConfig ¶
type BaseChannelConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled"`
AccountID string `mapstructure:"account_id" json:"account_id"` // 账号ID
Name string `mapstructure:"name" json:"name"` // 账号显示名称
AllowedIDs []string `mapstructure:"allowed_ids" json:"allowed_ids"`
}
BaseChannelConfig 通道基础配置
type BaseChannelImpl ¶
type BaseChannelImpl struct {
// contains filtered or unexported fields
}
BaseChannelImpl 通道基础实现
func NewBaseChannelImpl ¶
func NewBaseChannelImpl(name, accountID string, config BaseChannelConfig, bus *bus.MessageBus) *BaseChannelImpl
NewBaseChannelImpl 创建通道基础实现
func (*BaseChannelImpl) IsAllowed ¶
func (c *BaseChannelImpl) IsAllowed(senderID string) bool
IsAllowed 检查发送者是否允许
func (*BaseChannelImpl) PublishInbound ¶
func (c *BaseChannelImpl) PublishInbound(ctx context.Context, msg *bus.InboundMessage) error
PublishInbound 发布入站消息
func (*BaseChannelImpl) SendStream ¶
func (c *BaseChannelImpl) SendStream(chatID string, stream <-chan *bus.StreamMessage) error
SendStream 发送流式消息 (默认实现,收集所有chunk后一次性发送)
func (*BaseChannelImpl) Start ¶
func (c *BaseChannelImpl) Start(ctx context.Context) error
Start 启动通道
func (*BaseChannelImpl) WaitForStop ¶
func (c *BaseChannelImpl) WaitForStop() <-chan struct{}
WaitForStop 等待停止信号
type C2CMessageEventData ¶
type C2CMessageEventData struct {
ID string `json:"id"`
Content string `json:"content"`
Timestamp string `json:"timestamp"`
Author struct {
UserOpenID string `json:"user_openid"`
} `json:"author"`
}
C2CMessageEventData C2C 消息事件数据
type DingTalkChannel ¶
type DingTalkChannel struct {
*BaseChannelImpl
// contains filtered or unexported fields
}
DingTalkChannel DingTalk 通道实现
func NewDingTalkChannel ¶
func NewDingTalkChannel(cfg config.DingTalkChannelConfig, bus *bus.MessageBus) (*DingTalkChannel, error)
NewDingTalkChannel 创建 DingTalk 通道实例
func (*DingTalkChannel) Send ¶
func (c *DingTalkChannel) Send(msg *bus.OutboundMessage) error
Send 发送消息到 DingTalk
func (*DingTalkChannel) SendDirectReply ¶
func (c *DingTalkChannel) SendDirectReply(sessionWebhook, content string) error
SendDirectReply 使用 session webhook 发送直接回复
func (*DingTalkChannel) SendStream ¶
func (c *DingTalkChannel) SendStream(chatID string, stream <-chan *bus.StreamMessage) error
SendStream 发送流式消息 (DingTalk 不支持,收集后一次性发送)
type DiscordChannel ¶
type DiscordChannel struct {
*BaseChannelImpl
// contains filtered or unexported fields
}
DiscordChannel Discord 通道
func NewDiscordChannel ¶
func NewDiscordChannel(cfg DiscordConfig, bus *bus.MessageBus) (*DiscordChannel, error)
NewDiscordChannel 创建 Discord 通道
func (*DiscordChannel) Send ¶
func (c *DiscordChannel) Send(msg *bus.OutboundMessage) error
Send 发送消息
type DiscordConfig ¶
type DiscordConfig struct {
BaseChannelConfig
Token string `mapstructure:"token" json:"token"`
}
DiscordConfig Discord 配置
type FeishuChannel ¶
type FeishuChannel struct {
*BaseChannelImpl
// contains filtered or unexported fields
}
FeishuChannel 飞书通道 - WebSocket 模式
func NewFeishuChannel ¶
func NewFeishuChannel(cfg config.FeishuChannelConfig, bus *bus.MessageBus) (*FeishuChannel, error)
NewFeishuChannel 创建飞书通道
type GoogleChatChannel ¶
type GoogleChatChannel struct {
*BaseChannelImpl
// contains filtered or unexported fields
}
GoogleChatChannel Google Chat 通道
func NewGoogleChatChannel ¶
func NewGoogleChatChannel(cfg GoogleChatConfig, bus *bus.MessageBus) (*GoogleChatChannel, error)
NewGoogleChatChannel 创建 Google Chat 通道
func (*GoogleChatChannel) HandleWebhook ¶
func (c *GoogleChatChannel) HandleWebhook(ctx context.Context, event *chat.DeprecatedEvent) error
HandleWebhook 处理 Google Chat webhook (需要在外部 HTTP 端点调用)
func (*GoogleChatChannel) InitService ¶
func (c *GoogleChatChannel) InitService(ctx context.Context) error
InitService 初始化 Google Chat 服务 (如果需要主动发送)
func (*GoogleChatChannel) Send ¶
func (c *GoogleChatChannel) Send(msg *bus.OutboundMessage) error
Send 发送消息
func (*GoogleChatChannel) SendWithWebhook ¶
func (c *GoogleChatChannel) SendWithWebhook(webhookURL string, msg *bus.OutboundMessage) error
SendWithWebhook 使用 webhook 发送消息 (推荐方式)
type GoogleChatConfig ¶
type GoogleChatConfig struct {
BaseChannelConfig
ProjectID string `mapstructure:"project_id" json:"project_id"`
Credentials string `mapstructure:"credentials" json:"credentials"` // Service account credentials JSON
}
GoogleChatConfig Google Chat 配置
type GroupATMessageEventData ¶
type GroupATMessageEventData struct {
ID string `json:"id"`
Content string `json:"content"`
Timestamp string `json:"timestamp"`
Author struct {
MemberOpenID string `json:"member_openid"`
} `json:"author"`
GroupOpenID string `json:"group_openid"`
}
GroupATMessageEventData 群 @消息事件数据
type HelloData ¶
type HelloData struct {
HeartbeatInterval int `json:"heartbeat_interval"`
}
HelloData Hello 事件数据
type InfoflowChannel ¶
type InfoflowChannel struct {
*BaseChannelImpl
// contains filtered or unexported fields
}
InfoflowChannel 百度如流通道
func NewInfoflowChannel ¶
func NewInfoflowChannel(accountID string, cfg InfoflowConfig, bus *bus.MessageBus) (*InfoflowChannel, error)
NewInfoflowChannel 创建如流通道
func (*InfoflowChannel) Send ¶
func (c *InfoflowChannel) Send(msg *bus.OutboundMessage) error
Send 发送消息
func (*InfoflowChannel) SendStream ¶
func (c *InfoflowChannel) SendStream(chatID string, stream <-chan *bus.StreamMessage) error
SendStream 发送流式消息(如流不支持,使用普通发送)
type InfoflowConfig ¶
type InfoflowConfig struct {
BaseChannelConfig
WebhookURL string `json:"webhook_url" mapstructure:"webhook_url"`
Token string `json:"token" mapstructure:"token"`
AESKey string `json:"aes_key" mapstructure:"aes_key"`
WebhookPort int `json:"webhook_port" mapstructure:"webhook_port"`
}
InfoflowConfig 如流通道配置
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 通道管理器
func (*Manager) DispatchOutbound ¶
DispatchOutbound 分发出站消息
func (*Manager) RegisterWithName ¶
func (m *Manager) RegisterWithName(channel BaseChannel, name string) error
RegisterWithName 使用指定名称注册通道
func (*Manager) SetupFromConfig ¶
SetupFromConfig 从配置设置通道
type QQChannel ¶
type QQChannel struct {
*BaseChannelImpl
// contains filtered or unexported fields
}
QQChannel QQ 官方开放平台 Bot 通道 使用 botgo SDK 实现:https://github.com/tencent-connect/botgo
func NewQQChannel ¶
func NewQQChannel(accountID string, cfg config.QQChannelConfig, bus *bus.MessageBus) (*QQChannel, error)
NewQQChannel 创建 QQ 官方 Bot 通道
func (*QQChannel) GetSession ¶
func (c *QQChannel) GetSession() *dto.WebsocketAP
GetSession 获取当前会话信息(用于调试)
func (*QQChannel) HandleWebhook ¶
HandleWebhook 处理 QQ Webhook 回调(WebSocket 模式下不使用)
type ReadyData ¶
type ReadyData struct {
SessionID string `json:"session_id"`
Version int `json:"version"`
User struct {
ID string `json:"id"`
Username string `json:"username"`
Bot bool `json:"bot"`
} `json:"user"`
}
ReadyData Ready 事件数据
type SlackChannel ¶
type SlackChannel struct {
*BaseChannelImpl
// contains filtered or unexported fields
}
SlackChannel Slack 通道
func NewSlackChannel ¶
func NewSlackChannel(cfg SlackConfig, bus *bus.MessageBus) (*SlackChannel, error)
NewSlackChannel 创建 Slack 通道
type SlackConfig ¶
type SlackConfig struct {
BaseChannelConfig
Token string `mapstructure:"token" json:"token"`
SigningSecret string `mapstructure:"signing_secret" json:"signing_secret"`
}
SlackConfig Slack 配置
type TeamsActor ¶
TeamsActor Teams 参与者
type TeamsAttachment ¶
type TeamsAttachment struct {
ContentType string `json:"contentType"`
Content map[string]interface{} `json:"content"`
}
TeamsAttachment Teams 附件
type TeamsChannel ¶
type TeamsChannel struct {
*BaseChannelImpl
// contains filtered or unexported fields
}
TeamsChannel Microsoft Teams 通道
func NewTeamsChannel ¶
func NewTeamsChannel(cfg TeamsConfig, bus *bus.MessageBus) (*TeamsChannel, error)
NewTeamsChannel 创建 Teams 通道
func (*TeamsChannel) HandleWebhook ¶
func (c *TeamsChannel) HandleWebhook(ctx context.Context, webhookMsg *TeamsWebhookMessage) error
HandleWebhook 处理 Teams webhook (需要在外部 HTTP 端点调用)
func (*TeamsChannel) SendAdaptiveCard ¶
func (c *TeamsChannel) SendAdaptiveCard(msg *bus.OutboundMessage, card map[string]interface{}) error
SendAdaptiveCard 发送自适应卡片 (富格式消息)
func (*TeamsChannel) SendWithWebhook ¶
func (c *TeamsChannel) SendWithWebhook(webhookURL string, msg *bus.OutboundMessage) error
SendWithWebhook 使用 webhook 发送消息 (用于 outgoing webhooks)
type TeamsConfig ¶
type TeamsConfig struct {
BaseChannelConfig
AppID string `mapstructure:"app_id" json:"app_id"`
AppPassword string `mapstructure:"app_password" json:"app_password"`
TenantID string `mapstructure:"tenant_id" json:"tenant_id"`
WebhookURL string `mapstructure:"webhook_url" json:"webhook_url"` // For outgoing webhooks
}
TeamsConfig Teams 配置
type TeamsConversation ¶
TeamsConversation Teams 会话
type TeamsEntity ¶
type TeamsEntity struct {
Type string `json:"type"`
Data map[string]interface{} `json:"data,omitempty"`
}
TeamsEntity Teams 实体
type TeamsWebhookMessage ¶
type TeamsWebhookMessage struct {
Type string `json:"type"`
ID string `json:"id"`
Timestamp string `json:"timestamp"`
ServiceURL string `json:"serviceUrl"`
ChannelID string `json:"channelId"`
From TeamsActor `json:"from"`
Conversation TeamsConversation `json:"conversation"`
Text string `json:"text"`
Attachments []TeamsAttachment `json:"attachments"`
Entities []TeamsEntity `json:"entities"`
}
TeamsWebhookMessage Teams webhook 消息
type TelegramChannel ¶
type TelegramChannel struct {
*BaseChannelImpl
// contains filtered or unexported fields
}
TelegramChannel Telegram 通道
func NewTelegramChannel ¶
func NewTelegramChannel(accountID string, cfg TelegramConfig, bus *bus.MessageBus) (*TelegramChannel, error)
NewTelegramChannel 创建 Telegram 通道
func (*TelegramChannel) Send ¶
func (c *TelegramChannel) Send(msg *bus.OutboundMessage) error
Send 发送消息
type TelegramConfig ¶
type TelegramConfig struct {
BaseChannelConfig
Token string `mapstructure:"token" json:"token"`
}
TelegramConfig Telegram 配置
type WSPayload ¶
type WSPayload struct {
Op int `json:"op"`
D json.RawMessage `json:"d"`
S uint32 `json:"s"`
T string `json:"t"`
}
WSPayload WebSocket 消息负载
type WeWorkChannel ¶
type WeWorkChannel struct {
*BaseChannelImpl
// contains filtered or unexported fields
}
WeWorkChannel 企业微信通道
func NewWeWorkChannel ¶
func NewWeWorkChannel(cfg config.WeWorkChannelConfig, bus *bus.MessageBus) (*WeWorkChannel, error)
NewWeWorkChannel 创建企业微信通道
type WhatsAppChannel ¶
type WhatsAppChannel struct {
*BaseChannelImpl
// contains filtered or unexported fields
}
WhatsAppChannel WhatsApp 通道
func NewWhatsAppChannel ¶
func NewWhatsAppChannel(cfg WhatsAppConfig, bus *bus.MessageBus) (*WhatsAppChannel, error)
NewWhatsAppChannel 创建 WhatsApp 通道
func (*WhatsAppChannel) Send ¶
func (c *WhatsAppChannel) Send(msg *bus.OutboundMessage) error
Send 发送消息
type WhatsAppConfig ¶
type WhatsAppConfig struct {
BaseChannelConfig
BridgeURL string `mapstructure:"bridge_url" json:"bridge_url"`
}
WhatsAppConfig WhatsApp 配置