def __init__(
        self,
        email,
        password,
        user_agent=None,
        max_tries=5,
        session_cookies=None,
        logging_level=logging.INFO,
    ):
        """Initializes and logs in the client

        :param email: Facebook `email`, `id` or `phone number`
        :param password: Facebook account password
        :param user_agent: Custom user agent to use when sending requests. If `None`, user agent will be chosen from a premade list (see :any:`utils.USER_AGENTS`)
        :param max_tries: Maximum number of times to try logging in
        :param session_cookies: Cookies from a previous session (Will default to login if these are invalid)
        :param logging_level: Configures the `logging level <https://docs.python.org/3/library/logging.html#logging-levels>`_. Defaults to `INFO`
        :type max_tries: int
        :type session_cookies: dict
        :type logging_level: int
        :raises: FBchatException on failed login
        """
        self._sticky, self._pool = (None, None)
        self._session = requests.session()
        self._req_counter = 1
        self._seq = "0"
        # See `createPoll` for the reason for using `OrderedDict` here
        self._payload_default = OrderedDict()
        self._default_thread_id = None
        self._default_thread_type = None
        self.req_url = ReqUrl()
        self._markAlive = True
        self._buddylist = dict()

        if not user_agent:
            user_agent = choice(USER_AGENTS)

        self._header = {
            "Content-Type": "application/x-www-form-urlencoded",
            "Referer": self.req_url.BASE,
            "Origin": self.req_url.BASE,
            "User-Agent": user_agent,
            "Connection": "keep-alive",
        }

        handler.setLevel(logging_level)

        # If session cookies aren't set, not properly loaded or gives us an invalid session, then do the login
        if (
            not session_cookies
            or not self.setSession(session_cookies)
            or not self.isLoggedIn()
        ):
            self.login(email, password, max_tries)
def __init__ ( self , email , password , user_agent = None , max_tries = 5 , session_cookies = None , logging_level = logging . INFO , ) : self . _sticky , self . _pool = ( None , None ) self . _session = requests . session ( ) self . _req_counter = 1 self . _seq = "0" self . _payload_default = OrderedDict ( ) self . _default_thread_id = None self . _default_thread_type = None self . req_url = ReqUrl ( ) self . _markAlive = True self . _buddylist = dict ( ) if not user_agent : user_agent = choice ( USER_AGENTS ) self . _header = { "Content-Type" : "application/x-www-form-urlencoded" , "Referer" : self . req_url . BASE , "Origin" : self . req_url . BASE , "User-Agent" : user_agent , "Connection" : "keep-alive" , } handler . setLevel ( logging_level ) if ( not session_cookies or not self . setSession ( session_cookies ) or not self . isLoggedIn ( ) ) : self . login ( email , password , max_tries )
Initializes and logs in the client

        :param email: Facebook `email`, `id` or `phone number`
        :param password: Facebook account password
        :param user_agent: Custom user agent to use when sending requests. If `None`, user agent will be chosen from a premade list (see :any:`utils.USER_AGENTS`)
        :param max_tries: Maximum number of times to try logging in
        :param session_cookies: Cookies from a previous session (Will default to login if these are invalid)
        :param logging_level: Configures the `logging level <https://docs.python.org/3/library/logging.html#logging-levels>`_. Defaults to `INFO`
        :type max_tries: int
        :type session_cookies: dict
        :type logging_level: int
        :raises: FBchatException on failed login