diff --git a/client/auth/sig.go b/client/auth/sig.go index d9b7af9..a8e8f89 100644 --- a/client/auth/sig.go +++ b/client/auth/sig.go @@ -31,7 +31,6 @@ type SigInfo struct { TempPwd []byte CaptchaInfo [3]string - CaptchaURL string NewDeviceVerifyURL string Nickname string diff --git a/client/client.go b/client/client.go index cb30f36..22b39f1 100644 --- a/client/client.go +++ b/client/client.go @@ -189,7 +189,7 @@ func (c *QQClient) PasswordLogin() (*LoginResponse, error) { return &res, err } -func (c *QQClient) CommitCaptcha(ticket, randStr, aid string) (*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) if err != nil { diff --git a/client/ntlogin.go b/client/ntlogin.go index 0d65387..899954d 100644 --- a/client/ntlogin.go +++ b/client/ntlogin.go @@ -150,12 +150,6 @@ func parseNtloginResponse(response []byte, sig *auth.SigInfo) (LoginResponse, er return nil }() sig.Cookies = base.Header.Cookie.Cookie.Unwrap() - sig.CaptchaURL = func() string { - if body.Captcha != nil { - return body.Captcha.Url - } - return "" - }() sig.NewDeviceVerifyURL = base.Header.Error.NewDeviceVerifyUrl.Unwrap() err = nil } @@ -166,12 +160,15 @@ func parseNtloginResponse(response []byte, sig *auth.SigInfo) (LoginResponse, er err = fmt.Errorf("login fail on ntlogin(%s): [%s]>%s", ret.Name(), title, content) } var loginErr LoginError + var verifyURL string //nolint:exhaustive switch ret { case loginstate.CaptchaVerify: - loginErr = NeedCaptcha + loginErr = SliderNeededError + verifyURL = body.Captcha.Url case loginstate.NewDeviceVerify: loginErr = UnsafeDeviceError + verifyURL = base.Header.Error.NewDeviceVerifyUrl.Unwrap() default: loginErr = OtherLoginError } @@ -179,6 +176,7 @@ func parseNtloginResponse(response []byte, sig *auth.SigInfo) (LoginResponse, er Success: false, Error: loginErr, ErrorMessage: ret.Name(), + VerifyURL: verifyURL, }, err } diff --git a/main.go b/main.go index e676190..40160cf 100644 --- a/main.go +++ b/main.go @@ -89,15 +89,15 @@ func main() { return nil } switch ret.Error { - case client.NeedCaptcha: + case client.SliderNeededError: logger.Warnln("captcha verification required") - logger.Warnln(c.Sig().CaptchaURL) - aid := strings.Split(strings.Split(c.Sig().CaptchaURL, "&sid=")[1], "&")[0] + logger.Warnln(ret.VerifyURL) + aid := strings.Split(strings.Split(ret.VerifyURL, "sid=")[1], "&")[0] logger.Warnln("ticket?->") ticket := utils.ReadLine() logger.Warnln("rand_str?->") randStr := utils.ReadLine() - ret, err = c.CommitCaptcha(ticket, randStr, aid) + ret, err = c.SubmitCaptcha(ticket, randStr, aid) continue case client.UnsafeDeviceError: vf, err := c.GetNewDeviceVerifyURL()