Thanks to visit codestin.com
Credit goes to github.com

Skip to content

xmpppy/xmpppy

Repository files navigation

xmpppy


About:Python 2/3 implementation of XMPP
Standards:RFC3920, RFC3921
Documentation:https://xmpppy.sourceforge.net/
Source Code:https://github.com/xmpppy/xmpppy

Installation

Using pip, you can install the package with:

pip install --upgrade xmpppy

Usage

As a library

Regularly, the module is used as a library, like:

import xmpp

jabberid = "[email protected]"
password = "secret"
receiver = "[email protected]"
message  = "hello world"

def main():
    jid = xmpp.protocol.JID(jabberid)
    connection = xmpp.Client(server=jid.getDomain(), debug=True)
    connection.connect()
    connection.auth(user=jid.getNode(), password=password, resource=jid.getResource())
    connection.send(xmpp.protocol.Message(to=receiver, body=message))

if __name__ == "__main__":
    main()

Command line interface

The package also installs a command line program called xmpp-message. Its synopsis is:

xmpp-message --debug \
    --jabberid [email protected] --password secret \
    --receiver [email protected] --message 'hello world'

You can also put your credentials into an ~/.xsend file, like:

[email protected]
PASSWORD=secret

and then invoke xmpp-message omitting the --jabberid and --password options, like:

xmpp-message --receiver [email protected] --message 'hello world'

Documentation

The canonical documentation is hosted at https://xmpppy.github.io/ and http://xmpppy.sourceforge.net/.

For learning about how to use this module, please have a look at these spots within the code base.

  • The xmpp-message program, located at xmpp/cli.py, for sending a single XMPP message.
  • The other programs within the doc/examples directory.
  • The docstrings within the library itself.

Development

Sandbox

Acquire sources and bootstrap sandbox:

git clone https://github.com/xmpppy/xmpppy
cd xmpppy
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade --editable='.[test]'

Software tests

Running the software tests requires a local XMPP server and a specific user account.

TCP (ipv4):localhost:5222
XMPP vhost:localhost
JID:testdrive@localhost
Password:secret

The server needs to support the core XMPP specification, it does not need to federate with other servers, nor provide TLS upgrades or other remote accesses.

Run software tests:

pytest

Run particular test cases:

pytest --no-cov -k compile

Run software tests using Prosody XMPP through the accompanied Compose file:

docker compose --file=tests/compose.yml up
docker compose --file=tests/compose.yml exec prosody prosodyctl register testdrive localhost secret
pytest

Support

If you have any questions about xmpppy usage or you have found a bug or want to share some ideas - you are welcome to join us on the issue tracker or on the xmpppy-devel mailing list.

Other projects