Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
2b9eabdc97
@ -3,7 +3,7 @@
|
||||
如果觉得不错,请麻烦点个`Star`,非常感谢。(最新己经添加了docker部署的方式)
|
||||
|
||||
<p>
|
||||
<img alt="Version" src="https://img.shields.io/badge/version-2.0.0-blue.svg?cacheSeconds=86400" />
|
||||
<img alt="Version" src="https://img.shields.io/badge/version-2.9.3-blue.svg?cacheSeconds=86400" />
|
||||
<a href="#" target="_blank">
|
||||
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-green.svg" />
|
||||
</a>
|
||||
|
@ -35,12 +35,11 @@ func LoadConfig() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetConfig() *Config {
|
||||
return config
|
||||
}
|
||||
|
||||
func GetWechat() *string {
|
||||
wechat := getEnv("wechat")
|
||||
if config == nil {
|
||||
return nil
|
||||
}
|
||||
if wechat == nil {
|
||||
wechat = config.ChatGpt.Wechat
|
||||
}
|
||||
@ -49,6 +48,9 @@ func GetWechat() *string {
|
||||
|
||||
func GetWechatKeyword() *string {
|
||||
keyword := getEnv("wechat_keyword")
|
||||
if config == nil {
|
||||
return nil
|
||||
}
|
||||
if keyword == nil {
|
||||
keyword = config.ChatGpt.WechatKeyword
|
||||
}
|
||||
@ -57,7 +59,9 @@ func GetWechatKeyword() *string {
|
||||
|
||||
func GetTelegram() *string {
|
||||
tg := getEnv("telegram")
|
||||
|
||||
if config == nil {
|
||||
return nil
|
||||
}
|
||||
if tg == nil {
|
||||
tg = config.ChatGpt.Telegram
|
||||
}
|
||||
@ -66,6 +70,9 @@ func GetTelegram() *string {
|
||||
|
||||
func GetTelegramKeyword() *string {
|
||||
tgKeyword := getEnv("tg_keyword")
|
||||
if config == nil {
|
||||
return nil
|
||||
}
|
||||
if tgKeyword == nil {
|
||||
tgKeyword = config.ChatGpt.TgKeyword
|
||||
}
|
||||
@ -74,6 +81,9 @@ func GetTelegramKeyword() *string {
|
||||
|
||||
func GetTelegramWhitelist() *string {
|
||||
tgWhitelist := getEnv("tg_whitelist")
|
||||
if config == nil {
|
||||
return nil
|
||||
}
|
||||
if tgWhitelist == nil {
|
||||
tgWhitelist = config.ChatGpt.TgWhitelist
|
||||
}
|
||||
@ -82,6 +92,9 @@ func GetTelegramWhitelist() *string {
|
||||
|
||||
func GetOpenAiApiKey() *string {
|
||||
apiKey := getEnv("api_key")
|
||||
if config == nil {
|
||||
return nil
|
||||
}
|
||||
if apiKey == nil {
|
||||
apiKey = &config.ChatGpt.Token
|
||||
}
|
||||
@ -90,6 +103,9 @@ func GetOpenAiApiKey() *string {
|
||||
|
||||
func getEnv(key string) *string {
|
||||
value := os.Getenv(key)
|
||||
if config == nil {
|
||||
return nil
|
||||
}
|
||||
if len(value) > 0 {
|
||||
return &value
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ func (gmh *GroupMessageHandler) ReplyText(msg *openwechat.Message) error {
|
||||
wechat := config.GetWechatKeyword()
|
||||
requestText := msg.Content
|
||||
if wechat != nil {
|
||||
content, key := utils.ContainsI(msg.Content, *wechat)
|
||||
content, key := utils.ContainsI(requestText, *wechat)
|
||||
if len(key) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user