From e488f4a7dae052bbfb5df26f9f3afdb6cf0d6388 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sun, 5 Jan 2020 19:52:59 +0100 Subject: [PATCH] Fix typing status parsing Co-authored-by: Tulir Asokan --- fbchat/_client.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/fbchat/_client.py b/fbchat/_client.py index 007a6b5..7ab6941 100644 --- a/fbchat/_client.py +++ b/fbchat/_client.py @@ -2741,19 +2741,13 @@ class Client(object): ) # Typing - elif topic in ["typ", "ttyp"]: - author_id = str(m.get("from")) - thread_id = m.get("thread_fbid") - if thread_id: - thread_type = ThreadType.GROUP - thread_id = str(thread_id) - else: - thread_type = ThreadType.USER - if author_id == self._uid: - thread_id = m.get("to") - else: - thread_id = author_id - typing_status = TypingStatus(m.get("st")) + elif topic in ("/thread_typing", "/orca_typing_notifications"): + author_id = str(m["sender_fbid"]) + thread_id = m.get("thread", author_id) + typing_status = TypingStatus(m.get("state")) + thread_type = ( + ThreadType.USER if thread_id == author_id else ThreadType.GROUP + ) self.onTyping( author_id=author_id, status=typing_status,