code: def on_message(self, event):
          '''Runs when a message event is received
  
          Args:
              event: RTM API event.
  
          Returns:
              Legobot.messge
          '''
  
          metadata = self._parse_metadata(event)
          message = Message(text=metadata['text'],
                            metadata=metadata).__dict__
          if message.get('text'):
              message['text'] = self.find_and_replace_userids(message['text'])
              message['text'] = self.find_and_replace_channel_refs(
                  message['text']
              )
          return messagf on_message(self, event):
          '''Runs when a message event is received
  
          Args:
              event: RTM API event.
  
          Returns:
              Legobot.messge
          '''
  
          metadata = self._parse_metadata(event)
          message = Message(text=metadata['text'],
                            metadata=metadata).__dict__
          if message.get('text'):
              message['text'] = self.find_and_replace_userids(message['text'])
              message['text'] = self.find_and_replace_channel_refs(
                  message['text']
              )
          return message
docs: Runs when a message event is received
  
          Args:
              event: RTM API event.
  
          Returns:
              Legobot.messge