Submit XHTML via Jabber with xmpppy

I am trying to send XHTML (hyperlink) via Jabber (on Google Talk) using xmpppy, but cannot find a good working example ... I tried with this:

http://intertwingly.net/blog/2007/08/09/Sending-XHTML-over-Jabber

But it didn’t work out ... any ideas?

Thanks in advance!

M

+3
source share
1 answer

Here is what I use to create an XHTML post (thanks to Thomas Perl /Jabberbot.py)

    html_message = "<b>Test!</b>"

    plain_message = re.sub(r'<[^>]+>', '', html_message)
    message = xmpp.protocol.Message(body=plain_message)
    html = xmpp.Node('html', {'xmlns': 'http://jabber.org/protocol/xhtml-im'})
    html.addChild(node=xmpp.simplexml.XML2Node("<body xmlns='http://www.w3.org/1999/xhtml'>" + html_message.encode('utf-8') + "</body>")) 
    message.addChild(node=html)
+2
source

Source: https://habr.com/ru/post/1756013/


All Articles