diff --git a/telegram/connect.go b/telegram/connect.go index d37c5fd..b332352 100644 --- a/telegram/connect.go +++ b/telegram/connect.go @@ -234,6 +234,21 @@ func (c *Client) Disconnect(resource string, quit bool) bool { c.sendPresence(args...) } + if c.Session.MUC { + c.locks.mucCacheLock.Lock() + for chatID := range c.mucCache { + c.sendPresence( + gateway.SPFrom(gateway.MUCNODE(chatID)), + gateway.SPResource(c.GetMUCNickname(0)), + gateway.SPType("unavailable"), + gateway.SPMUCAffiliation("none"), + gateway.SPMUCRole("none"), + gateway.SPMUCStatusCodes([]uint16{110, 332}), + ) + } + c.locks.mucCacheLock.Unlock() + } + c.close() return true