From 7d60564e23a4186e9897e2874a0cc9f9daf2af2f Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 24 Dec 2013 01:31:01 +0100 Subject: [PATCH] plugin XEP-0050: fixed getDiscoItems when no commands were added + fixed commands purge on profile disconnection --- src/plugins/plugin_xep_0050.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/plugin_xep_0050.py b/src/plugins/plugin_xep_0050.py index c4077868..d6918662 100644 --- a/src/plugins/plugin_xep_0050.py +++ b/src/plugins/plugin_xep_0050.py @@ -227,6 +227,12 @@ class XEP_0050(object): def profileConnected(self, profile): self.addAdHocCommand(self._statusCallback, _("Status"), profile_key="@ALL@") + def profileDisconnected(self, profile): + try: + del self.answering[profile] + except KeyError: + pass + def _statusCallback(self, command_elt, session_data, action, node, profile): """ Ad-hoc command used to change the "show" part of status """ actions = session_data.setdefault('actions',[]) @@ -350,7 +356,7 @@ class XEP_0050_handler(XMPPHandler): def getDiscoItems(self, requestor, target, nodeIdentifier=''): ret = [] if nodeIdentifier == NS_COMMANDS: - for command in self.plugin_parent.answering[self.parent.profile].values(): + for command in self.plugin_parent.answering.get(self.parent.profile,{}).values(): if command.isAuthorised(requestor): ret.append(disco.DiscoItem(self.parent.jid, command.node, command.getName())) #TODO: manage name language return ret