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