feat: 添加获取登录账户信息的功能,并更新相关数据结构和常量
This commit is contained in:
parent
546f1abcd1
commit
eba07290a9
@ -104,15 +104,3 @@ func (am *actionManager) DrawbackMsg(msgId int32) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (am *actionManager) GetGroupMemberList(groupId int64) ([]int64, error) {
|
|
||||||
askGroupMemberListPkg := model.GenGetGroupMemberListPkg(groupId)
|
|
||||||
askGroupMemberListPkgJson, err := json.Marshal(askGroupMemberListPkg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err = am.botConn.WriteMessage(websocket.TextMessage, askGroupMemberListPkgJson); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return nil, nil //todo
|
|
||||||
}
|
|
||||||
|
@ -56,3 +56,26 @@ func GetGroupList() ([]model.Group, error) {
|
|||||||
|
|
||||||
return groupListResponse.Data, nil
|
return groupListResponse.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (am *actionManager) GetLoginAccountInfo() (*model.LoginAccountInfoResponse, error) {
|
||||||
|
fullURL := fmt.Sprintf("http://%s%s", config.ConfigManager.GetConfig().Management.NapcatHttpSrv, constants.GET_LOGIN_INFO)
|
||||||
|
|
||||||
|
response, err := http.Post(fullURL, "application/json", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
body, err := io.ReadAll(response.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var loginAccountInfoResponse model.LoginAccountInfoResponse
|
||||||
|
err = json.Unmarshal(body, &loginAccountInfoResponse)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &loginAccountInfoResponse, nil
|
||||||
|
}
|
||||||
|
@ -3,4 +3,5 @@ package constants
|
|||||||
const (
|
const (
|
||||||
GET_GROUP_LIST = "/get_group_list"
|
GET_GROUP_LIST = "/get_group_list"
|
||||||
GET_GROUP_MEMBER_LIST = "/get_group_member_list"
|
GET_GROUP_MEMBER_LIST = "/get_group_member_list"
|
||||||
|
GET_LOGIN_INFO = "/get_login_info"
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package help
|
package help
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"git.lxtend.com/qqbot/action"
|
"git.lxtend.com/qqbot/action"
|
||||||
"git.lxtend.com/qqbot/constants"
|
"git.lxtend.com/qqbot/constants"
|
||||||
"git.lxtend.com/qqbot/handler"
|
"git.lxtend.com/qqbot/handler"
|
||||||
@ -32,8 +35,16 @@ func help(msg model.Message) *model.Reply {
|
|||||||
textMsg := message.NewTextMessage()
|
textMsg := message.NewTextMessage()
|
||||||
textMsg.Data.Text = helpInfo
|
textMsg.Data.Text = helpInfo
|
||||||
nodeMsg := message.NewNodeMessage()
|
nodeMsg := message.NewNodeMessage()
|
||||||
nodeMsg.Data.UserID = "123456789"
|
loginAccountInfo, err := action.ActionManager.GetLoginAccountInfo()
|
||||||
nodeMsg.Data.Nickname = "test"
|
if err != nil {
|
||||||
|
log.Println("GetLoginAccountInfo error:", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if loginAccountInfo == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
nodeMsg.Data.UserID = strconv.FormatInt(int64(loginAccountInfo.Data.UserID), 10)
|
||||||
|
nodeMsg.Data.Nickname = loginAccountInfo.Data.Nickname
|
||||||
nodeMsg.Data.Content = []any{&textMsg}
|
nodeMsg.Data.Content = []any{&textMsg}
|
||||||
action.ActionManager.SendForward(&model.Reply{
|
action.ActionManager.SendForward(&model.Reply{
|
||||||
ReplyMsg: []any{&nodeMsg},
|
ReplyMsg: []any{&nodeMsg},
|
||||||
|
@ -45,3 +45,15 @@ type GroupMemberListResponse struct {
|
|||||||
Wording string `json:"wording"`
|
Wording string `json:"wording"`
|
||||||
Echo string `json:"echo"`
|
Echo string `json:"echo"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LoginAccountInfoResponse struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
Retcode int `json:"retcode"`
|
||||||
|
Data struct {
|
||||||
|
UserID int `json:"user_id"`
|
||||||
|
Nickname string `json:"nickname"`
|
||||||
|
} `json:"data"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
Wording string `json:"wording"`
|
||||||
|
Echo string `json:"echo"`
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user