import string


def message_fn(msg):
    """Return the file path used to store this message value."""

    ID_PATH_CHARS = string.ascii_letters + '. '

    # calculate the filename
    id_src = "".join([n for n in msg.id if n in ID_PATH_CHARS]).lower()
    words = id_src.split()

    if len(words) == 1:
        return words[0] + '.txt'
    
    filename = "-".join([''] + words[:4] + [str(abs(hash(msg.id)))])
    filename += ".txt"

    return filename