Skip to content

Commit

Permalink
fix: 导出client.Version
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmomn committed Dec 26, 2024
1 parent 824e2c5 commit 237c559
Showing 4 changed files with 22 additions and 21 deletions.
6 changes: 3 additions & 3 deletions client/base.go
Original file line number Diff line number Diff line change
@@ -162,12 +162,12 @@ func (c *QQClient) UseVersion(app *auth.AppInfo) {

func (c *QQClient) UseSignProvider(p sign.Provider) {
c.signProvider = p
if c.version() != nil {
c.signProvider.SetAppInfo(c.version())
if c.Version() != nil {
c.signProvider.SetAppInfo(c.Version())
}
}

func (c *QQClient) version() *auth.AppInfo {
func (c *QQClient) Version() *auth.AppInfo {
return c.transport.Version
}

26 changes: 13 additions & 13 deletions client/client.go
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ func (c *QQClient) TokenLogin() (*LoginResponse, error) {
if c.Online.Load() {
return nil, ErrAlreadyOnline
}
data, err := buildNtloginRequest(c.Uin, c.version(), c.Device(), &c.transport.Sig, c.transport.Sig.TempPwd)
data, err := buildNtloginRequest(c.Uin, c.Version(), c.Device(), &c.transport.Sig, c.transport.Sig.TempPwd)
if err != nil {
return nil, err
}
@@ -62,14 +62,14 @@ func (c *QQClient) FetchQRCode(size, margin, ecLevel uint32) ([]byte, string, er
WriteU64(0).
WriteU8(0).
WriteTLV(
tlv.T16(c.version().AppID, c.version().SubAppID,
utils.MustParseHexStr(c.Device().GUID), c.version().PTVersion, c.version().PackageName),
tlv.T16(c.Version().AppID, c.Version().SubAppID,
utils.MustParseHexStr(c.Device().GUID), c.Version().PTVersion, c.Version().PackageName),
tlv.T1b(0, 0, size, margin, 72, ecLevel, 2),
tlv.T1d(c.version().MiscBitmap),
tlv.T1d(c.Version().MiscBitmap),
tlv.T33(utils.MustParseHexStr(c.Device().GUID)),
tlv.T35(c.version().PTOSVersion),
tlv.T66(c.version().PTOSVersion),
tlv.Td1(c.version().OS, c.Device().DeviceName),
tlv.T35(c.Version().PTOSVersion),
tlv.T66(c.Version().PTOSVersion),
tlv.Td1(c.Version().OS, c.Device().DeviceName),
).WriteU8(3).ToBytes()

packet := c.buildCode2dPacket(c.Uin, 0x31, body)
@@ -168,7 +168,7 @@ func (c *QQClient) PasswordLogin() (*LoginResponse, error) {
return nil, err
}

data, err := buildPasswordLoginRequest(c.Uin, c.version(), c.Device(), &c.transport.Sig, c.PasswordMD5)
data, err := buildPasswordLoginRequest(c.Uin, c.Version(), c.Device(), &c.transport.Sig, c.PasswordMD5)
if err != nil {
return nil, err
}
@@ -191,7 +191,7 @@ func (c *QQClient) PasswordLogin() (*LoginResponse, error) {

func (c *QQClient) SubmitCaptcha(ticket, randStr, aid string) (*LoginResponse, error) {
c.Sig().CaptchaInfo = [3]string{ticket, randStr, aid}
data, err := buildPasswordLoginRequest(c.Uin, c.version(), c.Device(), &c.transport.Sig, c.PasswordMD5)
data, err := buildPasswordLoginRequest(c.Uin, c.Version(), c.Device(), &c.transport.Sig, c.PasswordMD5)
if err != nil {
return nil, err
}
@@ -230,7 +230,7 @@ func (c *QQClient) GetNewDeviceVerifyURL() (string, error) {
Uint32Flag: 1,
Uint32UrlType: 0,
StrUinToken: queryParams.Get("uin-token"),
StrDevType: c.version().OS,
StrDevType: c.Version().OS,
StrDevName: c.Device().DeviceName,
})

@@ -297,7 +297,7 @@ func (c *QQClient) NewDeviceVerify(verifyURL string) error {
}
if resp.StrNtSuccToken != "" {
c.transport.Sig.TempPwd = utils.S2B(resp.StrNtSuccToken)
data, err := buildNtloginRequest(c.Uin, c.version(), c.Device(), &c.transport.Sig, c.transport.Sig.TempPwd)
data, err := buildNtloginRequest(c.Uin, c.Version(), c.Device(), &c.transport.Sig, c.transport.Sig.TempPwd)
if err != nil {
return err
}
@@ -324,7 +324,7 @@ func (c *QQClient) NewDeviceVerify(verifyURL string) error {
}

func (c *QQClient) QRCodeLogin() (*LoginResponse, error) {
app := c.version()
app := c.Version()
device := c.Device()
response, err := c.sendUniPacketAndWait(
"wtlogin.login",
@@ -389,7 +389,7 @@ func (c *QQClient) init() error {
func (c *QQClient) register() error {
response, err := c.sendUniPacketAndWait(
"trpc.qq_new_tech.status_svc.StatusService.Register",
wtlogin.BuildRegisterRequest(c.version(), c.Device()))
wtlogin.BuildRegisterRequest(c.Version(), c.Device()))

if err != nil {
c.errorln(err)
9 changes: 5 additions & 4 deletions client/oicq.go
Original file line number Diff line number Diff line change
@@ -3,14 +3,15 @@ package client
import (
"fmt"

"github.com/RomiChan/protobuf/proto"
tea "github.com/fumiama/gofastTEA"

"github.com/LagrangeDev/LagrangeGo/client/auth"
"github.com/LagrangeDev/LagrangeGo/client/internal/oicq"
"github.com/LagrangeDev/LagrangeGo/client/packets/pb"
"github.com/LagrangeDev/LagrangeGo/utils"
"github.com/LagrangeDev/LagrangeGo/utils/binary"
"github.com/LagrangeDev/LagrangeGo/utils/crypto"
"github.com/RomiChan/protobuf/proto"
tea "github.com/fumiama/gofastTEA"
)

// ref https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/entities.go#L18
@@ -57,7 +58,7 @@ func (c *QQClient) buildCode2dPacket(uin uint32, cmdID int, body []byte) []byte
binary.NewBuilder(nil).
WriteU8(0).
WriteU16(uint16(len(body))+53).
WriteU32(uint32(c.version().AppID)).
WriteU32(uint32(c.Version().AppID)).
WriteU32(0x72).
WriteBytes(make([]byte, 3)).
WriteU32(uint32(utils.TimeStamp())).
@@ -68,7 +69,7 @@ func (c *QQClient) buildCode2dPacket(uin uint32, cmdID int, body []byte) []byte
WriteU8(3).
WriteU32(50).
WriteBytes(make([]byte, 14)).
WriteU32(uint32(c.version().AppID)).
WriteU32(uint32(c.Version().AppID)).
WriteBytes(body).
ToBytes(),
)
2 changes: 1 addition & 1 deletion client/operation.go
Original file line number Diff line number Diff line change
@@ -1383,7 +1383,7 @@ func (c *QQClient) ImageOcr(url string) (*oidb2.OcrResponse, error) {

// SendGroupSign 发送群聊打卡消息
func (c *QQClient) SendGroupSign(groupUin uint32) (*oidb2.BotGroupClockInResult, error) {
pkt, err := oidb2.BuildGroupSignPacket(c.Uin, groupUin, c.version().CurrentVersion)
pkt, err := oidb2.BuildGroupSignPacket(c.Uin, groupUin, c.Version().CurrentVersion)
if err != nil {
return nil, err
}

0 comments on commit 237c559

Please sign in to comment.