sleekxmpp 组件如何工作?
这听起来可能有点傻,但我跟着这个教程做的:
https://github.com/fritzy/SleekXMPP/wiki/Creating-a-SleekXMPP-Plugin
最后我得到了一个组件,它使用了我创建的XEP-0077插件:
import sleekxmpp.componentxmpp
class Example(sleekxmpp.componentxmpp.ComponentXMPP):
def __init__(self, jid, password):
sleekxmpp.componentxmpp.ComponentXMPP.__init__(self, jid, password, 'localhost', 8888)
self.registerPlugin('xep_0030')
self.registerPlugin('xep_0077')
self.plugin['xep_0077'].setForm('username', 'password')
self.add_event_handler("registered_user", self.reg)
self.add_event_handler("unregistered_user", self.unreg)
def reg(self, iq):
msg = "Welcome! %s" % iq['register']['username']
self.sendMessage(iq['from'], msg, mfrom=self.fulljid)
def unreg(self, iq):
msg = "Bye! %s" % iq['register']['username']
self.sendMessage(iq['from'], msg, mfrom=self.fulljid)
但是我不知道怎么用这个组件,而且我也找不到任何关于如何使用它的sleekxmpp文档。我想要实现的目标是能够通过Python在xmpp服务器上注册和注销用户。
1 个回答
1
看看这个链接:
http://louizatakk.fedorapeople.org/sleekxmpp-1.0-Beta2-0/examples/config_component.py
这里面会解答你所有的问题。如果还有不明白的地方,可以在下面留言提问。