# HG changeset patch # User Goffi # Date 1387845061 -3600 # Node ID 7f98f53f69979174ef8b8725188307920a49ff43 # Parent f49945d728de2968c06a367abe382914dd30b2c4 plugin XEP-0050: fixed getDiscoItems when no commands were added + fixed commands purge on profile disconnection diff -r f49945d728de -r 7f98f53f6997 src/plugins/plugin_xep_0050.py --- a/src/plugins/plugin_xep_0050.py Tue Dec 17 01:46:45 2013 +0100 +++ b/src/plugins/plugin_xep_0050.py Tue Dec 24 01:31:01 2013 +0100 @@ -227,6 +227,12 @@ 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 @@ 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