From 89c6af516c42592e4f7988412959ded927bb0771 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 11 Mar 2020 15:00:50 +0100 Subject: [PATCH] Fix various documentation mistakes --- docs/api/exceptions.rst | 3 +++ docs/index.rst | 1 + docs/intro.rst | 8 ++++---- fbchat/_client.py | 6 +++--- fbchat/_listen.py | 6 +++--- fbchat/_models/_common.py | 2 +- fbchat/_models/_file.py | 4 ++-- fbchat/_models/_location.py | 2 +- fbchat/_models/_message.py | 6 +++--- fbchat/_threads/_abc.py | 2 +- fbchat/_threads/_user.py | 2 +- 11 files changed, 23 insertions(+), 19 deletions(-) diff --git a/docs/api/exceptions.rst b/docs/api/exceptions.rst index 9219745..09958ca 100644 --- a/docs/api/exceptions.rst +++ b/docs/api/exceptions.rst @@ -4,5 +4,8 @@ Exceptions .. autoexception:: FacebookError() .. autoexception:: HTTPError() .. autoexception:: ParseError() +.. autoexception:: NotLoggedIn() .. autoexception:: ExternalError() .. autoexception:: GraphQLError() +.. autoexception:: InvalidParameters() +.. autoexception:: PleaseRefresh() diff --git a/docs/index.rst b/docs/index.rst index d5c1225..99af34b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,3 +1,4 @@ +.. highlight:: sh .. See README.rst for explanation of these markers .. include:: ../README.rst diff --git a/docs/intro.rst b/docs/intro.rst index 3de223a..108c8bb 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -46,7 +46,7 @@ A thread basically just means "something I can chat with", but more precisely, i - The conversation between you and a single Facebook user (`User`) - The conversation between you and a Facebook Page (`Page`) -You can get your own user ID with `Session.user.id`. +You can get your own user ID from `Session.user` with ``session.user.id``. Getting the ID of a specific group thread is fairly trivial, you only need to login to ``_, click on the group you want to find the ID of, and then read the id from the address bar. The URL will look something like this: ``https://www.messenger.com/t/1234567890``, where ``1234567890`` would be the ID of the group. @@ -111,19 +111,19 @@ Some functionality, like adding users to a `Group`, or blocking a `User`, logica With that out of the way, let's see some examples! -The simplest way of interracting with a thread is by sending a message:: +The simplest way of interacting with a thread is by sending a message:: # Send a message to the user message = user.send_text("test message") There are many types of messages you can send, see the full API documentation for more. -Notice how we held on to the sent message? The return type i a `Message` instance, so you can interract with it afterwards:: +Notice how we held on to the sent message? The return type i a `Message` instance, so you can interact with it afterwards:: # React to the message with the 😍 emoji message.react("😍") -Besides sending messages, you can also interract with threads in other ways. An example is to change the thread color:: +Besides sending messages, you can also interact with threads in other ways. An example is to change the thread color:: # Will change the thread color to the default blue thread.set_color("#0084ff") diff --git a/fbchat/_client.py b/fbchat/_client.py index dacb0f0..50c842e 100644 --- a/fbchat/_client.py +++ b/fbchat/_client.py @@ -33,10 +33,10 @@ class Client: But does not include deactivated, deleted or memorialized users (logically, since you can't chat with those). - The order these are returned is arbitary. + The order these are returned is arbitrary. Example: - Get the name of an arbitary user that you're currently chatting with. + Get the name of an arbitrary user that you're currently chatting with. >>> users = client.fetch_users() >>> users[0].name @@ -211,7 +211,7 @@ class Client: Warning! If someone send a message to a thread that matches the query, while we're searching, some snippets will get returned twice, and some will be lost. - This is fundamentally unfixable, it's just how the endpoint is implemented. + This is fundamentally not fixable, it's just how the endpoint is implemented. Args: query: Text to search for diff --git a/fbchat/_listen.py b/fbchat/_listen.py index a39bf1c..4b60a8e 100644 --- a/fbchat/_listen.py +++ b/fbchat/_listen.py @@ -364,7 +364,7 @@ class Listener: The `Listener` object should not be used after this is called! Example: - Stop the listener when recieving a message with the text "/stop" + Stop the listener when receiving a message with the text "/stop" >>> for event in listener.listen(): ... if isinstance(event, fbchat.MessageEvent): @@ -374,7 +374,7 @@ class Listener: self._mqtt.disconnect() def set_foreground(self, value: bool) -> None: - """Set the `foreground` value while listening.""" + """Set the ``foreground`` value while listening.""" # TODO: Document what this actually does! payload = _util.json_minimal({"foreground": value}) info = self._mqtt.publish("/foreground_state", payload=payload, qos=1) @@ -383,7 +383,7 @@ class Listener: # info.wait_for_publish() def set_chat_on(self, value: bool) -> None: - """Set the `chat_on` value while listening.""" + """Set the ``chat_on`` value while listening.""" # TODO: Document what this actually does! # TODO: Is this the right request to make? data = {"make_user_available_when_in_foreground": value} diff --git a/fbchat/_models/_common.py b/fbchat/_models/_common.py index 6828151..8b4ef68 100644 --- a/fbchat/_models/_common.py +++ b/fbchat/_models/_common.py @@ -24,7 +24,7 @@ class ThreadLocation(enum.Enum): class ActiveStatus: #: Whether the user is active now active = attr.ib(type=bool) - #: Datetime when the user was last active + #: When the user was last active last_active = attr.ib(None, type=Optional[datetime.datetime]) #: Whether the user is playing Messenger game now in_game = attr.ib(None, type=Optional[bool]) diff --git a/fbchat/_models/_file.py b/fbchat/_models/_file.py index 984e245..1ed1985 100644 --- a/fbchat/_models/_file.py +++ b/fbchat/_models/_file.py @@ -39,7 +39,7 @@ class AudioAttachment(Attachment): filename = attr.ib(None, type=Optional[str]) #: URL of the audio file url = attr.ib(None, type=Optional[str]) - #: Duration of the audio clip as a timedelta + #: Duration of the audio clip duration = attr.ib(None, type=Optional[datetime.timedelta]) #: Audio type audio_type = attr.ib(None, type=Optional[str]) @@ -118,7 +118,7 @@ class VideoAttachment(Attachment): width = attr.ib(None, type=Optional[int]) #: Height of original video height = attr.ib(None, type=Optional[int]) - #: Length of video as a timedelta + #: Length of video duration = attr.ib(None, type=Optional[datetime.timedelta]) #: URL to very compressed preview video preview_url = attr.ib(None, type=Optional[str]) diff --git a/fbchat/_models/_location.py b/fbchat/_models/_location.py index 7dd7557..c4d9afa 100644 --- a/fbchat/_models/_location.py +++ b/fbchat/_models/_location.py @@ -55,7 +55,7 @@ class LiveLocationAttachment(LocationAttachment): #: Name of the location name = attr.ib(None, type=Optional[str]) - #: Datetime when live location expires + #: When live location expires expires_at = attr.ib(None, type=Optional[datetime.datetime]) #: True if live location is expired is_expired = attr.ib(None, type=Optional[bool]) diff --git a/fbchat/_models/_message.py b/fbchat/_models/_message.py index eab7855..26569e3 100644 --- a/fbchat/_models/_message.py +++ b/fbchat/_models/_message.py @@ -224,7 +224,7 @@ class MessageSnippet(Message): #: ID of the sender author = attr.ib(type=str) - #: Datetime of when the message was sent + #: When the message was sent created_at = attr.ib(type=datetime.datetime) #: The actual message text = attr.ib(type=str) @@ -252,7 +252,7 @@ class MessageData(Message): #: ID of the sender author = attr.ib(type=str) - #: Datetime of when the message was sent + #: When the message was sent created_at = attr.ib(type=datetime.datetime) #: The actual message text = attr.ib(None, type=Optional[str]) @@ -262,7 +262,7 @@ class MessageData(Message): emoji_size = attr.ib(None, type=Optional[EmojiSize]) #: Whether the message is read is_read = attr.ib(None, type=Optional[bool]) - #: A list of people IDs who read the message, works only with `Client.fetch_thread_messages` + #: People IDs who read the message, only works with `ThreadABC.fetch_messages` read_by = attr.ib(factory=list, type=bool) #: A dictionary with user's IDs as keys, and their reaction as values reactions = attr.ib(factory=dict, type=Mapping[str, str]) diff --git a/fbchat/_threads/_abc.py b/fbchat/_threads/_abc.py index ed9159a..710d9f5 100644 --- a/fbchat/_threads/_abc.py +++ b/fbchat/_threads/_abc.py @@ -319,7 +319,7 @@ class ThreadABC(metaclass=abc.ABCMeta): Warning! If someone send a message to the thread that matches the query, while we're searching, some snippets will get returned twice. - This is fundamentally unfixable, it's just how the endpoint is implemented. + This is fundamentally not fixable, it's just how the endpoint is implemented. The returned message snippets are ordered by last sent first. diff --git a/fbchat/_threads/_user.py b/fbchat/_threads/_user.py index 888dc76..c481a6c 100644 --- a/fbchat/_threads/_user.py +++ b/fbchat/_threads/_user.py @@ -114,7 +114,7 @@ class UserData(User): first_name = attr.ib(type=str) #: The users last name last_name = attr.ib(None, type=Optional[str]) - #: Datetime when the thread was last active / when the last message was sent + #: When the thread was last active / when the last message was sent last_active = attr.ib(None, type=Optional[datetime.datetime]) #: Number of messages in the thread message_count = attr.ib(None, type=Optional[int])