mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-12 06:45:46 +08:00
update MiraiGo.
This commit is contained in:
parent
e8513da090
commit
a979c46563
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20201005155759-f9b3c399e5e0
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20201008075030-5a7da6298521
|
||||
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect
|
||||
github.com/gin-gonic/gin v1.6.3
|
||||
github.com/go-playground/validator/v10 v10.4.0 // indirect
|
||||
|
6
go.sum
6
go.sum
@ -1,5 +1,11 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20201005155759-f9b3c399e5e0 h1:sduD7+a96T7ANQSjvqvmjSREq1eXhm4RQVuHeoV/QQo=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20201005155759-f9b3c399e5e0/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20201008071514-e1f2ae7f80ed h1:JcK6nr0t9S8uO5IQWJ6+xkG5cT0orhULK2+k25kt+uE=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20201008071514-e1f2ae7f80ed/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20201008075030-5a7da6298521 h1:4wJgQDor9dwZLnxFkv9/ohjPk4wOA17sbjwBm520t0k=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20201008075030-5a7da6298521/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
|
||||
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
||||
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
|
@ -98,12 +98,24 @@ func (s *webServer) Dologin() {
|
||||
s.Console = bufio.NewReader(os.Stdin)
|
||||
conf := GetConf()
|
||||
cli := s.Cli
|
||||
cli.AllowSlider = true
|
||||
rsp, err := cli.Login()
|
||||
for {
|
||||
global.Check(err)
|
||||
var text string
|
||||
if !rsp.Success {
|
||||
switch rsp.Error {
|
||||
case client.SliderNeededError:
|
||||
if client.SystemDeviceInfo.Protocol == client.AndroidPhone {
|
||||
log.Warnf("警告: Android Phone 强制要求暂不支持得滑条验证码, 请开启设备锁或切换到Android Pad协议验证通过后再使用Phone协议.")
|
||||
log.Infof("按 Enter 继续....")
|
||||
_, _ = s.Console.ReadString('\n')
|
||||
os.Exit(0)
|
||||
}
|
||||
cli.AllowSlider = false
|
||||
cli.Disconnect()
|
||||
rsp, err = cli.Login()
|
||||
continue
|
||||
case client.NeedCaptcha:
|
||||
_ = ioutil.WriteFile("captcha.jpg", rsp.CaptchaImage, 0644)
|
||||
img, _, _ := image.Decode(bytes.NewReader(rsp.CaptchaImage))
|
||||
@ -118,6 +130,40 @@ func (s *webServer) Dologin() {
|
||||
rsp, err = cli.SubmitCaptcha(strings.ReplaceAll(text, "\n", ""), rsp.CaptchaSign)
|
||||
global.DelFile("captcha.jpg")
|
||||
continue
|
||||
case client.SNSNeededError:
|
||||
log.Warnf("账号已开启设备锁, 按下 Enter 向手机 %v 发送短信验证码.", rsp.SMSPhone)
|
||||
_, _ = s.Console.ReadString('\n')
|
||||
if !cli.RequestSNS() {
|
||||
log.Warnf("发送验证码失败,可能是请求过于频繁.")
|
||||
time.Sleep(time.Second * 5)
|
||||
os.Exit(0)
|
||||
}
|
||||
log.Warn("请输入短信验证码: (Enter 提交)")
|
||||
text, _ = s.Console.ReadString('\n')
|
||||
rsp, err = cli.SubmitSNS(strings.ReplaceAll(strings.ReplaceAll(text, "\n", ""), "\r", ""))
|
||||
continue
|
||||
case client.SNSOrVerifyNeededError:
|
||||
log.Warnf("账号已开启设备锁,请选择验证方式:")
|
||||
log.Warnf("1. 向手机 %v 发送短信验证码", rsp.SMSPhone)
|
||||
log.Warnf("2. 使用手机QQ扫码验证.")
|
||||
log.Warn("请输入(1 - 2): ")
|
||||
text, _ = s.Console.ReadString('\n')
|
||||
if strings.Contains(text, "1") {
|
||||
if !cli.RequestSNS() {
|
||||
log.Warnf("发送验证码失败,可能是请求过于频繁.")
|
||||
time.Sleep(time.Second * 5)
|
||||
os.Exit(0)
|
||||
}
|
||||
log.Warn("请输入短信验证码: (Enter 提交)")
|
||||
text, _ = s.Console.ReadString('\n')
|
||||
rsp, err = cli.SubmitSNS(strings.ReplaceAll(strings.ReplaceAll(text, "\n", ""), "\r", ""))
|
||||
continue
|
||||
}
|
||||
log.Warnf("请前往 -> %v <- 验证并重启Bot.", rsp.VerifyUrl)
|
||||
log.Infof(" 按 Enter 继续....")
|
||||
_, _ = s.Console.ReadString('\n')
|
||||
os.Exit(0)
|
||||
return
|
||||
case client.UnsafeDeviceError:
|
||||
log.Warnf("账号已开启设备锁,请前往 -> %v <- 验证并重启Bot.", rsp.VerifyUrl)
|
||||
if conf.WebUi.WebInput {
|
||||
@ -131,7 +177,10 @@ func (s *webServer) Dologin() {
|
||||
os.Exit(0)
|
||||
return
|
||||
case client.OtherLoginError, client.UnknownLoginError:
|
||||
log.Fatalf("登录失败: %v", rsp.ErrorMessage)
|
||||
log.Warnf("登录失败: %v", rsp.ErrorMessage)
|
||||
log.Infof(" 按 Enter 继续....")
|
||||
_, _ = s.Console.ReadString('\n')
|
||||
os.Exit(0)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user