1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

Merge pull request #227 from LXY1226/qr-param

feat: 现可使用不同的二维码生成参数获取二维码
This commit is contained in:
Mrs4s 2021-12-24 14:38:15 +08:00 committed by GitHub
commit dd17e12e1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -124,7 +124,7 @@ func (c *QQClient) buildDeviceLockLoginPacket() (uint16, []byte) {
return seq, c.transport.PackPacket(&req2) return seq, c.transport.PackPacket(&req2)
} }
func (c *QQClient) buildQRCodeFetchRequestPacket() (uint16, []byte) { func (c *QQClient) buildQRCodeFetchRequestPacket(size, margin, ecLevel uint32) (uint16, []byte) {
watch := auth.AndroidWatch.Version() watch := auth.AndroidWatch.Version()
seq := c.nextSeq() seq := c.nextSeq()
req := c.buildOicqRequestPacket(0, 0x0812, binary.NewWriterF(func(w *binary.Writer) { req := c.buildOicqRequestPacket(0, 0x0812, binary.NewWriterF(func(w *binary.Writer) {
@ -139,7 +139,7 @@ func (c *QQClient) buildQRCodeFetchRequestPacket() (uint16, []byte) {
w.WriteUInt16(6) w.WriteUInt16(6)
w.Write(tlv.T16(watch.SSOVersion, 16, watch.AppId, c.deviceInfo.Guid, []byte(watch.ApkId), []byte(watch.SortVersionName), watch.ApkSign)) w.Write(tlv.T16(watch.SSOVersion, 16, watch.AppId, c.deviceInfo.Guid, []byte(watch.ApkId), []byte(watch.SortVersionName), watch.ApkSign))
w.Write(tlv.T1B(0, 0, 3, 4, 72, 2, 2)) w.Write(tlv.T1B(0, 0, size, margin, 72, ecLevel, 2))
w.Write(tlv.T1D(watch.MiscBitmap)) w.Write(tlv.T1D(watch.MiscBitmap))
w.Write(tlv.T1F(false, c.deviceInfo.OSType, []byte("7.1.2"), []byte("China Mobile GSM"), c.deviceInfo.APN, 2)) w.Write(tlv.T1F(false, c.deviceInfo.OSType, []byte("7.1.2"), []byte("China Mobile GSM"), c.deviceInfo.APN, 2))
w.Write(tlv.T33(c.deviceInfo.Guid)) w.Write(tlv.T33(c.deviceInfo.Guid))

View File

@ -310,6 +310,10 @@ func (c *QQClient) TokenLogin(token []byte) error {
} }
func (c *QQClient) FetchQRCode() (*QRCodeLoginResponse, error) { func (c *QQClient) FetchQRCode() (*QRCodeLoginResponse, error) {
return c.FetchQRCodeCustomSize(3, 4, 2)
}
func (c *QQClient) FetchQRCodeCustomSize(size, margin, ecLevel uint32) (*QRCodeLoginResponse, error) {
if c.Online.Load() { if c.Online.Load() {
return nil, ErrAlreadyOnline return nil, ErrAlreadyOnline
} }
@ -317,7 +321,7 @@ func (c *QQClient) FetchQRCode() (*QRCodeLoginResponse, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
i, err := c.sendAndWait(c.buildQRCodeFetchRequestPacket()) i, err := c.sendAndWait(c.buildQRCodeFetchRequestPacket(size, margin, ecLevel))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "fetch qrcode error") return nil, errors.Wrap(err, "fetch qrcode error")
} }