这听起来可能很蠢,但我遵循了本教程:
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服务器上注册/注销用户。在
退房
http://louizatakk.fedorapeople.org/sleekxmpp-1.0-Beta2-0/examples/config_component.py
它会回答你所有的问题。如果没有,请用下面的后续问题发表评论。在
相关问题 更多 >
编程相关推荐