fbchat icon indicating copy to clipboard operation
fbchat copied to clipboard

Client.isLoggedIn() raises "AttributeError: 'NoneType' object has no attribute 'is_logged_in'"

Open saavedra29 opened this issue 4 years ago • 1 comments

Description of the problem

Client.isLoggedIn() raises AttributeError: 'NoneType' object has no attribute 'is_logged_in' referring to the Client._state property.

Code to reproduce

client = fb.Client('[email protected]', 'mypassword')
client.logout()
print('Logged status: {}'.format(client.isLoggedIn()))

Traceback

AttributeError                            Traceback (most recent call last)
<ipython-input-31-9afa70e6a12f> in <module>
----> 1 client.isLoggedIn()

~/.virtualenvs/fbchat/lib/python3.8/site-packages/fbchat/_client.py in isLoggedIn(self)
    152             bool: True if the client is still logged in
    153         """
--> 154         return self._state.is_logged_in()
    155 
    156     def getSession(self):

AttributeError: 'NoneType' object has no attribute 'is_logged_in'

Environment information

  • Python 3.8
  • fbchat 1.9.6

I think in _client.py we should change in line 154 return self._state.is_logged_in() with return bool(self._state)

saavedra29 avatar May 11 '20 13:05 saavedra29

your code worked fine for me, thanks!

Rafo1994 avatar Feb 16 '22 11:02 Rafo1994