Skip to content

Commit

Permalink
Merge pull request #133 from eatmoreapple/handle-xml-syntax-error
Browse files Browse the repository at this point in the history
  • Loading branch information
eatmoreapple authored Nov 27, 2022
2 parents fe2f73b + 7b4a856 commit b182426
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,13 @@ func (b *Bot) LoginWithUUID(uuid string) error {
switch resp.Code {
case StatusSuccess:
// 判断是否有登录回调,如果有执行它
if err = b.HandleLogin(resp.Raw); err != nil {
return err
}
if b.LoginCallBack != nil {
b.LoginCallBack(resp.Raw)
}
return b.HandleLogin(resp.Raw)
return nil
case StatusScanned:
// 执行扫码回调
if b.ScanCallBack != nil {
Expand Down
6 changes: 6 additions & 0 deletions caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"os"
)
Expand Down Expand Up @@ -86,6 +88,10 @@ func (c *Caller) GetLoginInfo(body []byte) (*LoginInfo, error) {
if err != nil {
return nil, err
}
// 判断是否重定向
if resp.StatusCode != http.StatusMovedPermanently {
return nil, fmt.Errorf("%w: try to login with Desktop Mode", ErrForbidden)
}
defer func() { _ = resp.Body.Close() }()

var loginInfo LoginInfo
Expand Down
3 changes: 3 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ func IgnoreNetworkError(errHandler func(err error)) func(error) {
}
}
}

// ErrForbidden 禁止当前账号登录
var ErrForbidden = errors.New("login forbidden")

0 comments on commit b182426

Please sign in to comment.