<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def verify(self):
 """ Verify the validity of message. """

        if self.author is None or not isinstance(self.author, EFBChat):
            raise ValueError("Author is not valid.")
        else:
            self.author.verify()
        if self.chat is None or not isinstance(self.chat, EFBChat):
            raise ValueError("Chat is not valid.")
        elif self.chat is not self.author:  # Prevent repetitive verification
            self.chat.verify()
        if self.type is None or not isinstance(self.type, MsgType):
            raise ValueError("Type is not valid.")
        if self.deliver_to is None or not isinstance(self.deliver_to, EFBChannel):
            raise ValueError("Deliver_to is not valid.")
        if self.type in (MsgType.Audio, MsgType.File, MsgType.Image, MsgType.Sticker, MsgType.Video) and \
                ((not self.edit) or (self.edit and self.edit_media)):
            if self.file is None or not hasattr(self.file, "read") or not hasattr(self.file, "close"):
                raise ValueError("File is not valid.")
            if self.mime is None or not self.mime or not isinstance(self.mime, str):
                raise ValueError("MIME is not valid.")
            if self.path is None or not self.path or not isinstance(self.path, str):
                raise ValueError("Path is not valid.")
        if self.type == MsgType.Location and (self.attributes is None
                                              or not isinstance(self.attributes, EFBMsgLocationAttribute)):
            raise ValueError("Attribute of location message is invalid.")
        if self.type == MsgType.Link and (self.attributes is None
                                          or not isinstance(self.attributes, EFBMsgLinkAttribute)):
            raise ValueError("Attribute of link message is invalid.")
        if self.type == MsgType.Status and (self.attributes is None
                                            or not isinstance(self.attributes, EFBMsgStatusAttribute)):
            raise ValueError("Attribute of status message is invalid.")

        if self.attributes:
            self.attributes.verify()

        if self.commands:
            self.commands.verify()

        if self.substitutions:
            self.substitutions.verify()