add wechat env 🚀

This commit is contained in:
Evan 2022-12-14 15:59:16 +09:00
parent 677cafaaa0
commit b548ce9693
3 changed files with 5 additions and 1 deletions

View File

@ -67,6 +67,7 @@ docker run -d --name wechatgpt -e apiKey="你的chatgpt apiKey" -e wechat="触
docker run -d --name wechatgpt -e apiKey="你的chatgpt apiKey" -e wechat="触发关键字" xiaomoinfo/wechatgpt-amd64:latest docker run -d --name wechatgpt -e apiKey="你的chatgpt apiKey" -e wechat="触发关键字" xiaomoinfo/wechatgpt-amd64:latest
``` ```
<img src="screenshots/docker部署.png" alt="drawing" style="width:250px;"/>
### 微信 ### 微信

View File

@ -3,9 +3,9 @@ package wechat
import ( import (
"fmt" "fmt"
"github.com/eatmoreapple/openwechat" "github.com/eatmoreapple/openwechat"
log "github.com/sirupsen/logrus"
"github.com/wechatgpt/wechatbot/config" "github.com/wechatgpt/wechatbot/config"
"github.com/wechatgpt/wechatbot/openai" "github.com/wechatgpt/wechatbot/openai"
"log"
"os" "os"
"strings" "strings"
) )
@ -37,6 +37,8 @@ func (gmh *GroupMessageHandler) ReplyText(msg *openwechat.Message) error {
appConfig := config.GetConfig() appConfig := config.GetConfig()
if appConfig != nil { if appConfig != nil {
keyword = appConfig.ChatGpt.Keyword keyword = appConfig.ChatGpt.Keyword
} else {
keyword = "chatgpt"
} }
} }
@ -48,6 +50,7 @@ func (gmh *GroupMessageHandler) ReplyText(msg *openwechat.Message) error {
return nil return nil
} }
requestText := strings.TrimSpace(splitItems[1]) requestText := strings.TrimSpace(splitItems[1])
log.Println("问题:%s", requestText)
reply, err := openai.Completions(requestText) reply, err := openai.Completions(requestText)
if err != nil { if err != nil {
log.Println(err) log.Println(err)

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB