def __init__(self, base_url, token=None, user_id=None,
                 valid_cert_check=True, sync_filter_limit=20,
                 cache_level=CACHE.ALL, encryption=False, encryption_conf=None):
        if user_id:
            warn(
                "user_id is deprecated. "
                "Now it is requested from the server.", DeprecationWarning
            )

        if encryption and not ENCRYPTION_SUPPORT:
            raise ValueError("Failed to enable encryption. Please make sure the olm "
                             "library is available.")

        self.api = MatrixHttpApi(base_url, token)
        self.api.validate_certificate(valid_cert_check)
        self.listeners = []
        self.presence_listeners = {}
        self.invite_listeners = []
        self.left_listeners = []
        self.ephemeral_listeners = []
        self.device_id = None
        self._encryption = encryption
        self.encryption_conf = encryption_conf or {}
        self.olm_device = None
        if isinstance(cache_level, CACHE):
            self._cache_level = cache_level
        else:
            self._cache_level = CACHE.ALL
            raise ValueError(
                "cache_level must be one of CACHE.NONE, CACHE.SOME, CACHE.ALL"
            )

        self.sync_token = None
        self.sync_filter = '{ "room": { "timeline" : { "limit" : %i } } }' \
            % sync_filter_limit
        self.sync_thread = None
        self.should_listen = False

        """ Time to wait before attempting a /sync request after failing."""
        self.bad_sync_timeout_limit = 60 * 60
        self.rooms = {
            # room_id: Room
        }
        self.users = {
            # user_id: User
        }
        if token:
            response = self.api.whoami()
            self.user_id = response["user_id"]
            self._sync()
def __init__ ( self , base_url , token = None , user_id = None , valid_cert_check = True , sync_filter_limit = 20 , cache_level = CACHE . ALL , encryption = False , encryption_conf = None ) : if user_id : warn ( "user_id is deprecated. " "Now it is requested from the server." , DeprecationWarning ) if encryption and not ENCRYPTION_SUPPORT : raise ValueError ( "Failed to enable encryption. Please make sure the olm " "library is available." ) self . api = MatrixHttpApi ( base_url , token ) self . api . validate_certificate ( valid_cert_check ) self . listeners = [ ] self . presence_listeners = { } self . invite_listeners = [ ] self . left_listeners = [ ] self . ephemeral_listeners = [ ] self . device_id = None self . _encryption = encryption self . encryption_conf = encryption_conf or { } self . olm_device = None if isinstance ( cache_level , CACHE ) : self . _cache_level = cache_level else : self . _cache_level = CACHE . ALL raise ValueError ( "cache_level must be one of CACHE.NONE, CACHE.SOME, CACHE.ALL" ) self . sync_token = None self . sync_filter = '{ "room": { "timeline" : { "limit" : %i } } }' % sync_filter_limit self . sync_thread = None self . should_listen = False """ Time to wait before attempting a /sync request after failing.""" self . bad_sync_timeout_limit = 60 * 60 self . rooms = { } self . users = { } if token : response = self . api . whoami ( ) self . user_id = response [ "user_id" ] self . _sync ( )
Time to wait before attempting a /sync request after failing.