Removed deprecations and new event system, improved other things
Removed deprecations Removed new event system Added documentation for all events Added FAQ Changed Client.uid to Client.id Improved User model Prepared for support of pages
This commit is contained in:
@@ -16,15 +16,9 @@ Client
|
||||
This is the main class of `fbchat`, which contains all the methods you use to interract with Facebook.
|
||||
You can extend this class, and overwrite the events, to provide custom event handling (mainly used while listening)
|
||||
|
||||
.. todo::
|
||||
Add documentation for all events
|
||||
|
||||
.. autoclass:: Client(email, password, user_agent=None, max_retries=5, session_cookies=None, logging_level=logging.INFO)
|
||||
.. autoclass:: Client(email, password, user_agent=None, max_tries=5, session_cookies=None, logging_level=logging.INFO)
|
||||
:members:
|
||||
|
||||
.. automethod:: sendRemoteImage(image_url, message=None, thread_id=None, thread_type=ThreadType.USER)
|
||||
.. automethod:: sendLocalImage(image_path, message=None, thread_id=None, thread_type=ThreadType.USER)
|
||||
|
||||
|
||||
.. _api_models:
|
||||
|
||||
|
@@ -7,6 +7,14 @@ Examples
|
||||
These are a few examples on how to use `fbchat`. Remember to swap out `<email>` and `<password>` for your email and password
|
||||
|
||||
|
||||
Basic example
|
||||
-------------
|
||||
|
||||
This will show basic usage of `fbchat`
|
||||
|
||||
.. literalinclude:: ../examples/basic_usage.py
|
||||
|
||||
|
||||
Interacting with Threads
|
||||
------------------------
|
||||
|
||||
|
44
docs/faq.rst
Normal file
44
docs/faq.rst
Normal file
@@ -0,0 +1,44 @@
|
||||
.. highlight:: python
|
||||
.. module:: fbchat
|
||||
.. _faq:
|
||||
|
||||
Frequently asked questions
|
||||
==========================
|
||||
|
||||
Version X broke my installation
|
||||
-------------------------------
|
||||
|
||||
We try to provide backwards compatability where possible, but since we're not part of Facebook,
|
||||
most of the things may be broken at any point in time
|
||||
|
||||
Downgrade to an earlier version of fbchat, run this command
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
$ pip install fbchat==<X>
|
||||
|
||||
Where you replace ``<X>`` with the version you want to use
|
||||
|
||||
|
||||
Will you be supporting creating posts/events/pages and so on?
|
||||
-------------------------------------------------------------
|
||||
|
||||
We won't be focusing on anything else than chat-related things. This API is called `fbCHAT`, after all ;)
|
||||
|
||||
|
||||
Submitting Issues
|
||||
-----------------
|
||||
|
||||
If you're having trouble with some of the snippets, or you think some of the functionality is broken,
|
||||
please feel free to submit an issue on `Github <https://github.com/carpedm20/fbchat>`_.
|
||||
You should first login with ``logging_level`` set to ``logging.DEBUG``::
|
||||
|
||||
from fbchat import Client
|
||||
import logging
|
||||
client = Client('<email>', '<password>', logging_level=logging.DEBUG)
|
||||
|
||||
Then you can submit the relevant parts of this log, and detailed steps on how to reproduce
|
||||
|
||||
.. warning::
|
||||
Always remove your credentials from any debug information you may provide us.
|
||||
Preferably, use a test account, in case you miss anything
|
@@ -36,6 +36,9 @@ Currently `fbchat` support Python 2.7, 3.4, 3.5 and 3.6:
|
||||
This means doing the exact same GET/POST requests and tricking Facebook into thinking it's accessing the website normally.
|
||||
Therefore, this API requires the credentials of a Facebook account.
|
||||
|
||||
.. note::
|
||||
If you're having problems, please check the :ref:`faq`, before asking questions on Github
|
||||
|
||||
.. warning::
|
||||
We are not responsible if your account gets banned for spammy activities,
|
||||
such as sending lots of messages to people you don't know, sending messages very quickly,
|
||||
@@ -60,3 +63,4 @@ Overview
|
||||
testing
|
||||
api
|
||||
todo
|
||||
faq
|
||||
|
@@ -53,9 +53,9 @@ These will specify whether the thread is a single user chat or a group chat.
|
||||
This is required for many of `fbchat`'s functions, since Facebook differetiates between these two internally
|
||||
|
||||
Searching for group chats and finding their ID is not yet possible with `fbchat`,
|
||||
but searching for users is possible via. :func:`Client.getUsers`. See :ref:`intro_fetching`
|
||||
but searching for users is possible via. :func:`Client.searchForUsers`. See :ref:`intro_fetching`
|
||||
|
||||
You can get your own user ID by using :any:`Client.uid`
|
||||
You can get your own user ID by using :any:`Client.id`
|
||||
|
||||
Getting the ID of a group chat is fairly trivial though, since you only need to navigate to `<https://www.facebook.com/messages/>`_,
|
||||
click on the group you want to find the ID of, and then read the id from the address bar.
|
||||
@@ -108,7 +108,7 @@ like adding users to and removing users from a group chat, logically only works
|
||||
The simplest way of using `fbchat` is to send a message.
|
||||
The following snippet will, as you've probably already figured out, send the message `test message` to your account::
|
||||
|
||||
message_id = client.sendMessage('test message', thread_id=client.uid, thread_type=ThreadType.USER)
|
||||
message_id = client.sendMessage('test message', thread_id=client.id, thread_type=ThreadType.USER)
|
||||
|
||||
You can see a full example showing all the possible thread interactions with `fbchat` by going to :ref:`examples`
|
||||
|
||||
@@ -120,12 +120,12 @@ Fetching Information
|
||||
|
||||
You can use `fbchat` to fetch basic information like user names, profile pictures, thread names and user IDs
|
||||
|
||||
You can retrieve a user's ID with :func:`Client.getUsers`.
|
||||
You can retrieve a user's ID with :func:`Client.searchForUsers`.
|
||||
The following snippet will search for users by their name, take the first (and most likely) user, and then get their user ID from the result::
|
||||
|
||||
users = client.getUsers('<name of user>')
|
||||
users = client.searchForUsers('<name of user>')
|
||||
user = users[0]
|
||||
print("User's ID: {}".format(user.uid))
|
||||
print("User's ID: {}".format(user.id))
|
||||
print("User's name: {}".format(user.name))
|
||||
print("User's profile picture url: {}".format(user.photo))
|
||||
print("User's main url: {}".format(user.url))
|
||||
@@ -198,23 +198,3 @@ and ``mid``, ``ts``, ``metadata`` and ``msg`` got removed, but the function stil
|
||||
the API actually requires that you include ``**kwargs`` as your final argument.
|
||||
|
||||
View the :ref:`examples` to see some more examples illustrating the event system
|
||||
|
||||
|
||||
.. _intro_submitting:
|
||||
|
||||
Submitting Issues
|
||||
-----------------
|
||||
|
||||
If you're having trouble with some of the snippets shown here, or you think some of the functionality is broken,
|
||||
please feel free to submit an issue on `Github <https://github.com/carpedm20/fbchat>`_.
|
||||
One side note is that you should first login with ``logging_level`` set to ``logging.DEBUG``::
|
||||
|
||||
from fbchat import Client
|
||||
import logging
|
||||
client = Client('<email>', '<password>', logging_level=logging.DEBUG)
|
||||
|
||||
Then you can submit the relevant parts of this log, and detailed steps on how to reproduce
|
||||
|
||||
.. warning::
|
||||
Always remove your credentials from any debug information you may provide us.
|
||||
Preferably, use a test account, in case you miss anything
|
||||
|
@@ -17,7 +17,7 @@ Missing Functionality
|
||||
- This will use the graphql request API
|
||||
- Implement chatting with pages
|
||||
- This might require a new :class:`models.ThreadType`, something like ``ThreadType.PAGE``
|
||||
- Rework `User`, `Thread` and `Message` models, and rework fething methods, to make the whole process more streamlined
|
||||
- Rework `Message` model, to make the whole process more streamlined
|
||||
|
||||
|
||||
Documentation
|
||||
|
Reference in New Issue
Block a user