一个客户端蟒蛇
pyejabberd的Python项目详细描述
docs | |
---|---|
tests | |
package | |
compatibility |
ejabberd xmlrpc api的python客户机
- 自由软件:麻省理工学院许可证
安装
pip install pyejabberd
用法
frompyejabberdimportEjabberdAPIClient# 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')
开发
要运行所有测试,请运行:
tox
更改日志
0.2.11(2016-03-09)
- 更新了“Enum34”版本要求
0.2.10(2015-09-16)
- 添加的api:add_rosteritem
- 添加的api:delete\u rosteritem
- 添加了api:get_花名册
0.2.9(2015-08-12)
- 错误修复和小的改进
0.2.8(2015-08-03)
- 增加了针对Ejabberd 15.07的测试
0.2.7(2015-07-28)
- 添加了api:connected_用户
- 添加了api:connected_users_info
- 添加了API:连接的用户数
- 添加了API:用户会话信息
0.2.6(2015-07-14)
- 添加了api:set_room_affiliation
- 添加了api:get_room_affiliations
0.2.5(2015-07-07)
- python 2/3兼容性
- 修复了失败的生成
0.2.4(2015-07-06)
- 使构造器更加严格(不再是夸格斯)
- 添加了可选功能以从服务URL创建客户端实例,符合“12factor app”的理念
0.2.3(2015-06-18)
- 改进的测试套件
- 使一些枚举更加明确
- 与Ejabberd中当前支持的选项对齐的MUC室选项,从主分支构建
0.2.2(2015-05-25)
- 清理和更多测试
0.2.1(2015-05-25)
- 重构的方法验证程序/序列化程序系统
0.2.0(2015-05-20)
- 大重构,接口更改为更好地匹配ejabberdctl接口。
0.1.2(2015-05-16)
- 修复了生成脚本。
0.1.1(2015-05-16)
- 一些错误修复。
0.1.0(2015-05-16)
- pypi上的第一个版本。