MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / GetGroupHonorInfo

Method GetGroupHonorInfo

client/operation.go:1096–1125  ·  view source on GitHub ↗

GetGroupHonorInfo 获取群荣誉信息 reference https://github.com/Mrs4s/MiraiGo/blob/master/client/http_api.go

(groupUin uint32, honorType entity.HonorType)

Source from the content-addressed store, hash-verified

1094// GetGroupHonorInfo 获取群荣誉信息
1095// reference https://github.com/Mrs4s/MiraiGo/blob/master/client/http_api.go
1096func (c *QQClient) GetGroupHonorInfo(groupUin uint32, honorType entity.HonorType) (*entity.GroupHonorInfo, error) {
1097 ret := &entity.GroupHonorInfo{}
1098 honorRe := regexp.MustCompile(`window\.__INITIAL_STATE__\s*?=\s*?(\{.*})`)
1099 reqURL := fmt.Sprintf("https://qun.qq.com/interactive/honorlist?gc=%d&type=%d", groupUin, honorType)
1100 req, err := http.NewRequest(http.MethodGet, reqURL, nil)
1101 if err != nil {
1102 return ret, err
1103 }
1104 resp, err := c.SendRequestWithCookie(req)
1105 if err != nil {
1106 return ret, err
1107 }
1108 respData, err := io.ReadAll(resp.Body)
1109 if err != nil {
1110 return nil, err
1111 }
1112 _ = resp.Body.Close()
1113 if resp.StatusCode != http.StatusOK {
1114 return ret, fmt.Errorf("error resp code %d", resp.StatusCode)
1115 }
1116 matched := honorRe.FindSubmatch(respData)
1117 if len(matched) == 0 {
1118 return nil, errors.New("no matched data")
1119 }
1120 err = json.NewDecoder(bytes.NewReader(matched[1])).Decode(&ret)
1121 if err != nil {
1122 return nil, err
1123 }
1124 return ret, nil
1125}
1126
1127// GetGroupNotice 获取群公告
1128func (c *QQClient) GetGroupNotice(groupUin uint32) (l []*entity.GroupNoticeFeed, err error) {

Callers

nothing calls this directly

Calls 3

SendRequestWithCookieMethod · 0.95
ReadAllMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected