2019-07-16 15:31:33 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/bdlm/log"
|
|
|
|
|
|
|
|
"gosrc.io/xmpp"
|
|
|
|
"gosrc.io/xmpp/stanza"
|
|
|
|
)
|
|
|
|
|
2020-01-09 06:33:11 -08:00
|
|
|
func joinMUC(c xmpp.Sender, toJID *stanza.Jid) error {
|
2019-07-27 18:06:55 -07:00
|
|
|
return c.Send(stanza.Presence{Attrs: stanza.Attrs{To: toJID.Full()},
|
2019-07-16 15:31:33 -07:00
|
|
|
Extensions: []stanza.PresExtension{
|
|
|
|
stanza.MucPresence{
|
|
|
|
History: stanza.History{MaxStanzas: stanza.NewNullableInt(0)},
|
|
|
|
}},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-01-09 06:33:11 -08:00
|
|
|
func leaveMUCs(c xmpp.Sender, mucsToLeave []*stanza.Jid) {
|
2019-07-16 15:31:33 -07:00
|
|
|
for _, muc := range mucsToLeave {
|
|
|
|
if err := c.Send(stanza.Presence{Attrs: stanza.Attrs{
|
2019-07-27 18:06:55 -07:00
|
|
|
To: muc.Full(),
|
2019-07-16 15:31:33 -07:00
|
|
|
Type: stanza.PresenceTypeUnavailable,
|
|
|
|
}}); err != nil {
|
|
|
|
log.WithField("muc", muc).Errorf("error on leaving muc: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|