Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions handler/wechat/wechat_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,26 @@ func (gmh *GroupMessageHandler) ReplyText(msg *openwechat.Message) error {
log.Printf("Received Group %v Text Msg : %v", group.NickName, msg.Content)

wechat := config.GetWechatKeyword()
if nil == wechat {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个判断会让微信没有关键字话就不会回复,我之前经常会自己给自己的微信发消息问问题。

return nil
}

requestText := msg.Content
if wechat != nil {
content, key := utils.ContainsI(requestText, *wechat)
if len(key) == 0 {
return nil
}
splitItems := strings.Split(content, key)
if len(splitItems) < 2 {
return nil
}
requestText = strings.TrimSpace(splitItems[1])

content, key := utils.ContainsI(requestText, *wechat)
if len(key) == 0 {
return nil
}
splitItems := strings.Split(content, key)
if len(splitItems) < 2 {
return nil
}
requestText = strings.TrimSpace(splitItems[1])

if "" == requestText {
return nil
}

log.Println("问题:", requestText)
reply, err := openai.Completions(requestText)
if err != nil {
Expand Down