Skip to content

Commit 8252d04

Browse files
committed
disconnect before new
1 parent 0a47630 commit 8252d04

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

service/handler/bot.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ func FetchQrCode(c *gin.Context) {
132132
log.Infof("开始初始化设备信息")
133133
bot.InitDevice(0)
134134
log.Infof("设备信息 %+v", string(client.SystemDeviceInfo.ToJson()))
135+
if bot.Cli != nil {
136+
bot.Cli.Disconnect()
137+
time.Sleep(time.Second)
138+
}
135139
bot.Cli = client.NewClientEmpty()
136140
log.Infof("初始化日志")
137141
bot.InitLog(bot.Cli)
@@ -213,6 +217,10 @@ func CreateBotImpl(uin int64, password string) {
213217
log.Infof("设备信息 %+v", string(client.SystemDeviceInfo.ToJson()))
214218

215219
log.Infof("创建机器人 %+v", uin)
220+
if bot.Cli != nil {
221+
bot.Cli.Disconnect()
222+
time.Sleep(time.Second)
223+
}
216224
bot.Cli = client.NewClient(uin, password)
217225

218226
log.Infof("初始化日志")

0 commit comments

Comments
 (0)