def build_url_from_settings(settings):
    """Constructs web socket urls from settings"""
    is_secure = settings.TELEGRAPHY_IS_SECURE
    proto = 'wss' if is_secure else 'ws'
    url_parts = [proto, '://', settings.TELEGRAPHY_WS_HOST or 'localhost',
        ':', str(settings.TELEGRAPHY_WS_PORT), '/', settings.
        TELEGRAPHY_WS_URI or '']
    return ''.join(url_parts)
