A Python client for the Ejabberd XMLRPC API
Project description
Free software: MIT license
Installation
pip install pyejabberd
Documentation
Usage
from pyejabberd import EjabberdAPIClient
# Create a client and authenticate with elevated user 'bob@example.com'
client = EjabberdAPIClient(host='localhost', port=5222, username='bob', password='p@$$wd', user_domain='example.com',
protocol='https')
# Test the connection by sending an echo request to the server
sentence = 'some random data'
result = client.echo(sentence)
assert result == sentence
# Get a list of users that are on the server
registered_users = client.registered_users('example.com')
# result is in the format [{'username': 'bob', ...}]
# Register a new user
client.register(user='alice', host='example.com', password='@l1cepwd')
# Change a password
client.change_password(user='alice', host='example.com', newpass='newpwd')
# Verify password
assert client.check_password_hash(user='bob', host='example.com', password='newpwd') is True
# Set nickname
client.set_nickname(user='bob', host='example.com', nickname='Bob the builder')
# Get muc rooms
muc_online_rooms = client.muc_online_rooms()
# result is in the format ['room1@conference', ...] where 'conference' is the muc service name
# Create a muc room
client.create_room(name='room1', service='conference', host='example.com')
# Get room options
room_options = client.get_room_options(name='room1', service='conference')
# Set room option
from pyejabberd.muc.enums import MUCRoomOption
client.change_room_option(name='room1', service='conference', option=MUCRoomOption.public, value=False)
client.change_room_option(name='room1', service='conference', option=MUCRoomOption.members_only, value=True)
# Set room affiliation
from pyejabberd.muc.enums import Affiliation
client.set_room_affiliation(name='room1', service='conference', jid='alice@example.com', affiliation=Affiliation.member)
# Get room affiliations
affiliations = client.get_room_affiliations(name='room1', service='conference')
# Destroy a muc room
client.destroy_room(name='room1', service='conference', host='example.com')
# Unregister a user
client.unregister(user='alice', host='example.com')
Development
To run the all tests run:
tox
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyejabberd-0.2.6.tar.gz
(19.5 kB
view hashes)
Built Distribution
Close
Hashes for pyejabberd-0.2.6-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a615f3b24cc683843f489a15f8e5d33c544178dbafe41938ee77f7b45b4852c |
|
MD5 | be872a309e1cd04d7ed6e8b0053169c0 |
|
BLAKE2b-256 | 58f133cc566259bebe32a84a13386855e9b1af043f13f5184ef7640879839a9e |