2011-03-02 65 views
3

這可能聽起來愚蠢的,但我也跟着這個教程: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服務器上註冊用戶。

回答