mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-03 18:47:41 +08:00
add: GetGroupHonorInfo()
This commit is contained in:
parent
ac7fc7ad28
commit
707fb3f7c2
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -11,6 +12,7 @@ import (
|
||||
"math"
|
||||
"math/rand"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@ -173,6 +175,21 @@ func (c *QQClient) Login() (*LoginResponse, error) {
|
||||
return &l, nil
|
||||
}
|
||||
|
||||
func (c *QQClient) GetGroupHonorInfo(groupCode int64, honorType HonorType) (*GroupHonorInfo, error) {
|
||||
b, err := utils.HttpGetBytes(fmt.Sprintf("https://qun.qq.com/interactive/honorlist?gc=%d&type=%d", groupCode, honorType), c.getCookiesWithDomain("qun.qq.com"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rsp := string(b)
|
||||
data := strings.Split(strings.Split(rsp, `window.__INITIAL_STATE__=`)[1], "</script>")[0]
|
||||
ret := GroupHonorInfo{}
|
||||
err = json.Unmarshal([]byte(data), &ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
// SubmitCaptcha send captcha to server
|
||||
func (c *QQClient) SubmitCaptcha(result string, sign []byte) (*LoginResponse, error) {
|
||||
seq, packet := c.buildCaptchaPacket(result, sign)
|
||||
|
@ -777,7 +777,7 @@ func decodeMultiApplyDownResponse(c *QQClient, _ uint16, payload []byte) (interf
|
||||
}
|
||||
rsp := body.MultimsgApplydownRsp[0]
|
||||
i := binary.UInt32ToIPV4Address(uint32(rsp.Uint32DownIp[0]))
|
||||
b, err := utils.HttpGetBytes(fmt.Sprintf("http://%s:%d%s", i, body.MultimsgApplydownRsp[0].Uint32DownPort[0], string(rsp.ThumbDownPara)))
|
||||
b, err := utils.HttpGetBytes(fmt.Sprintf("http://%s:%d%s", i, body.MultimsgApplydownRsp[0].Uint32DownPort[0], string(rsp.ThumbDownPara)), "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -191,9 +191,9 @@ type (
|
||||
|
||||
const (
|
||||
NeedCaptcha LoginError = 1
|
||||
OtherLoginError = 3
|
||||
UnsafeDeviceError = 4
|
||||
UnknownLoginError = -1
|
||||
OtherLoginError LoginError = 3
|
||||
UnsafeDeviceError LoginError = 4
|
||||
UnknownLoginError LoginError = -1
|
||||
|
||||
Owner MemberPermission = iota
|
||||
Administrator
|
||||
|
39
client/honor.go
Normal file
39
client/honor.go
Normal file
@ -0,0 +1,39 @@
|
||||
package client
|
||||
|
||||
type (
|
||||
HonorType int
|
||||
|
||||
GroupHonorInfo struct {
|
||||
GroupCode string `json:"gc"`
|
||||
Uin string `json:"uin"`
|
||||
Type HonorType `json:"type"`
|
||||
TalkativeList []HonorMemberInfo `json:"talkativeList"`
|
||||
CurrentTalkative CurrentTalkative `json:"currentTalkative"`
|
||||
ActorList []HonorMemberInfo `json:"actorList"`
|
||||
LegendList []HonorMemberInfo `json:"legendList"`
|
||||
StrongNewbieList []HonorMemberInfo `json:"strongnewbieList"`
|
||||
EmotionList []HonorMemberInfo `json:"emotionList"`
|
||||
}
|
||||
|
||||
HonorMemberInfo struct {
|
||||
Uin int64 `json:"uin"`
|
||||
Avatar string `json:"avatar"`
|
||||
Name string `json:"name"`
|
||||
Desc string `json:"desc"`
|
||||
}
|
||||
|
||||
CurrentTalkative struct {
|
||||
Uin int64 `json:"uin"`
|
||||
DayCount int32 `json:"day_count"`
|
||||
Avatar string `json:"avatar"`
|
||||
Name string `json:"nick"`
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
Talkative HonorType = 1 //龙王
|
||||
Performer HonorType = 2 //群聊之火
|
||||
Legend HonorType = 3 //群聊炙焰
|
||||
StrongNewbie HonorType = 5 //冒尖小春笋
|
||||
Emotion HonorType = 6 //快乐源泉
|
||||
)
|
@ -8,13 +8,16 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func HttpGetBytes(url string) ([]byte, error) {
|
||||
func HttpGetBytes(url, cookie string) ([]byte, error) {
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header["User-Agent"] = []string{"QQ/8.2.0.1296 CFNetwork/1126"}
|
||||
req.Header["Net-Type"] = []string{"Wifi"}
|
||||
if cookie != "" {
|
||||
req.Header["Cookie"] = []string{cookie}
|
||||
}
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
x
Reference in New Issue
Block a user