Skip to content

Commit f19a251

Browse files
committed
update relogin
1 parent 07c366f commit f19a251

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,3 @@ lz1998/gmc:0.1.11
128128

129129
此时就能看到一个标准的 `JSON`, 复制 `ticket` 字段并回到 验证码处理 粘贴. 即可通过滑块验证.
130130

131-
#### 方案B
132-
133-
下载专用软件进行验证
134-
135-
TODO

service/bot/bot.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ func Login(cli *client.QQClient) (bool, error) {
108108

109109
func SetRelogin(cli *client.QQClient, retryInterval int, retryCount int) {
110110
cli.OnDisconnected(func(bot *client.QQClient, e *client.ClientDisconnectedEvent) {
111+
time.Sleep(5 * time.Second)
112+
113+
// 尝试token登录
114+
if err := cli.TokenLogin(LoginToken); err != nil {
115+
log.Errorf("failed to relogin with token, try to login with password, %+v", err)
116+
} else {
117+
LoginToken = cli.GenToken()
118+
log.Info("succeed to relogin with token")
119+
return
120+
}
121+
111122
var times = 1
112123
for {
113124
if cli.Online {
@@ -122,22 +133,12 @@ func SetRelogin(cli *client.QQClient, retryInterval int, retryCount int) {
122133
times++
123134
time.Sleep(time.Second * time.Duration(retryInterval))
124135

125-
// 尝试token登录
126-
if err := cli.TokenLogin(LoginToken); err != nil {
127-
log.Errorf("failed to relogin with token, try to login with password, %+v", err)
128-
} else {
129-
LoginToken = cli.GenToken()
130-
log.Info("succeed to relogin with token")
131-
return
132-
}
133-
134-
time.Sleep(time.Second)
135-
136136
// 尝试密码登录
137137
ok, err := Login(cli)
138138

139139
if err != nil {
140140
log.Errorf("重连失败: %v", err)
141+
cli.Disconnect()
141142
continue
142143
}
143144
if ok {

0 commit comments

Comments
 (0)