Code Monkey home page Code Monkey logo

pyejabberd's Introduction

Python API Client for Ejabberd

docs Documentation Status
tests
CircleCI Build Status Coverage Status Scrtinizer Status
package Requirements Status PyPI Package latest release PyPI Package monthly downloads PyPI Wheel
compatibility Supported python versions Supported imlementations Supported ejabberd versions

A Python client for the Ejabberd XMLRPC API

  • Free software: MIT license

Installation

pip install pyejabberd

Contributors

A big thanks to the contributors:

Documentation

https://pyejabberd.readthedocs.org/

Usage

from pyejabberd import EjabberdAPIClient

# Create a client and authenticate with elevated user '[email protected]'
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 Bob's contacts
client.get_roster(user='bob', host='example.com')

# Add Alice to Bob's contact group Friends
client.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 contacts
client.delete_rosteritem(localuser='bob', localserver='example.com', user='alice', server='example.com')

# Get list of *all* connected users
client.connected_users()

# Get list of *all* connected users and information about their sessions
client.connected_users_info()

# Get number of connected users
client.connected_users_number()

# Get information for all sessions for a user
client.user_sessions_info(user="jim", host="example.com"):

# 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='[email protected]', 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

pyejabberd's People

Contributors

dirkmoors avatar encodeltd avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.