def messageReceived(self, cnx, msg): '''Message received, addressed to the component. The command execution can raise exceptions, but those will be taken care of by the caller (messageHandler())''' user = UserAccount(msg.getFrom()) if user.isRegistered(): try: address = Address(msg.getBody()) msg = Message(to=msg.getFrom(), frm=address.jid,\ body=_(ROSTER, 'address_start_chat').format(address=address), typ='chat') except InvalidBitcoinAddressError: (action, args) = parseCommand(msg.getBody()) if action is None: return msg = msg.buildReply(Command(action, args).execute(user)) msg.setType('chat') if user.checkBalance() is not None: self.sendBitcoinPresence(cnx, user) else: error = _(REGISTRATION, 'error_not_registered') msg = msg.buildReply(_(COMMANDS, 'error_message').format(message=error)) msg.setType('error') cnx.send(msg) raise NodeProcessed