代码之家  ›  专栏  ›  技术社区  ›  diegueus9

如何在python中获得对xmpp客户机的响应

  •  1
  • diegueus9  · 技术社区  · 16 年前

    我在python中使用xmpp,我可以发送消息,但是我如何接收?

    2 回复  |  直到 14 年前
        1
  •  2
  •   Alex Eftimiades    14 年前

    我必须注册一个处理程序和进程:

    def messageCB(sess,mess):
        print 'MESSAGE'*100
        nick=mess.getFrom().getResource()
        text=mess.getBody()
        #print mess,nick
        print text
    
    client.RegisterHandler('message',messageCB)
    
    while 1:
        client.Process(1)
    
        2
  •  0
  •   David    15 年前

    好帖子。我注意到这个代码片段也在xmppy sourceforge网站的logger示例中。

    I wonder if it is possible to reply to incoming messages. The code above only receives and the nickname resource ID does not indicate who the sender is (in terms of JID format, user@server) unless xmpppy can translate that appropriately. So how might one take the received message nd "echo" it back to the sender? Or is that not easily possible with the xmpppy library and need to find a different XMPP library?