From bbc34bd009646983bf1d1bff387e5ff610f15699 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 2 Jan 2018 13:33:13 +0100 Subject: [PATCH] Added onTyping method --- fbchat/client.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/fbchat/client.py b/fbchat/client.py index 91a8018..8754d33 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -1528,8 +1528,13 @@ class Client(object): # Typing elif mtype == "typ": author_id = str(m.get("from")) + thread_id = str(m.get("to")) + if thread_id == self.uid: + thread_type = ThreadType.USER + else: + thread_type = ThreadType.GROUP typing_status = TypingStatus(m.get("st")) - self.onTyping(author_id=author_id, typing_status=typing_status) + self.onTyping(author_id=author_id, status=typing_status, thread_id=thread_id, thread_type=thread_type, msg=m) # Delivered @@ -1849,6 +1854,20 @@ class Client(object): """ log.info('Inbox event: {}, {}, {}'.format(unseen, unread, recent_unread)) + def onTyping(self, author_id=None, status=None, thread_id=None, thread_type=None, msg=None): + """ + Called when the client is listening, and somebody starts or stops typing into a chat + + :param author_id: The ID of the person who sent the action + :param status: The typing status + :param thread_id: Thread ID that the action was sent to. See :ref:`intro_threads` + :param thread_type: Type of thread that the action was sent to. See :ref:`intro_threads` + :param msg: A full set of the data recieved + :type typing_status: models.TypingStatus + :type thread_type: models.ThreadType + """ + pass + def onQprimer(self, ts=None, msg=None): """ Called when the client just started listening