Add ability to join password protected chat rooms

This commit is contained in:
Marcel Brüggebors 2014-12-03 20:21:45 +01:00
parent 846b8175da
commit 7568e71728

View File

@ -27,6 +27,19 @@ func (c *Client) JoinMUC(jid, nick string) {
xmlEscape(jid), xmlEscape(nick), nsMUC) xmlEscape(jid), xmlEscape(nick), nsMUC)
} }
// xep-0045 7.2.6
func (c *Client) JoinProtectedMUC(jid, nick string, password string) {
if nick == "" {
nick = c.jid
}
fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
"<x xmlns='%s'>\n"+
"<password>%s</password>\n"+
"</x>\n"+
"</presence>",
xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password))
}
// xep-0045 7.14 // xep-0045 7.14
func (c *Client) LeaveMUC(jid string) { func (c *Client) LeaveMUC(jid string) {
fmt.Fprintf(c.conn, "<presence from='%s' to='%s' type='unavailable' />", fmt.Fprintf(c.conn, "<presence from='%s' to='%s' type='unavailable' />",