class_docstr: Base class for a person on messenger that can act in a ParlAI world.
class_docstr_tok: ["Base","class","for","a","person","on","messenger","that","can","act","in","a","ParlAI","world","."]
docstr: Pulls a message from the message queue.
  
  If none exist returns None unless the timeout has expired.
docstr_tok: ["Pulls","a","message","from","the","message","queue",".","If","none","exist","returns","None","unless","the","timeout","has","expired","."]
code: def act(self, timeout=None):
      """
      Pulls a message from the message queue.
  
      If none exist returns None unless the timeout has expired.
      """
      # if this is the first act since last sent message start timing
      if self.message_request_time is None:
          self.message_request_time = time.time()
  
      # If checking timeouts
      if timeout:
          # If time is exceeded, timeout
          if time.time() - self.message_request_time > timeout:
              return self.mark_inactive()
  
      # Get a new message, if it's not None reset the timeout
      msg = self.get_new_act_message()
      if msg is not None:
          if msg.get("img_attempt") and not self.data.get(
              "allow_images", False
          ):
              # Let agent know that they cannot send images if they
              # attempted to send one
              msg = None
              act = {
                  "id": "SYSTEM",
                  "text": "Only text messages are supported at this time. "
                  "Please try with a text-only message.",
                  "episode_done": True,
              }
              self.observe(act)
          elif not msg.get("text") and not (
              msg.get("image_url") or msg.get("attachment_url")
          ):
              # Do not allow agent to send empty strings
              msg = None
  
          if msg is not None and self.message_request_time is not None:
              self.message_request_time = None
      return msg
  
file_path: ParlAI/parlai/chat_service/services/messenger/agents.py
imports: import time
  from parlai.chat_service.core.agents import ChatServiceAgent
label_desc: Use image node_id 7 for calling the MessengerAgent obj's underlying member method code with example usage: obj.act(timeout) and returns: msg, self