Send an xmpp message using a python library

前端 未结 2 992
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 04:39

How can I send an XMPP message using one of the following Python libraries: wokkel, xmpppy, or jabber.py ?

I think I am aware of the pseudo-code, but so far have not

2条回答
  •  渐次进展
    2020-12-14 04:56

    This is the simplest possible xmpp client. It will send a 'hello :)' message. I'm using xmpppy in the example. And connecting to gtalk server. I think the example is self-explanatory:

    import xmpp
    
    username = 'username'
    passwd = 'password'
    to='name@example.com'
    msg='hello :)'
    
    
    client = xmpp.Client('gmail.com')
    client.connect(server=('talk.google.com',5223))
    client.auth(username, passwd, 'botty')
    client.sendInitPresence()
    message = xmpp.Message(to, msg)
    message.setAttr('type', 'chat')
    client.send(message)
    

提交回复
热议问题