diff --git a/xmpp.go b/xmpp.go index dd7d81c..372aaf6 100644 --- a/xmpp.go +++ b/xmpp.go @@ -597,6 +597,8 @@ type Chat struct { Text string Subject string Thread string + Ooburl string + Oobdesc string Roster Roster Other []string OtherElem []XMLElement @@ -684,21 +686,44 @@ func (c *Client) Recv() (stanza interface{}, err error) { // Send sends the message wrapped inside an XMPP message stanza body. func (c *Client) Send(chat Chat) (n int, err error) { - var subtext = `` - var thdtext = `` + var subtext, thdtext, oobtext string if chat.Subject != `` { subtext = `` + xmlEscape(chat.Subject) + `` } if chat.Thread != `` { thdtext = `` + xmlEscape(chat.Thread) + `` } + if chat.Ooburl != `` { + oobtext = `` + xmlEscape(chat.Ooburl) + `` + if chat.Oobdesc != `` { + oobtext += `` + xmlEscape(chat.Oobdesc) + `` + } + oobtext += `` + } - stanza := "" + subtext + "%s" + thdtext + "" + stanza := "" + subtext + "%s" + oobtext + thdtext + "" return fmt.Fprintf(c.conn, stanza, xmlEscape(chat.Remote), xmlEscape(chat.Type), cnonce(), xmlEscape(chat.Text)) } +// SendOOB sends OOB data wrapped inside an XMPP message stanza, without actual body. +func (c *Client) SendOOB(chat Chat) (n int, err error) { + var thdtext, oobtext string + if chat.Thread != `` { + thdtext = `` + xmlEscape(chat.Thread) + `` + } + if chat.Ooburl != `` { + oobtext = `` + xmlEscape(chat.Ooburl) + `` + if chat.Oobdesc != `` { + oobtext += `` + xmlEscape(chat.Oobdesc) + `` + } + oobtext += `` + } + return fmt.Fprintf(c.conn, ""+oobtext+thdtext+"", + xmlEscape(chat.Remote), xmlEscape(chat.Type), cnonce()) +} + // SendOrg sends the original text without being wrapped in an XMPP message stanza. func (c *Client) SendOrg(org string) (n int, err error) { return fmt.Fprint(c.conn, org)