From b9b4d57b25d3d81353eb2c25083a01d619c43ed8 Mon Sep 17 00:00:00 2001
From: Mads Marquart <madsmtm@gmail.com>
Date: Tue, 21 Jan 2020 19:50:57 +0100
Subject: [PATCH 1/5] =?UTF-8?q?Bump=20version:=201.9.5=20=E2=86=92=201.9.6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .bumpversion.cfg   | 2 +-
 fbchat/__init__.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index b8f82b7d..8464e121 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 1.9.5
+current_version = 1.9.6
 commit = True
 tag = True
 
diff --git a/fbchat/__init__.py b/fbchat/__init__.py
index 5591481b..17e55d66 100644
--- a/fbchat/__init__.py
+++ b/fbchat/__init__.py
@@ -13,7 +13,7 @@
 from ._util import log  # TODO: Remove this (from examples too)
 
 __title__ = "fbchat"
-__version__ = "1.9.5"
+__version__ = "1.9.6"
 __description__ = "Facebook Chat (Messenger) for Python"
 
 __copyright__ = "Copyright 2015 - 2019 by Taehoon Kim"

From 064707ac23655e8a61afd721e30a933d19e985d1 Mon Sep 17 00:00:00 2001
From: Mads Marquart <madsmtm@gmail.com>
Date: Fri, 24 Jan 2020 21:19:58 +0100
Subject: [PATCH 2/5] Add error handling for when the listener has been logged
 out

---
 fbchat/_mqtt.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/fbchat/_mqtt.py b/fbchat/_mqtt.py
index 9bb361a1..b8daa776 100644
--- a/fbchat/_mqtt.py
+++ b/fbchat/_mqtt.py
@@ -130,11 +130,10 @@ def _fetch_sequence_id(state):
         log.debug("Fetching MQTT sequence ID")
         # Same request as in `Client.fetchThreadList`
         (j,) = state._graphql_requests(_graphql.from_doc_id("1349387578499440", params))
-        try:
-            return int(j["viewer"]["message_threads"]["sync_sequence_id"])
-        except (KeyError, ValueError):
-            # TODO: Proper exceptions
-            raise
+        sequence_id = j["viewer"]["message_threads"]["sync_sequence_id"]
+        if not sequence_id:
+            raise _exception.FBchatNotLoggedIn("Failed fetching sequence id")
+        return int(sequence_id)
 
     def _on_connect_handler(self, client, userdata, flags, rc):
         if rc == 21:
@@ -287,6 +286,8 @@ def loop_once(self, on_error=None):
                 # This error is wrongly classified
                 # See https://github.com/eclipse/paho.mqtt.python/issues/340
                 log.warning("Connection error, retrying")
+            elif rc == paho.mqtt.client.MQTT_ERR_CONN_REFUSED:
+                raise _exception.FBchatNotLoggedIn("MQTT connection refused")
             else:
                 err = paho.mqtt.client.error_string(rc)
                 log.error("MQTT Error: %s", err)

From fdf64597ec722ca1f7dc7fb7a6947a9659f89ec0 Mon Sep 17 00:00:00 2001
From: Benjamin Loison <benjamin.loison@orange.fr>
Date: Mon, 6 Apr 2020 12:46:34 +0200
Subject: [PATCH 3/5] Update fetch.py

Variable name mismatched.
---
 examples/fetch.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/fetch.py b/examples/fetch.py
index cbcef403..6e72b6cd 100644
--- a/examples/fetch.py
+++ b/examples/fetch.py
@@ -67,5 +67,5 @@
 
 # Print image url for 20 last images from thread.
 images = client.fetchThreadImages("<thread id>")
-for image in islice(image, 20):
+for image in islice(images, 20):
     print(image.large_preview_url)

From e175ec791c487bd189b6087da13d04e06df26439 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20C=C3=B4t=C3=A9?=
 <raphael.cote@ellipse-synergie.com>
Date: Sun, 31 May 2020 22:38:08 -0400
Subject: [PATCH 4/5] Update _state.py

---
 fbchat/_state.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fbchat/_state.py b/fbchat/_state.py
index a20e4f23..3aebcecf 100644
--- a/fbchat/_state.py
+++ b/fbchat/_state.py
@@ -27,6 +27,8 @@ def find_input_fields(html):
 def session_factory(user_agent=None):
     session = requests.session()
     session.headers["Referer"] = "https://www.facebook.com"
+    session.headers["Accept"] = "text/html"
+
     # TODO: Deprecate setting the user agent manually
     session.headers["User-Agent"] = user_agent or random.choice(_util.USER_AGENTS)
     return session

From 0761116335f2a0e2000ced45004d212c53d645c4 Mon Sep 17 00:00:00 2001
From: Mads Marquart <madsmtm@gmail.com>
Date: Mon, 8 Jun 2020 22:20:43 +0200
Subject: [PATCH 5/5] =?UTF-8?q?Bump=20version:=201.9.6=20=E2=86=92=201.9.7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .bumpversion.cfg   | 2 +-
 fbchat/__init__.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index 8464e121..f997fc93 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 1.9.6
+current_version = 1.9.7
 commit = True
 tag = True
 
diff --git a/fbchat/__init__.py b/fbchat/__init__.py
index 17e55d66..bb53b91a 100644
--- a/fbchat/__init__.py
+++ b/fbchat/__init__.py
@@ -13,7 +13,7 @@
 from ._util import log  # TODO: Remove this (from examples too)
 
 __title__ = "fbchat"
-__version__ = "1.9.6"
+__version__ = "1.9.7"
 __description__ = "Facebook Chat (Messenger) for Python"
 
 __copyright__ = "Copyright 2015 - 2019 by Taehoon Kim"
