How to send message using xmpppy to a jabber client?
I've to send xmpp based chat client (hipchat) and I'm using xmpp.py for this purpose. For now, I'm trying to send message from shell. Following are the statements that I'm executing from the shell:
>>> import xmpp
>>> jid = xmpp.protocol.JID('99999_9999@chat.hipchat.com')
>>> cl=xmpp.Client(jid.getDomain(),debug=[])
>>> cl.connect()
'tls'
>>> cl.auth(jid.getNode(),'password')
'sasl'
>>> cl.send(xmpp.protocol.Message('99999_9999@chat.hipchat.com','hey!'))
'3'
I'm using the same jabber id for authentication and as a receiver. I'm also online in chat room but I don't get any message. What's missing?
Some older XMPP servers need an initial presence state. The state is sent using the following call before the cl.send
:
cl.SendInitPresence(requestRoster=0)
See also the xsend example from xmpppy home page: http://xmpppy.sourceforge.net/examples/xsend.py
I was missing the typ
parameter. Adding it with value chat
solved the problem:
cl.send(xmpp.protocol.Message('99999_9999@chat.hipchat.com','hey!', typ='chat'))
链接地址: http://www.djcxy.com/p/94108.html
上一篇: 社交网站上IM /聊天系统的想法