Added MUC invite handler to XEP-0045 plugin.

Originally contributed by damium/romeira, with some
modifications.

Also, converted tabs to spaces to prepare for future cleanup.
This commit is contained in:
Lance Stout 2010-12-16 16:18:49 -05:00
parent 67775fb8bd
commit 988a90a176

View file

@ -108,7 +108,7 @@ class MUCPresence(ElementBase):
class xep_0045(base.base_plugin):
"""
Impliments XEP-0045 Multi User Chat
Implements XEP-0045 Multi User Chat
"""
def plugin_init(self):
@ -121,6 +121,14 @@ class xep_0045(base.base_plugin):
self.xmpp.registerHandler(Callback('MUCPresence', MatchXMLMask("<presence xmlns='%s' />" % self.xmpp.default_ns), self.handle_groupchat_presence))
self.xmpp.registerHandler(Callback('MUCMessage', MatchXMLMask("<message xmlns='%s' type='groupchat'><body/></message>" % self.xmpp.default_ns), self.handle_groupchat_message))
self.xmpp.registerHandler(Callback('MUCSubject', MatchXMLMask("<message xmlns='%s' type='groupchat'><subject/></message>" % self.xmpp.default_ns), self.handle_groupchat_subject))
self.xmpp.registerHandler(Callback('MUCInvite', MatchXPath("{%s}message/{http://jabber.org/protocol/muc#user}x/invite" % self.xmpp.default_ns), self.handle_groupchat_invite))
def handle_groupchat_invite(self, inv):
""" Handle an invite into a muc.
"""
logging.debug("MUC invite to %s from %s: %s" % (inv['from'], inv["from"], inv))
if inv['from'] not in self.rooms.keys():
self.xmpp.event("groupchat_invite", inv)
def handle_groupchat_presence(self, pr):
""" Handle a presence in a muc.