From c81e509eb08220777e2482b4d5cf81ef4d32ec37 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 9 Jan 2020 20:56:10 +0100 Subject: [PATCH] Remove TypingStatus --- docs/api.rst | 2 -- fbchat/__init__.py | 2 +- fbchat/_client.py | 7 +++---- fbchat/_user.py | 9 +-------- tests/test_thread_interraction.py | 4 ++-- 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 61fc4f1..274bf24 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -55,8 +55,6 @@ Miscellaneous .. autoclass:: ThreadLocation(Enum) :undoc-members: .. autoclass:: ActiveStatus() -.. autoclass:: TypingStatus(Enum) - :undoc-members: .. autoclass:: QuickReply .. autoclass:: QuickReplyText diff --git a/fbchat/__init__.py b/fbchat/__init__.py index 85a57cf..d4a1355 100644 --- a/fbchat/__init__.py +++ b/fbchat/__init__.py @@ -15,7 +15,7 @@ from ._core import Image from ._exception import FBchatException, FBchatFacebookError from ._session import Session from ._thread import ThreadLocation, ThreadABC, Thread -from ._user import TypingStatus, User, UserData, ActiveStatus +from ._user import User, UserData, ActiveStatus from ._group import Group, GroupData from ._page import Page, PageData from ._message import EmojiSize, Mention, Message diff --git a/fbchat/_client.py b/fbchat/_client.py index dc1540e..a15fd5f 100644 --- a/fbchat/_client.py +++ b/fbchat/_client.py @@ -7,7 +7,7 @@ from . import _util, _graphql, _session from ._exception import FBchatException, FBchatFacebookError from ._thread import ThreadLocation -from ._user import TypingStatus, User, UserData, ActiveStatus +from ._user import User, UserData, ActiveStatus from ._group import Group, GroupData from ._page import Page, PageData from ._message import EmojiSize, Mention, Message @@ -1401,9 +1401,8 @@ class Client: else: thread_id = author_id thread = User(session=self.session, id=thread_id) - typing_status = TypingStatus(m.get("st")) self.on_typing( - author_id=author_id, status=typing_status, thread=thread, + author_id=author_id, status=m["st"] == 1, thread=thread ) # Delivered @@ -1812,7 +1811,7 @@ class Client: Args: author_id: The ID of the person who sent the action - status (TypingStatus): The typing status + is_typing: ``True`` if the user started typing, ``False`` if they stopped. thread: Thread that the action was sent to. See :ref:`intro_threads` """ pass diff --git a/fbchat/_user.py b/fbchat/_user.py index 0e51f7c..081cead 100644 --- a/fbchat/_user.py +++ b/fbchat/_user.py @@ -1,5 +1,5 @@ import attr -from ._core import log, attrs_default, Enum, Image +from ._core import log, attrs_default, Image from . import _util, _session, _plan, _thread @@ -33,13 +33,6 @@ GENDERS = { } -class TypingStatus(Enum): - """Used to specify whether the user is typing or has stopped typing.""" - - STOPPED = 0 - TYPING = 1 - - @attrs_default class User(_thread.ThreadABC): """Represents a Facebook user. Implements `ThreadABC`.""" diff --git a/tests/test_thread_interraction.py b/tests/test_thread_interraction.py index 5b05366..babd376 100644 --- a/tests/test_thread_interraction.py +++ b/tests/test_thread_interraction.py @@ -1,6 +1,6 @@ import pytest -from fbchat import Message, FBchatFacebookError, TypingStatus +from fbchat import Message, FBchatFacebookError from utils import random_hex, subset from os import path @@ -105,7 +105,7 @@ def test_change_color_invalid(client): client.change_thread_color(InvalidColor()) -@pytest.mark.parametrize("status", TypingStatus) +@pytest.mark.parametrize("status", [True, False]) def test_typing_status(client, catch_event, compare, status): with catch_event("on_typing") as x: client.set_typing_status(status)