xmpp_muc.go
func (c *Client) JoinProtectedMUC(jid, nick string, password string, history_type, history int, history_date *time.Time) (n int, err error) {
	if nick == "" {
		nick = c.jid
	}
	switch history_type {
	case NoHistory:
		return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
			"<x xmlns='%s'>\n"+
			"<password>%s</password>"+
			"</x>\n"+
			"</presence>",
			xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password))
	case CharHistory:
		return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
			"<x xmlns='%s'>\n"+
			"<password>%s</password>\n"+
			"<history maxchars='%d'/></x>\n"+
			"</presence>",
			xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history)
	case StanzaHistory:
		return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
			"<x xmlns='%s'>\n"+
			"<password>%s</password>\n"+
			"<history maxstanzas='%d'/></x>\n"+
			"</presence>",
			xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history)
	case SecondsHistory:
		return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
			"<x xmlns='%s'>\n"+
			"<password>%s</password>\n"+
			"<history seconds='%d'/></x>\n"+
			"</presence>",
			xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history)
	case SinceHistory:
		if history_date != nil {
			return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
				"<x xmlns='%s'>\n"+
				"<password>%s</password>\n"+
				"<history since='%s'/></x>\n"+
				"</presence>",
				xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history_date.Format(time.RFC3339))
		}
	}
	return 0, errors.New("Unknown history option")
}
func (c *Client) JoinProtectedMUC(jid, nick string, password string, history_type, history int, history_date *time.Time) (n int, err error) {
	if nick == "" {
		nick = c.jid
	}
	switch history_type {
	case NoHistory:
		return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
			"<x xmlns='%s'>\n"+
			"<password>%s</password>"+
			"</x>\n"+
			"</presence>",
			xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password))
	case CharHistory:
		return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
			"<x xmlns='%s'>\n"+
			"<password>%s</password>\n"+
			"<history maxchars='%d'/></x>\n"+
			"</presence>",
			xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history)
	case StanzaHistory:
		return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
			"<x xmlns='%s'>\n"+
			"<password>%s</password>\n"+
			"<history maxstanzas='%d'/></x>\n"+
			"</presence>",
			xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history)
	case SecondsHistory:
		return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
			"<x xmlns='%s'>\n"+
			"<password>%s</password>\n"+
			"<history seconds='%d'/></x>\n"+
			"</presence>",
			xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history)
	case SinceHistory:
		if history_date != nil {
			return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
				"<x xmlns='%s'>\n"+
				"<password>%s</password>\n"+
				"<history since='%s'/></x>\n"+
				"</presence>",
				xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history_date.Format(time.RFC3339))
		}
	}
	return 0, errors.New("Unknown history option")
}
// xep-0045 7.2.6