Truncates the message to the given limit length. The beginning and the
    end of the message are left untouched.

def truncate(message, limit=500):
    """
    Truncates the message to the given limit length. The beginning and the
    end of the message are left untouched.
    """
    if len(message) > limit:
        trc_msg = ''.join([message[:limit // 2 - 2],
                           ' .. ',
                           message[len(message) - limit // 2 + 2:]])
    else:
        trc_msg = message
    return trc_msg