Skip to content

Commit

Permalink
Merge pull request #31 from houko/feature/fix_wechat_file
Browse files Browse the repository at this point in the history
fix wechat restart error
  • Loading branch information
houko authored Jan 14, 2023
2 parents f92e4e3 + 78d4967 commit 334809d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bootstrap/wechat.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/eatmoreapple/openwechat"
log "github.com/sirupsen/logrus"
"github.com/wechatgpt/wechatbot/handler/wechat"
"os"
)

func StartWebChat() {
Expand All @@ -14,8 +15,13 @@ func StartWebChat() {
reloadStorage := openwechat.NewJsonFileHotReloadStorage("token.json")
err := bot.HotLogin(reloadStorage)
if err != nil {
if err = bot.Login(); err != nil {
log.Fatal(err)
err := os.Remove("token.json")
if err != nil {
return
}
reloadStorage = openwechat.NewJsonFileHotReloadStorage("token.json")
err = bot.HotLogin(reloadStorage)
if err != nil {
return
}
}
Expand Down

0 comments on commit 334809d

Please sign in to comment.