Documentation
¶
Index ¶
- type Bot
- func (b *Bot) AddTypingIndicator(messageID string) bool
- func (b *Bot) CreateRichMessage(channel string, opts bot.RichMessageOptions) (bot.RichMessageHandle, error)
- func (b *Bot) DebounceWindow() int
- func (b *Bot) DownloadMedia(ctx context.Context, msg *bot.BotMessage) error
- func (b *Bot) FetchQuotedMessage(ctx context.Context, channelID, messageID string) (*bot.QuotedMessage, error)
- func (b *Bot) GetMessageHandler() func(bot.BotMessage)
- func (b *Bot) RemoveTypingIndicator(messageID string) error
- func (b *Bot) SendMessage(chatID, message string) error
- func (b *Bot) SendMessageWithReply(channel, message, replyToMessageID string) error
- func (b *Bot) SetDebounceMs(ms int)
- func (b *Bot) SetEncryptKey(key string)
- func (b *Bot) SetMediaConfig(dir string, ttl time.Duration, maxSize int64)
- func (b *Bot) SetMentionInGroup(mention bool)
- func (b *Bot) SetMessageHandler(handler func(bot.BotMessage))
- func (b *Bot) SetProxyManager(mgr proxy.Manager)
- func (b *Bot) SetVerificationToken(token string)
- func (b *Bot) ShouldRespond(msg bot.BotMessage) bool
- func (b *Bot) Start(messageHandler func(bot.BotMessage)) error
- func (b *Bot) Stop() error
- func (b *Bot) SupportsTypingIndicator() bool
- func (b *Bot) ThreadScope(channelID string, msg bot.BotMessage) string
- type FileContent
- type ImageContent
- type TextContent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot implements BotAdapter interface for Feishu (Lark) using WebSocket long connection
func (*Bot) AddTypingIndicator ¶
AddTypingIndicator adds a typing reaction to a message
func (*Bot) CreateRichMessage ¶
func (b *Bot) CreateRichMessage(channel string, opts bot.RichMessageOptions) (bot.RichMessageHandle, error)
CreateRichMessage creates a CardKit card and sends it to the channel.
func (*Bot) DebounceWindow ¶
DebounceWindow returns the configured debounce window in milliseconds. Returns 0 if debouncing is disabled.
func (*Bot) DownloadMedia ¶
DownloadMedia downloads media files from Feishu and attaches them to the message. Skips text and sticker messages. Returns nil on skip or error (non-blocking).
func (*Bot) FetchQuotedMessage ¶
func (b *Bot) FetchQuotedMessage(ctx context.Context, channelID, messageID string) (*bot.QuotedMessage, error)
FetchQuotedMessage fetches a referenced message by its ID using the Feishu API. Returns nil if messageID is empty.
func (*Bot) GetMessageHandler ¶
func (b *Bot) GetMessageHandler() func(bot.BotMessage)
GetMessageHandler gets the message handler in a thread-safe manner
func (*Bot) RemoveTypingIndicator ¶
RemoveTypingIndicator removes the typing reaction from a message
func (*Bot) SendMessage ¶
SendMessage sends a message to a Feishu chat
func (*Bot) SendMessageWithReply ¶
SendMessageWithReply sends a message that visually references a parent message. Uses the Feishu Reply API when a replyToMessageID is provided. Falls back to regular SendMessage on any error.
func (*Bot) SetDebounceMs ¶
SetDebounceMs configures the debounce window in milliseconds. Set to 0 to disable debouncing.
func (*Bot) SetEncryptKey ¶
SetEncryptKey sets the encryption key for event verification
func (*Bot) SetMediaConfig ¶
SetMediaConfig configures media download parameters.
func (*Bot) SetMentionInGroup ¶
SetMentionInGroup configures whether the bot requires an explicit @mention in group/topic chats to respond.
func (*Bot) SetMessageHandler ¶
func (b *Bot) SetMessageHandler(handler func(bot.BotMessage))
SetMessageHandler sets the message handler in a thread-safe manner
func (*Bot) SetProxyManager ¶
SetProxyManager sets the proxy manager for the Feishu bot
func (*Bot) SetVerificationToken ¶
SetVerificationToken sets the verification token for event verification
func (*Bot) ShouldRespond ¶
func (b *Bot) ShouldRespond(msg bot.BotMessage) bool
ShouldRespond determines whether the bot should respond to a message based on mention rules and chat type.
Rules:
- p2p or empty chatType: always respond
- group/topic with mentionInGroup=true: only respond if content contains @_user_1
- group/topic with mentionInGroup=false: always respond
func (*Bot) Start ¶
func (b *Bot) Start(messageHandler func(bot.BotMessage)) error
Start establishes WebSocket long connection to Feishu and begins listening for messages
func (*Bot) SupportsTypingIndicator ¶
SupportsTypingIndicator returns true as Feishu supports message reactions
func (*Bot) ThreadScope ¶
func (b *Bot) ThreadScope(channelID string, msg bot.BotMessage) string
ThreadScope returns the session scope key for a message, considering thread/topic context. For topic messages with a ThreadID, it returns "channelID:threadID" for thread isolation. Otherwise, it returns the channelID unchanged.
type FileContent ¶
type FileContent struct {
FileKey string `json:"file_key"`
FileName string `json:"file_name"`
FileSize string `json:"file_size"`
}
FileContent represents the JSON structure of Feishu file message content
type ImageContent ¶
type ImageContent struct {
ImageKey string `json:"image_key"`
}
ImageContent represents the JSON structure of Feishu image message content
type TextContent ¶
type TextContent struct {
Text string `json:"text"`
}
TextContent represents the JSON structure of Feishu text message content