Skip to content

Commit bd8f07f

Browse files
committed
feat: add feishu base url
1 parent c56a1df commit bd8f07f

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

code/config.example.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# 飞书
2+
BASE_URL: https://open.feishu.cn
23
APP_ID: cli_axxx
34
APP_SECRET: xxx
45
APP_ENCRYPT_KEY: xxx

code/initialization/config.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ package initialization
22

33
import (
44
"fmt"
5-
"github.com/spf13/pflag"
65
"os"
76
"strconv"
87
"strings"
98
"sync"
109

10+
"github.com/spf13/pflag"
11+
1112
"github.com/spf13/viper"
1213
)
1314

1415
type Config struct {
1516
// 表示配置是否已经被初始化了。
1617
Initialized bool
18+
FeishuBaseUrl string
1719
FeishuAppId string
1820
FeishuAppSecret string
1921
FeishuAppEncryptKey string
@@ -64,6 +66,7 @@ func LoadConfig(cfg string) *Config {
6466
//fmt.Println(string(content))
6567

6668
config := &Config{
69+
FeishuBaseUrl: getViperStringValue("BASE_URL", ""),
6770
FeishuAppId: getViperStringValue("APP_ID", ""),
6871
FeishuAppSecret: getViperStringValue("APP_SECRET", ""),
6972
FeishuAppEncryptKey: getViperStringValue("APP_ENCRYPT_KEY", ""),
@@ -163,7 +166,7 @@ func filterFormatKey(keys []string) []string {
163166
var result []string
164167
for _, key := range keys {
165168
if strings.HasPrefix(key, "sk-") || strings.HasPrefix(key,
166-
"fk") {
169+
"fk") || strings.HasPrefix(key, "fastgpt") {
167170
result = append(result, key)
168171
}
169172
}

code/initialization/lark_client.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ import (
88
var larkClient *lark.Client
99

1010
func LoadLarkClient(config Config) {
11+
options := []lark.ClientOptionFunc{
12+
lark.WithLogLevel(larkcore.LogLevelDebug),
13+
}
14+
if config.FeishuBaseUrl != "" {
15+
options = append(options, lark.WithOpenBaseUrl(config.FeishuBaseUrl))
16+
}
1117

12-
option := lark.WithLogLevel(larkcore.LogLevelDebug)
13-
larkClient = lark.NewClient(config.FeishuAppId, config.FeishuAppSecret, option)
18+
larkClient = lark.NewClient(config.FeishuAppId, config.FeishuAppSecret, options...)
1419

1520
}
1621

0 commit comments

Comments
 (0)