feishu

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

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 NewBot

func NewBot(appID, appSecret string) *Bot

NewBot creates a new Feishu bot instance

func (*Bot) AddTypingIndicator

func (b *Bot) AddTypingIndicator(messageID string) bool

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

func (b *Bot) DebounceWindow() int

DebounceWindow returns the configured debounce window in milliseconds. Returns 0 if debouncing is disabled.

func (*Bot) DownloadMedia

func (b *Bot) DownloadMedia(ctx context.Context, msg *bot.BotMessage) error

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

func (b *Bot) RemoveTypingIndicator(messageID string) error

RemoveTypingIndicator removes the typing reaction from a message

func (*Bot) SendMessage

func (b *Bot) SendMessage(chatID, message string) error

SendMessage sends a message to a Feishu chat

func (*Bot) SendMessageWithReply

func (b *Bot) SendMessageWithReply(channel, message, replyToMessageID string) error

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

func (b *Bot) SetDebounceMs(ms int)

SetDebounceMs configures the debounce window in milliseconds. Set to 0 to disable debouncing.

func (*Bot) SetEncryptKey

func (b *Bot) SetEncryptKey(key string)

SetEncryptKey sets the encryption key for event verification

func (*Bot) SetMediaConfig

func (b *Bot) SetMediaConfig(dir string, ttl time.Duration, maxSize int64)

SetMediaConfig configures media download parameters.

func (*Bot) SetMentionInGroup

func (b *Bot) SetMentionInGroup(mention bool)

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

func (b *Bot) SetProxyManager(mgr proxy.Manager)

SetProxyManager sets the proxy manager for the Feishu bot

func (*Bot) SetVerificationToken

func (b *Bot) SetVerificationToken(token string)

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) Stop

func (b *Bot) Stop() error

Stop closes the Feishu WebSocket connection and cleans up resources

func (*Bot) SupportsTypingIndicator

func (b *Bot) SupportsTypingIndicator() bool

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

Jump to

Keyboard shortcuts

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