XEP-0045: Better component handling

This commit is contained in:
mathieui 2021-01-10 15:01:58 +01:00
parent 1e23167ce4
commit 6369ee0e5f

View file

@ -136,22 +136,27 @@ class XEP_0045(BasePlugin):
def handle_groupchat_invite(self, inv):
""" Handle an invite into a muc. """
if inv['from'] not in self.rooms.keys():
self.xmpp.event("groupchat_invite", inv)
if self.xmpp.is_component:
self.xmpp.event('groupchat_invite', inv)
else:
if inv['from'] not in self.rooms.keys():
self.xmpp.event("groupchat_invite", inv)
def handle_groupchat_decline(self, decl):
"""Handle an invitation decline."""
if decl['from'] in self.room.keys():
self.xmpp.event('groupchat_decline', decl)
if self.xmpp.is_component:
self.xmpp.event('groupchat_invite', decl)
else:
if decl['from'] in self.room.keys():
self.xmpp.event('groupchat_decline', decl)
def handle_config_change(self, msg):
"""Handle a MUC configuration change (with status code)."""
self.xmpp.event('groupchat_config_status', msg)
self.xmpp.event('muc::%s::config_status' % msg['from'].bare , msg)
def handle_groupchat_presence(self, pr):
""" Handle a presence in a muc.
"""
def client_handle_presence(self, pr: Presence):
"""As a client, handle a presence stanza"""
got_offline = False
got_online = False
if pr['muc']['room'] not in self.rooms.keys():
@ -177,6 +182,13 @@ class XEP_0045(BasePlugin):
if got_online:
self.xmpp.event("muc::%s::got_online" % entry['room'], pr)
def handle_groupchat_presence(self, pr: Presence):
""" Handle a presence in a muc."""
if self.xmpp.is_component:
self.xmpp.event('groupchat_presence', pr)
else:
self.client_handle_presence(pr)
def handle_groupchat_message(self, msg: Message) -> None:
""" Handle a message event in a muc.
"""