Skip to content

Commit

Permalink
减少页面崩溃几率
Browse files Browse the repository at this point in the history
  • Loading branch information
yxw21 committed Dec 25, 2022
1 parent 5732c57 commit 9eaf819
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
5 changes: 0 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ func init() {
TokenFile: "qq.token",
DeviceFile: "device.json",
}
if Instance.AIUsername != "" && Instance.AIPassword != "" && Instance.Key != "" {
Session = chatgpt.NewSessionWithCredential(Instance.AIUsername, Instance.AIPassword, Instance.Key).AutoRefresh()
} else {
Session = chatgpt.NewSessionWithAccessToken(Instance.AccessToken).AutoRefresh()
}
qq, err := strconv.ParseInt(os.Getenv("QQ_UIN"), 10, 64)
if err == nil {
Instance.QQ = qq
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f
github.com/Mrs4s/MiraiGo v0.0.0-20221206193101-cf66e2864798
github.com/tuotoo/qrcode v0.0.0-20220425170535-52ccc2bebf5d
github.com/yxw21/chatgpt v0.7.0
github.com/yxw21/chatgpt v0.8.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I=
github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
github.com/yxw21/chatgpt v0.7.0 h1:7NVjO6+pyXof340nrFR1eXd8KcbDP/PRBXuzieKxMEA=
github.com/yxw21/chatgpt v0.7.0/go.mod h1:40HZqYFtcZoUNXsG0LKCgzea+KHdW1XJ7MnVvhFm8z4=
github.com/yxw21/chatgpt v0.8.0 h1:rCfYKcdR3vvaYUN12xpbuAJKHWfLEtw/ksnivEswZ2c=
github.com/yxw21/chatgpt v0.8.0/go.mod h1:40HZqYFtcZoUNXsG0LKCgzea+KHdW1XJ7MnVvhFm8z4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db h1:D/cFflL63o2KSLJIwjlcIt8PR064j/xsmdEJL/YvY/o=
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
Expand Down
7 changes: 6 additions & 1 deletion qqchatgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ func main() {
qq *client.QQClient
err error
)
browser, closeBrowser, err := chatgpt.NewBrowser("")
browser, closeBrowser, err := chatgpt.NewBrowser(config.Instance.Key)
if err != nil {
log.Fatal(err)
}
defer closeBrowser()
config.Browser = browser
if config.Instance.AIUsername != "" && config.Instance.AIPassword != "" {
config.Session = chatgpt.NewSessionWithCredential(browser, config.Instance.AIUsername, config.Instance.AIPassword).AutoRefresh()
} else {
config.Session = chatgpt.NewSessionWithAccessToken(browser, config.Instance.AccessToken).AutoRefresh()
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if err = helpers.AutoLoadDevice(); err != nil {
Expand Down

0 comments on commit 9eaf819

Please sign in to comment.