Documentation
¶
Index ¶
- func WeComDecryptMessage(encryptedMsg, encodingAESKey string) (string, error)
- func WeComDecryptMessageWithVerify(encryptedMsg, encodingAESKey, receiveid string) (string, error)
- func WeComVerifySignature(token, msgSignature, timestamp, nonce, msgEncrypt string) bool
- type BaseChannel
- type BotStatus
- type Channel
- type DingTalkChannel
- func (c *DingTalkChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
- func (c *DingTalkChannel) SendDirectReply(ctx context.Context, sessionWebhook, content string) error
- func (c *DingTalkChannel) Start(ctx context.Context) error
- func (c *DingTalkChannel) Stop(ctx context.Context) error
- type DiscordChannel
- type FeishuChannel
- type LINEChannel
- type MaixCamChannel
- type MaixCamMessage
- type Manager
- func (m *Manager) GetChannel(name string) (Channel, bool)
- func (m *Manager) GetEnabledChannels() []string
- func (m *Manager) GetStatus() map[string]any
- func (m *Manager) RegisterChannel(name string, channel Channel)
- func (m *Manager) SendToChannel(ctx context.Context, channelName, chatID, content string) error
- func (m *Manager) StartAll(ctx context.Context) error
- func (m *Manager) StopAll(ctx context.Context) error
- func (m *Manager) UnregisterChannel(name string)
- type OneBotChannel
- type PKCS7Padding
- type QQChannel
- type SlackChannel
- type TelegramChannel
- type TelegramCommander
- type WeComAccessTokenResponse
- type WeComAppChannel
- type WeComBotChannel
- type WeComBotMessage
- type WeComBotReplyMessage
- type WeComImageMessage
- type WeComMarkdownMessage
- type WeComSendMessageResponse
- type WeComTextMessage
- type WeComXMLMessage
- type WhatsAppChannel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WeComDecryptMessage ¶
WeComDecryptMessage decrypts the encrypted message using AES This is a common function used by both WeCom Bot and WeCom App For AIBOT, receiveid should be the aibotid; for other apps, it should be corp_id
func WeComDecryptMessageWithVerify ¶
WeComDecryptMessageWithVerify decrypts the encrypted message and optionally verifies receiveid receiveid: for AIBOT use aibotid, for WeCom App use corp_id. If empty, skip verification.
func WeComVerifySignature ¶
WeComVerifySignature verifies the message signature for WeCom This is a common function used by both WeCom Bot and WeCom App
Types ¶
type BaseChannel ¶
type BaseChannel struct {
// contains filtered or unexported fields
}
func NewBaseChannel ¶
func NewBaseChannel(name string, config any, 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) 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 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 ¶
func (c *DingTalkChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
Send sends a message to DingTalk via the chatbot reply API
func (*DingTalkChannel) SendDirectReply ¶
func (c *DingTalkChannel) SendDirectReply(ctx context.Context, sessionWebhook, content string) error
SendDirectReply sends a direct reply using the session webhook
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 (c *DiscordChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
func (*DiscordChannel) SetTranscriber ¶
func (c *DiscordChannel) SetTranscriber(transcriber *voice.GroqTranscriber)
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 (c *FeishuChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
type LINEChannel ¶
type LINEChannel struct {
*BaseChannel
// contains filtered or unexported fields
}
LINEChannel implements the Channel interface for LINE Official Account using the LINE Messaging API with HTTP webhook for receiving messages and REST API for sending messages.
func NewLINEChannel ¶
func NewLINEChannel(cfg config.LINEConfig, messageBus *bus.MessageBus) (*LINEChannel, error)
NewLINEChannel creates a new LINE channel instance.
func (*LINEChannel) Send ¶
func (c *LINEChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
Send sends a message to LINE. It first tries the Reply API (free) using a cached reply token, then falls back to the Push API.
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 (c *MaixCamChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
type MaixCamMessage ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) GetEnabledChannels ¶
func (*Manager) RegisterChannel ¶
func (*Manager) SendToChannel ¶
func (*Manager) UnregisterChannel ¶
type OneBotChannel ¶
type OneBotChannel struct {
*BaseChannel
// contains filtered or unexported fields
}
func NewOneBotChannel ¶
func NewOneBotChannel(cfg config.OneBotConfig, messageBus *bus.MessageBus) (*OneBotChannel, error)
func (*OneBotChannel) Send ¶
func (c *OneBotChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
func (*OneBotChannel) SetTranscriber ¶
func (c *OneBotChannel) SetTranscriber(transcriber *voice.GroqTranscriber)
type QQChannel ¶
type QQChannel struct {
*BaseChannel
// contains filtered or unexported fields
}
func NewQQChannel ¶
type SlackChannel ¶
type SlackChannel struct {
*BaseChannel
// contains filtered or unexported fields
}
func NewSlackChannel ¶
func NewSlackChannel(cfg config.SlackConfig, messageBus *bus.MessageBus) (*SlackChannel, error)
func (*SlackChannel) Send ¶
func (c *SlackChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
func (*SlackChannel) SetTranscriber ¶
func (c *SlackChannel) SetTranscriber(transcriber *voice.GroqTranscriber)
type TelegramChannel ¶
type TelegramChannel struct {
*BaseChannel
// contains filtered or unexported fields
}
func NewTelegramChannel ¶
func NewTelegramChannel(cfg *config.Config, bus *bus.MessageBus) (*TelegramChannel, error)
func (*TelegramChannel) Send ¶
func (c *TelegramChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
func (*TelegramChannel) SetTranscriber ¶
func (c *TelegramChannel) SetTranscriber(transcriber *voice.GroqTranscriber)
type TelegramCommander ¶
type TelegramCommander interface {
Help(ctx context.Context, message telego.Message) error
Start(ctx context.Context, message telego.Message) error
Show(ctx context.Context, message telego.Message) error
List(ctx context.Context, message telego.Message) error
}
func NewTelegramCommands ¶
func NewTelegramCommands(bot *telego.Bot, cfg *config.Config) TelegramCommander
type WeComAccessTokenResponse ¶
type WeComAccessTokenResponse struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
}
WeComAccessTokenResponse represents the access token API response
type WeComAppChannel ¶
type WeComAppChannel struct {
*BaseChannel
// contains filtered or unexported fields
}
WeComAppChannel implements the Channel interface for WeCom App (企业微信自建应用)
func NewWeComAppChannel ¶
func NewWeComAppChannel(cfg config.WeComAppConfig, messageBus *bus.MessageBus) (*WeComAppChannel, error)
NewWeComAppChannel creates a new WeCom App channel instance
func (*WeComAppChannel) Name ¶
func (c *WeComAppChannel) Name() string
Name returns the channel name
func (*WeComAppChannel) Send ¶
func (c *WeComAppChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
Send sends a message to WeCom user proactively using access token
type WeComBotChannel ¶
type WeComBotChannel struct {
*BaseChannel
// contains filtered or unexported fields
}
WeComBotChannel implements the Channel interface for WeCom Bot (企业微信智能机器人) Uses webhook callback mode - simpler than WeCom App but only supports passive replies
func NewWeComBotChannel ¶
func NewWeComBotChannel(cfg config.WeComConfig, messageBus *bus.MessageBus) (*WeComBotChannel, error)
NewWeComBotChannel creates a new WeCom Bot channel instance
func (*WeComBotChannel) Name ¶
func (c *WeComBotChannel) Name() string
Name returns the channel name
func (*WeComBotChannel) Send ¶
func (c *WeComBotChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
Send sends a message to WeCom user via webhook API Note: WeCom Bot can only reply within the configured timeout (default 5 seconds) of receiving a message For delayed responses, we use the webhook URL
type WeComBotMessage ¶
type WeComBotMessage struct {
MsgID string `json:"msgid"`
AIBotID string `json:"aibotid"`
ChatID string `json:"chatid"` // Session ID, only present for group chats
ChatType string `json:"chattype"` // "single" for DM, "group" for group chat
From struct {
UserID string `json:"userid"`
} `json:"from"`
ResponseURL string `json:"response_url"`
MsgType string `json:"msgtype"` // text, image, voice, file, mixed
Text struct {
Content string `json:"content"`
} `json:"text"`
Image struct {
URL string `json:"url"`
} `json:"image"`
Voice struct {
Content string `json:"content"` // Voice to text content
} `json:"voice"`
File struct {
URL string `json:"url"`
} `json:"file"`
Mixed struct {
MsgItem []struct {
MsgType string `json:"msgtype"`
Text struct {
Content string `json:"content"`
} `json:"text"`
Image struct {
URL string `json:"url"`
} `json:"image"`
} `json:"msg_item"`
} `json:"mixed"`
Quote struct {
MsgType string `json:"msgtype"`
Text struct {
Content string `json:"content"`
} `json:"text"`
} `json:"quote"`
}
WeComBotMessage represents the JSON message structure from WeCom Bot (AIBOT)
type WeComBotReplyMessage ¶
type WeComBotReplyMessage struct {
MsgType string `json:"msgtype"`
Text struct {
Content string `json:"content"`
} `json:"text,omitempty"`
}
WeComBotReplyMessage represents the reply message structure
type WeComImageMessage ¶
type WeComImageMessage struct {
ToUser string `json:"touser"`
MsgType string `json:"msgtype"`
AgentID int64 `json:"agentid"`
Image struct {
MediaID string `json:"media_id"`
} `json:"image"`
}
WeComImageMessage represents image message for sending
type WeComMarkdownMessage ¶
type WeComMarkdownMessage struct {
ToUser string `json:"touser"`
MsgType string `json:"msgtype"`
AgentID int64 `json:"agentid"`
Markdown struct {
Content string `json:"content"`
} `json:"markdown"`
}
WeComMarkdownMessage represents markdown message for sending
type WeComSendMessageResponse ¶
type WeComSendMessageResponse struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
InvalidUser string `json:"invaliduser"`
InvalidParty string `json:"invalidparty"`
InvalidTag string `json:"invalidtag"`
}
WeComSendMessageResponse represents the send message API response
type WeComTextMessage ¶
type WeComTextMessage struct {
ToUser string `json:"touser"`
MsgType string `json:"msgtype"`
AgentID int64 `json:"agentid"`
Text struct {
Content string `json:"content"`
} `json:"text"`
Safe int `json:"safe,omitempty"`
}
WeComTextMessage represents text message for sending
type WeComXMLMessage ¶
type WeComXMLMessage struct {
XMLName xml.Name `xml:"xml"`
ToUserName string `xml:"ToUserName"`
FromUserName string `xml:"FromUserName"`
CreateTime int64 `xml:"CreateTime"`
MsgType string `xml:"MsgType"`
Content string `xml:"Content"`
MsgId int64 `xml:"MsgId"`
AgentID int64 `xml:"AgentID"`
PicUrl string `xml:"PicUrl"`
MediaId string `xml:"MediaId"`
Format string `xml:"Format"`
ThumbMediaId string `xml:"ThumbMediaId"`
LocationX float64 `xml:"Location_X"`
LocationY float64 `xml:"Location_Y"`
Scale int `xml:"Scale"`
Label string `xml:"Label"`
Title string `xml:"Title"`
Description string `xml:"Description"`
Url string `xml:"Url"`
Event string `xml:"Event"`
EventKey string `xml:"EventKey"`
}
WeComXMLMessage represents the XML message structure from WeCom
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 (c *WhatsAppChannel) Send(ctx context.Context, msg bus.OutboundMessage) error