Package: pyejabberd
docstestspackagecompatibilityA Python client for the Ejabberd XMLRPC APIFree software: MIT licenseInstallationpip install pyejabberdContributorsA big thanks to the contributors:Jim Cortez:https://github.com/jimcortezMarek Kuziel:https://github.com/encodeltdDocumentationhttps://pyejabberd.readthedocs.org/UsagefrompyejabberdimportEjabberdAPIClient# 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 serversentence='some random data'result=client.echo(sentence)assertresult==sentence# Get a list of users that are on the serverregistered_users=client.registered_users('example.com')# result is in the format [{'username': 'bob', ...}]# Register a new userclient.register(user='alice',host='example.com',password='@l1cepwd')# Change a passwordclient.change_password(user='alice',host='example.com',newpass='newpwd')# Verify passwordassertclient.check_password_hash(user='bob',host='example.com',password='newpwd')isTrue# Set nicknameclient.set_nickname(user='bob',host='example.com',nickname='Bob the builder')# Get Bob's contactsclient.get_roster(user='bob',host='example.com')# Add Alice to Bob's contact group Friendsclient.add_rosteritem(localuser='bob',localserver='example.com',user='alice',server='example.com',nick='Alice from Wonderland',group='Friends',subs='both')# Delete Alice from Bob's contactsclient.delete_rosteritem(localuser='bob',localserver='example.com',user='alice',server='example.com')# Get list of *all* connected usersclient.connected_users()# Get list of *all* connected users and information about their sessionsclient.connected_users_info()# Get number of connected usersclient.connected_users_number()# Get information for all sessions for a userclient.user_sessions_info(user="jim",host="example.com"):# Get muc roomsmuc_online_rooms=client.muc_online_rooms()# result is in the format ['room1@conference', ...] where 'conference' is the muc service name# Create a muc roomclient.create_room(name='room1',service='conference',host='example.com')# Get room optionsroom_options=client.get_room_options(name='room1',service='conference')# Set room optionfrompyejabberd.muc.enumsimportMUCRoomOptionclient.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 affiliationfrompyejabberd.muc.enumsimportAffiliationclient.set_room_affiliation(name='room1',service='conference',jid='alice@example.com',affiliation=Affiliation.member)# Get room affiliationsaffiliations=client.get_room_affiliations(name='room1',service='conference')# Destroy a muc roomclient.destroy_room(name='room1',service='conference',host='example.com')# Unregister a userclient.unregister(user='alice',host='example.com')DevelopmentTo run the all tests run:toxChangelog0.2.11 (2016-03-09)Updated “enum34” version requirement0.2.10 (2015-09-16)Added API: add_rosteritemAdded API: delete_rosteritemAdded API: get_roster0.2.9 (2015-08-12)Bugfix and small improvements0.2.8 (2015-08-03)Added testing against Ejabberd 15.070.2.7 (2015-07-28)Added API: connected_usersAdded API: connected_users_infoAdded API: connected_users_numberAdded API: user_sessions_info0.2.6 (2015-07-14)Added API: set_room_affiliationAdded API: get_room_affiliations0.2.5 (2015-07-07)Python 2/3 compatibilityFixed failing build0.2.4 (2015-07-06)Made constructor more strict (no more kwargs)Added optional function to create a client instance from a service url, compliant with the ‘12factor app’ idea0.2.3 (2015-06-18)Improved test suiteMade some enums more explicitAligned MUC room options with currently supported options in Ejabberd, build from master branch0.2.2 (2015-05-25)Cleanup and more tests0.2.1 (2015-05-25)Refactored method validator/serializer system0.2.0 (2015-05-20)Big refactor, interface changed to better match the ejabberdctl interface.0.1.2 (2015-05-16)Fixed build scripts.0.1.1 (2015-05-16)Some bugfixes.0.1.0 (2015-05-16)First release on PyPI.