Fix wechatbot
This commit is contained in:
parent
c70ea53d93
commit
f93d65abe6
@ -6,4 +6,4 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o chatgpt
|
||||
FROM alpine:3.17.2
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/chatgpt .
|
||||
ENTRYPOINT ["./chatgpt", ">>", "chatgpt.log", "2>&1"]
|
||||
ENTRYPOINT ["./chatgpt"]
|
||||
|
||||
@ -56,7 +56,7 @@ func BingSearch(msg string, nickName string) (string, error) {
|
||||
return "非常抱歉😭,网络异常,请稍后重试", err
|
||||
}
|
||||
if response.StatusCode != 200 {
|
||||
return "非常抱歉😭,网络异常,请稍后重试 [" + string(rune(response.StatusCode)) + "]", nil
|
||||
return "非常抱歉😭,网络异常,请稍后重试 [" + string(response.StatusCode) + "]", nil
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
|
||||
@ -49,9 +49,9 @@ func Completions(msg string, nickName string) (string, error) {
|
||||
messageCache = []Message{message}
|
||||
} else {
|
||||
messageCache = append(messageCache, message)
|
||||
// 只保留10条
|
||||
if len(messageCache) > 10 {
|
||||
messageCache = messageCache[(len(messageCache) - 10):]
|
||||
// 只保留20条
|
||||
if len(messageCache) > 20 {
|
||||
messageCache = messageCache[(len(messageCache) - 20):]
|
||||
}
|
||||
}
|
||||
MessageCacheRegistry[nickName] = messageCache
|
||||
|
||||
@ -23,6 +23,9 @@ func (g *GroupMessageHandler) handle(msg *openwechat.Message) error {
|
||||
msg.ReplyText("目前我只支持文字哦~")
|
||||
}
|
||||
}
|
||||
if msg.IsPaiYiPai() {
|
||||
msg.ReplyText("我是机器人🤖️,会拍坏的哦~")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,12 @@ func (g *UserMessageHandler) handle(msg *openwechat.Message) error {
|
||||
if msg.IsText() {
|
||||
return g.ReplyText(msg)
|
||||
}
|
||||
if msg.IsSendByFriend() {
|
||||
msg.ReplyText("目前我只支持文字哦~")
|
||||
}
|
||||
if msg.IsPaiYiPai() {
|
||||
msg.ReplyText("我是机器人🤖️,会拍坏的哦~")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user