【问题标题】:How to send message using xmpppy to a jabber client?如何使用 xmpppy 向 jabber 客户端发送消息?
【发布时间】:2012-06-26 07:54:10
【问题描述】:

我必须发送基于 xmpp 的聊天客户端 (hipchat),为此我使用 xmpp.py。现在,我正在尝试从 shell 发送消息。以下是我从 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'

我使用相同的 jabber id 进行身份验证和作为接收者。我也在聊天室在线,但我没有收到任何消息。缺少什么?

【问题讨论】:

    标签: python xmpp xmpppy


    【解决方案1】:

    一些较旧的 XMPP 服务器需要初始状态。 在cl.send 之前使用以下调用发送状态:

    cl.SendInitPresence(requestRoster=0)
    

    另见 xmpppy 主页中的 xsend 示例: http://xmpppy.sourceforge.net/examples/xsend.py

    【讨论】:

      【解决方案2】:

      我缺少typ 参数。添加它的值chat 解决了这个问题:

      cl.send(xmpp.protocol.Message('99999_9999@chat.hipchat.com','hey!', typ='chat'))
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-01
        • 2019-01-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多