init push
This commit is contained in:
33
backend/pkg/bot/wechat_official_account/official_account.go
Normal file
33
backend/pkg/bot/wechat_official_account/official_account.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package wechat_official_account
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/silenceper/wechat/v2/officialaccount/user"
|
||||
|
||||
"github.com/chaitin/panda-wiki/pkg/bot"
|
||||
"github.com/chaitin/panda-wiki/pkg/bot/wechat_service"
|
||||
|
||||
"github.com/chaitin/panda-wiki/domain"
|
||||
)
|
||||
|
||||
func Wechat(ctx context.Context, GetQA bot.GetQAFun, userinfo *user.Info, content string) (string, error) {
|
||||
|
||||
wccontent, err := GetQA(ctx, content, domain.ConversationInfo{UserInfo: domain.UserInfo{
|
||||
UserID: userinfo.OpenID, // 用户对话的id
|
||||
NickName: userinfo.Nickname, //用户微信的昵称
|
||||
Avatar: userinfo.Headimgurl, // 用户微信的头像
|
||||
From: domain.MessageFromPrivate,
|
||||
}}, "")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var response string
|
||||
for v := range wccontent {
|
||||
response += v
|
||||
}
|
||||
response = wechat_service.MarkdowntoText(response)
|
||||
|
||||
return response, nil
|
||||
}
|
||||
Reference in New Issue
Block a user