Handle VKCalls captcha gates explicitly

This commit is contained in:
XXcipherX committed 2026-06-30 12:46:50 +03:00
1 parent ad939bda82
commit c762a85615
2 files changed
+48 -8

No files matched your search

+28
View File
@@ -604,16 +604,43 @@ type VkCaptchaError struct {
ErrorCode int
ErrorMsg string
CaptchaSid string
CaptchaImg string
RedirectURI string
SessionToken string
CaptchaTs string
CaptchaAttempt string
}
func (e *VkCaptchaError) Error() string {
if e == nil {
return "VK captcha required"
}
if e.ErrorCode != 0 && e.ErrorCode != 14 {
if e.ErrorMsg != "" {
return fmt.Sprintf("VK API error %d: %s", e.ErrorCode, e.ErrorMsg)
}
return fmt.Sprintf("VK API error %d", e.ErrorCode)
}
if e.RedirectURI != "" {
return fmt.Sprintf("VK captcha required: redirect_uri, sid=%q", e.CaptchaSid)
}
if e.CaptchaImg != "" {
return fmt.Sprintf("VK captcha required: captcha_img, sid=%q", e.CaptchaSid)
}
if e.CaptchaSid != "" {
return fmt.Sprintf("VK captcha required: sid=%q", e.CaptchaSid)
}
if e.ErrorMsg != "" {
return fmt.Sprintf("VK captcha required: %s", e.ErrorMsg)
}
return "VK captcha required"
}
func parseVkCaptchaError(errData map[string]interface{}) *VkCaptchaError {
codeFloat, _ := errData["error_code"].(float64)
redirectUri, _ := errData["redirect_uri"].(string)
errorMsg, _ := errData["error_msg"].(string)
captchaImg, _ := errData["captcha_img"].(string)
captchaSid, _ := errData["captcha_sid"].(string)
if captchaSid == "" {
@@ -647,6 +674,7 @@ func parseVkCaptchaError(errData map[string]interface{}) *VkCaptchaError {
ErrorCode: int(codeFloat),
ErrorMsg: errorMsg,
CaptchaSid: captchaSid,
CaptchaImg: captchaImg,
RedirectURI: redirectUri,
SessionToken: sessionToken,
CaptchaTs: captchaTs,