1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How to send messages to an XMPP server using only Twisted?

Discussão em 'Python' iniciado por Stack, Outubro 25, 2024 às 11:12.

  1. Stack

    Stack Membro Participativo

    I need to send messages to an XMPP server. Only send - I don't need to process replies, make a bot, or anything like that. When using the xmpppy module, it goes something like this:

    from xmpp import Client
    from xmpp.protocol import JID, Message


    jabberid = 'user@server.com'
    password = 'secret'
    receiver = 'sender_id@conference.server.com'
    message = 'Hello world!'

    jid = JID(jabberid)
    connection = Client(server=jid.getDomain(), debug=None)
    connection.connect()
    connection.auth(user=jid.getNode(), password=password, resource=jid.getResource())
    connection.send(Message(to=receiver, body=message))


    However, I need to do this using Twisted. Unfortunately, the documentation is mostly useless (seems machine-generated) and I have absolutely no idea what I am supposed to do. :-(

    Maybe something like

    from twisted.words.protocols.jabber.jid import JID
    from twisted.words.protocols.jabber.client import XMPPAuthenticator

    jabberid = 'user@server.com'
    password = 'secret'

    jid = JID(jabberid)
    XMPPAuthenticator(jid, password)


    but what then?

    Continue reading...

Compartilhe esta Página