Skip to content

Commit

Permalink
Merge pull request #263 from hehan-wang/master
Browse files Browse the repository at this point in the history
feat: add feishu base url
  • Loading branch information
Leizhenpeng authored Aug 31, 2023
2 parents c56a1df + bd8f07f commit a555b0a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions code/config.example.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 飞书
BASE_URL: https://open.feishu.cn
APP_ID: cli_axxx
APP_SECRET: xxx
APP_ENCRYPT_KEY: xxx
Expand Down
7 changes: 5 additions & 2 deletions code/initialization/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ package initialization

import (
"fmt"
"github.com/spf13/pflag"
"os"
"strconv"
"strings"
"sync"

"github.com/spf13/pflag"

"github.com/spf13/viper"
)

type Config struct {
// 表示配置是否已经被初始化了。
Initialized bool
FeishuBaseUrl string
FeishuAppId string
FeishuAppSecret string
FeishuAppEncryptKey string
Expand Down Expand Up @@ -64,6 +66,7 @@ func LoadConfig(cfg string) *Config {
//fmt.Println(string(content))

config := &Config{
FeishuBaseUrl: getViperStringValue("BASE_URL", ""),
FeishuAppId: getViperStringValue("APP_ID", ""),
FeishuAppSecret: getViperStringValue("APP_SECRET", ""),
FeishuAppEncryptKey: getViperStringValue("APP_ENCRYPT_KEY", ""),
Expand Down Expand Up @@ -163,7 +166,7 @@ func filterFormatKey(keys []string) []string {
var result []string
for _, key := range keys {
if strings.HasPrefix(key, "sk-") || strings.HasPrefix(key,
"fk") {
"fk") || strings.HasPrefix(key, "fastgpt") {
result = append(result, key)
}
}
Expand Down
9 changes: 7 additions & 2 deletions code/initialization/lark_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ import (
var larkClient *lark.Client

func LoadLarkClient(config Config) {
options := []lark.ClientOptionFunc{
lark.WithLogLevel(larkcore.LogLevelDebug),
}
if config.FeishuBaseUrl != "" {
options = append(options, lark.WithOpenBaseUrl(config.FeishuBaseUrl))
}

option := lark.WithLogLevel(larkcore.LogLevelDebug)
larkClient = lark.NewClient(config.FeishuAppId, config.FeishuAppSecret, option)
larkClient = lark.NewClient(config.FeishuAppId, config.FeishuAppSecret, options...)

}

Expand Down

0 comments on commit a555b0a

Please sign in to comment.