feat(feishu): add Lark (international) support via IsLark config field

Add IsLark field to FeishuConfig to switch between Feishu and Lark
domains. Also fix domain inconsistency where WS client defaulted to
LarkBaseUrl while HTTP client used FeishuBaseUrl.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Liqiang Liu 2026-03-18 22:00:10 +08:00
parent 12f4029610
commit f70db84f47
2 changed files with 11 additions and 1 deletions

View file

@ -54,11 +54,15 @@ func NewFeishuChannel(cfg config.FeishuConfig, bus *bus.MessageBus) (*FeishuChan
)
tc := newTokenCache()
opts := []lark.ClientOptionFunc{lark.WithTokenCache(tc)}
if cfg.IsLark {
opts = append(opts, lark.WithOpenBaseUrl(lark.LarkBaseUrl))
}
ch := &FeishuChannel{
BaseChannel: base,
config: cfg,
tokenCache: tc,
client: lark.NewClient(cfg.AppID, cfg.AppSecret, lark.WithTokenCache(tc)),
client: lark.NewClient(cfg.AppID, cfg.AppSecret, opts...),
}
ch.SetOwner(ch)
return ch, nil
@ -83,10 +87,15 @@ func (c *FeishuChannel) Start(ctx context.Context) error {
c.mu.Lock()
c.cancel = cancel
domain := lark.FeishuBaseUrl
if c.config.IsLark {
domain = lark.LarkBaseUrl
}
c.wsClient = larkws.NewClient(
c.config.AppID,
c.config.AppSecret,
larkws.WithEventHandler(dispatcher),
larkws.WithDomain(domain),
)
wsClient := c.wsClient
c.mu.Unlock()

View file

@ -325,6 +325,7 @@ type FeishuConfig struct {
Placeholder PlaceholderConfig `json:"placeholder,omitempty"`
ReasoningChannelID string `json:"reasoning_channel_id" env:"PICOCLAW_CHANNELS_FEISHU_REASONING_CHANNEL_ID"`
RandomReactionEmoji FlexibleStringSlice `json:"random_reaction_emoji" env:"PICOCLAW_CHANNELS_FEISHU_RANDOM_REACTION_EMOJI"`
IsLark bool `json:"is_lark" env:"PICOCLAW_CHANNELS_FEISHU_IS_LARK"`
}
type DiscordConfig struct {