fbchat-dev / fbchat-dev/fbchat
AttributeError: 'NoneType' object has no attribute '_chat_on' in doOneListen
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 403
- PR merge metrics
- No merged PRs in 30d
Description
## Description of the problem
AttributeError when using doOneListen()
What I'm trying to do is the following:
I have an application running with Qt. When the application starts I create an fbchat bot. A QTimer fires every 60 minutes to update a couple of widgets and that's where I also want to check if the fbchat bot has received any messages. I don't necessarily need it to listen() all the time, since this blocks the UI. I assumed that doOneListen() is exactly what I need, but it seems to be throwing this error.
Does anyone know why?
## Code to reproduce
```py
from fbchat import Client, log
from fbchat.models import *
from const import FB
import logging
# log.setLevel(logging.ERROR)
# Subclass fbchat.Client and override required methods
from fbchat import Client, log
from fbchat.models import *
from const import FB
# Subclass fbchat.Client and override required methods
class EchoBot(Client):
def onMessage(self, author_id, message_object, thread_id, thread_type, **kwargs):
self.markAsDelivered(thread_id, message_object.uid)
self.markAsRead(thread_id)
log.info("{} from {} in {}".format(message_object, thread_id, thread_type.name))
# If you're not the author, echo
if author_id != self.uid:
self.send(message_object, thread_id=thread_id, thread_type=thread_type)
client = EchoBot(FB.email, FB.pwd)
client.doOneListen()
```
## Traceback
```
Traceback (most recent call last):
File "C:\Google Drive\Tools\venv\lib\site-packages\fbchat\_client.py", line 2858, in doOneListen
if self._markAlive != self._mqtt._chat_on:
AttributeError: 'NoneType' object has no attribute '_chat_on'
```
## Environment information
Python 3.8.3
fbchat 1.9.7
Contributor guide
Assessment
This issue has not been assessed yet.