Skip to content

Commit

Permalink
feat: support manually input ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Aug 12, 2022
1 parent 177ba9d commit 93074ef
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cmd/gocq/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func loginResponseProcessor(res *client.LoginResponse) error {
log.Warn("请输入(1 - 2) (将在10秒后自动选择1):")
text = readLineTimeout(time.Second*10, "1")
if strings.Contains(text, "1") {
ticket := sliderCaptchaProcessor(res.VerifyUrl)
ticket := getTicket(res.VerifyUrl)
if ticket == "" {
os.Exit(0)
}
Expand Down Expand Up @@ -218,9 +218,19 @@ func loginResponseProcessor(res *client.LoginResponse) error {
}
}

func sliderCaptchaProcessor(u string) string {
func getTicket(u string) (str string) {
id := utils.RandomString(8)
log.Warnf("请前往该地址验证 -> %v", strings.ReplaceAll(u, "https://ssl.captcha.qq.com/template/wireless_mqq_captcha.html?", fmt.Sprintf("https://captcha.go-cqhttp.org/captcha?id=%v&", id)))
log.Warnf("请前往该地址验证 -> %v <- 或输入手动抓取的 ticket:(Enter 提交)", strings.ReplaceAll(u, "https://ssl.captcha.qq.com/template/wireless_mqq_captcha.html?", fmt.Sprintf("https://captcha.go-cqhttp.org/captcha?id=%v&", id)))
r := make(chan string)
select {
case r <- readLine():
case r <- sliderCaptchaProcessor(id):
}
str = <-r
return
}

func sliderCaptchaProcessor(id string) string {
start := time.Now()
for time.Since(start).Minutes() < 2 {
time.Sleep(time.Second)
Expand Down

0 comments on commit 93074ef

Please sign in to comment.