mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
fix panic.
This commit is contained in:
parent
b0e00fe052
commit
30c4d508bc
26
main.go
26
main.go
@ -225,12 +225,24 @@ func main() {
|
||||
log.Debug("Protocol -> " + e.Message)
|
||||
}
|
||||
})
|
||||
cli.OnServerUpdated(func(bot *client.QQClient, e *client.ServerUpdatedEvent) {
|
||||
log.Infof("收到服务器地址更新通知, 将在下一次重连时应用. 服务器地址: %v:%v 服务器位置: %v", e.Servers[0].Server, e.Servers[0].Port, e.Servers[0].Location)
|
||||
_ = ioutil.WriteFile("servers.bin", binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(uint16(len(e.Servers)))
|
||||
for _, s := range e.Servers {
|
||||
if !strings.Contains(s.Server, "com") {
|
||||
w.WriteString(s.Server)
|
||||
w.WriteUInt16(uint16(s.Port))
|
||||
}
|
||||
}
|
||||
}), 0644)
|
||||
})
|
||||
if global.PathExists("servers.bin") {
|
||||
if data, err := ioutil.ReadFile("servers.bin"); err == nil {
|
||||
r := binary.NewReader(data)
|
||||
r.ReadUInt16()
|
||||
cli.CustomServer = &net.TCPAddr{
|
||||
IP: r.ReadBytes(4),
|
||||
IP: net.ParseIP(r.ReadString()),
|
||||
Port: int(r.ReadUInt16()),
|
||||
}
|
||||
}
|
||||
@ -295,18 +307,6 @@ func main() {
|
||||
}
|
||||
log.Info("资源初始化完成, 开始处理信息.")
|
||||
log.Info("アトリは、高性能ですから!")
|
||||
cli.OnServerUpdated(func(bot *client.QQClient, e *client.ServerUpdatedEvent) {
|
||||
log.Infof("收到服务器地址更新通知, 将在下一次重连时应用. 服务器地址: %v:%v 服务器位置: %v", e.Servers[0].Server, e.Servers[0].Port, e.Servers[0].Location)
|
||||
_ = ioutil.WriteFile("servers.bin", binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(uint16(len(e.Servers)))
|
||||
for _, s := range e.Servers {
|
||||
if !strings.Contains(s.Server, "com") {
|
||||
w.Write(net.ParseIP(s.Server))
|
||||
w.WriteUInt16(uint16(s.Port))
|
||||
}
|
||||
}
|
||||
}), 0644)
|
||||
})
|
||||
cli.OnDisconnected(func(bot *client.QQClient, e *client.ClientDisconnectedEvent) {
|
||||
if conf.ReLogin.Enabled {
|
||||
var times uint = 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user