Skip to content

Commit

Permalink
update relogin
Browse files Browse the repository at this point in the history
  • Loading branch information
lz1998 committed Apr 22, 2021
1 parent 07c366f commit f19a251
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,3 @@ lz1998/gmc:0.1.11

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

#### 方案B

下载专用软件进行验证

TODO
23 changes: 12 additions & 11 deletions service/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ func Login(cli *client.QQClient) (bool, error) {

func SetRelogin(cli *client.QQClient, retryInterval int, retryCount int) {
cli.OnDisconnected(func(bot *client.QQClient, e *client.ClientDisconnectedEvent) {
time.Sleep(5 * time.Second)

// 尝试token登录
if err := cli.TokenLogin(LoginToken); err != nil {
log.Errorf("failed to relogin with token, try to login with password, %+v", err)
} else {
LoginToken = cli.GenToken()
log.Info("succeed to relogin with token")
return
}

var times = 1
for {
if cli.Online {
Expand All @@ -122,22 +133,12 @@ func SetRelogin(cli *client.QQClient, retryInterval int, retryCount int) {
times++
time.Sleep(time.Second * time.Duration(retryInterval))

// 尝试token登录
if err := cli.TokenLogin(LoginToken); err != nil {
log.Errorf("failed to relogin with token, try to login with password, %+v", err)
} else {
LoginToken = cli.GenToken()
log.Info("succeed to relogin with token")
return
}

time.Sleep(time.Second)

// 尝试密码登录
ok, err := Login(cli)

if err != nil {
log.Errorf("重连失败: %v", err)
cli.Disconnect()
continue
}
if ok {
Expand Down

0 comments on commit f19a251

Please sign in to comment.