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:
parent
12f4029610
commit
f70db84f47
2 changed files with 11 additions and 1 deletions
|
|
@ -54,11 +54,15 @@ func NewFeishuChannel(cfg config.FeishuConfig, bus *bus.MessageBus) (*FeishuChan
|
||||||
)
|
)
|
||||||
|
|
||||||
tc := newTokenCache()
|
tc := newTokenCache()
|
||||||
|
opts := []lark.ClientOptionFunc{lark.WithTokenCache(tc)}
|
||||||
|
if cfg.IsLark {
|
||||||
|
opts = append(opts, lark.WithOpenBaseUrl(lark.LarkBaseUrl))
|
||||||
|
}
|
||||||
ch := &FeishuChannel{
|
ch := &FeishuChannel{
|
||||||
BaseChannel: base,
|
BaseChannel: base,
|
||||||
config: cfg,
|
config: cfg,
|
||||||
tokenCache: tc,
|
tokenCache: tc,
|
||||||
client: lark.NewClient(cfg.AppID, cfg.AppSecret, lark.WithTokenCache(tc)),
|
client: lark.NewClient(cfg.AppID, cfg.AppSecret, opts...),
|
||||||
}
|
}
|
||||||
ch.SetOwner(ch)
|
ch.SetOwner(ch)
|
||||||
return ch, nil
|
return ch, nil
|
||||||
|
|
@ -83,10 +87,15 @@ func (c *FeishuChannel) Start(ctx context.Context) error {
|
||||||
|
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
c.cancel = cancel
|
c.cancel = cancel
|
||||||
|
domain := lark.FeishuBaseUrl
|
||||||
|
if c.config.IsLark {
|
||||||
|
domain = lark.LarkBaseUrl
|
||||||
|
}
|
||||||
c.wsClient = larkws.NewClient(
|
c.wsClient = larkws.NewClient(
|
||||||
c.config.AppID,
|
c.config.AppID,
|
||||||
c.config.AppSecret,
|
c.config.AppSecret,
|
||||||
larkws.WithEventHandler(dispatcher),
|
larkws.WithEventHandler(dispatcher),
|
||||||
|
larkws.WithDomain(domain),
|
||||||
)
|
)
|
||||||
wsClient := c.wsClient
|
wsClient := c.wsClient
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,7 @@ type FeishuConfig struct {
|
||||||
Placeholder PlaceholderConfig `json:"placeholder,omitempty"`
|
Placeholder PlaceholderConfig `json:"placeholder,omitempty"`
|
||||||
ReasoningChannelID string `json:"reasoning_channel_id" env:"PICOCLAW_CHANNELS_FEISHU_REASONING_CHANNEL_ID"`
|
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"`
|
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 {
|
type DiscordConfig struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue