有没有支持添加/删除用户的python xmpp库? [英] Is there any python xmpp library that supports adding/removing users?

查看:103
本文介绍了有没有支持添加/删除用户的python xmpp库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我有了一个python类,该类通过执行 ejabberdctl register / unregister命令来创建用户/删除用户。是否有一个python xmpp库支持添加/删除用户?

Right now I have a python class that creates user/deletes users by executing "ejabberdctl register/unregister" commands. Is there a python xmpp library that supports adding/removing users?

推荐答案

您需要实现 XEP-0077 :带内注册。 xmpppy 确实支持:

You need to have an implementation of XEP-0077: In-Band Registration. xmpppy does appear to support this:

import sys
import os
import xmpp

if len(sys.argv) < 3:
    print "Syntax: register.py [JID] [Password]"
    sys.exita(64)

jid=xmpp.protocol.JID(sys.argv[1])
cli=xmpp.Client(jid.getDomain(), debug=[])
cli.connect()

# getRegInfo has a bug that puts the username as a direct child of the
# IQ, instead of inside the query element.  The below will work, but
# won't return an error when the user is known, however the register
# call will return the error.
xmpp.features.getRegInfo(cli,
                         jid.getDomain(),
                         #{'username':jid.getNode()},
                         sync=True)

if xmpp.features.register(cli,
                          jid.getDomain(),
                          {'username':jid.getNode(),
                           'password':sys.argv[2]}):
    sys.stderr.write("Success!\n")
    sys.exit(0)
else:
    sys.stderr.write("Error!\n")
    sys.exit(1)

这篇关于有没有支持添加/删除用户的python xmpp库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆