forked from MirrorHub/mautrix-whatsapp
Handle connection failures like disconnections
This commit is contained in:
parent
f39fd0ac46
commit
ae92d71d5a
1 changed files with 8 additions and 1 deletions
9
user.go
9
user.go
|
@ -234,12 +234,19 @@ func (user *User) HandleError(err error) {
|
|||
closed, ok := err.(*whatsapp.ErrConnectionClosed)
|
||||
if ok {
|
||||
if closed.Code != 1000 {
|
||||
msg := fmt.Sprintf("\u26a0 Your WhatsApp connection failed with websocket status code %d.\n\n"+
|
||||
msg := fmt.Sprintf("\u26a0 Your WhatsApp connection was closed with websocket status code %d.\n\n"+
|
||||
"Use the `reconnect` command to reconnect.", closed.Code)
|
||||
_, _ = user.bridge.Bot.SendMessageEvent(user.ManagementRoom, mautrix.EventMessage, format.RenderMarkdown(msg))
|
||||
}
|
||||
user.Connected = false
|
||||
}
|
||||
failed, ok := err.(*whatsapp.ErrConnectionFailed)
|
||||
if ok {
|
||||
msg := fmt.Sprintf("\u26a0 Your WhatsApp connection failed: %v.\n\n"+
|
||||
"Use the `reconnect` command to reconnect.", failed.Err)
|
||||
_, _ = user.bridge.Bot.SendMessageEvent(user.ManagementRoom, mautrix.EventMessage, format.RenderMarkdown(msg))
|
||||
user.Connected = false
|
||||
}
|
||||
}
|
||||
|
||||
func (user *User) HandleJSONParseError(err error) {
|
||||
|
|
Loading…
Reference in a new issue