package wxwork import ( "code.tczkiot.com/wlw/ai-agent/internal/pkg/config" "strings" "github.com/silenceper/wechat/v2/cache" "github.com/silenceper/wechat/v2/work" wxconfig "github.com/silenceper/wechat/v2/work/config" ) var ( w *work.Work wxCfg config.WxWorkConfig ) func Init() { w = nil wxCfg = config.WxWorkConfig{} cfg := config.Current() if !cfg.WxWork.Enabled { return } wxCfg = cfg.WxWork if strings.TrimSpace(wxCfg.CorpID) == "" || strings.TrimSpace(wxCfg.CorpSecret) == "" { return } w = work.NewWork(&wxconfig.Config{ CorpID: wxCfg.CorpID, CorpSecret: wxCfg.CorpSecret, AgentID: wxCfg.AgentID, RasPrivateKey: wxCfg.RSAPrivateKey, Token: wxCfg.Token, EncodingAESKey: wxCfg.EncodingAESKey, Cache: cache.NewMemory(), }) } func Enabled() bool { return w != nil && wxCfg.Enabled } func GetWorkCli() *work.Work { return w }