add wechat env 🚀

This commit is contained in:
Evan 2022-12-14 14:57:56 +09:00
parent 130392868e
commit 4faf5f28dc
2 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,7 @@ FROM golang:1.19-alpine
ENV apiKey=""
ENV telegram=""
ENV wechat=""
RUN export GOPRIVATE=github.com/houko/wechatgpt

View File

@ -6,6 +6,7 @@ import (
"github.com/wechatgpt/wechatbot/config"
"github.com/wechatgpt/wechatbot/openai"
"log"
"os"
"strings"
)
@ -31,11 +32,13 @@ func (gmh *GroupMessageHandler) ReplyText(msg *openwechat.Message) error {
group := openwechat.Group{User: sender}
log.Printf("Received Group %v Text Msg : %v", group.NickName, msg.Content)
keyword := "chatgpt"
keyword := os.Getenv("wechat")
if len(keyword) == 0 {
appConfig := config.GetConfig()
if appConfig != nil {
keyword = appConfig.ChatGpt.Keyword
}
}
if !strings.Contains(msg.Content, keyword) {
return nil