Merge pull request #44 from tanuva/master

Add ability to join password protected chat rooms
This commit is contained in:
mattn 2014-12-04 10:26:39 +09:00
commit 98a0431d5b

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' />",