Merge pull request #133 from eatmoreapple/handle-xml-syntax-error

This commit is contained in:
多吃点苹果 2022-11-27 23:17:04 +08:00 committed by GitHub
commit b18242699a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

5
bot.go
View File

@ -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 {

View File

@ -4,7 +4,9 @@ import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"os"
)
@ -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

View File

@ -18,3 +18,6 @@ func IgnoreNetworkError(errHandler func(err error)) func(error) {
}
}
}
// ErrForbidden 禁止当前账号登录
var ErrForbidden = errors.New("login forbidden")