Use snake_case method names
Renamed: - Message.formatMentions - _util.digitToChar - _util.generateMessageID - _util.getSignatureID - _util.generateOfflineThreadingID - Client._markAlive Renamed following Client methods: - isLoggedIn - getSession - setSession - _forcedFetch - fetchThreads - fetchAllUsersFromThreads - fetchAllUsers - searchForUsers - searchForPages - searchForGroups - searchForThreads - searchForMessageIDs - searchForMessages - _fetchInfo - fetchUserInfo - fetchPageInfo - fetchGroupInfo - fetchThreadInfo - fetchThreadMessages - fetchThreadList - fetchUnread - fetchUnseen - fetchImageUrl - fetchMessageInfo - fetchPollOptions - fetchPlanInfo - _getPrivateData - getPhoneNumbers - getEmails - getUserActiveStatus - fetchThreadImages - _oldMessage - _doSendRequest - quickReply - _sendLocation - sendLocation - sendPinnedLocation - _sendFiles - sendRemoteFiles - sendLocalFiles - sendRemoteVoiceClips - sendLocalVoiceClips - forwardAttachment - createGroup - addUsersToGroup - removeUserFromGroup - _adminStatus - addGroupAdmins - removeGroupAdmins - changeGroupApprovalMode - _usersApproval - acceptUsersToGroup - denyUsersFromGroup - _changeGroupImage - changeGroupImageRemote - changeGroupImageLocal - changeThreadTitle - changeNickname - changeThreadColor - changeThreadEmoji - reactToMessage - createPlan - editPlan - deletePlan - changePlanParticipation - createPoll - updatePollVote - setTypingStatus - markAsDelivered - _readStatus - markAsRead - markAsUnread - markAsSeen - friendConnect - removeFriend - blockUser - unblockUser - moveThreads - deleteThreads - markAsSpam - deleteMessages - muteThread - unmuteThread - muteThreadReactions - unmuteThreadReactions - muteThreadMentions - unmuteThreadMentions - _pullMessage - _parseMessage - _doOneListen - setActiveStatus - onLoggingIn - on2FACode - onLoggedIn - onListening - onListenError - onMessage - onColorChange - onEmojiChange - onTitleChange - onImageChange - onNicknameChange - onAdminAdded - onAdminRemoved - onApprovalModeChange - onMessageSeen - onMessageDelivered - onMarkedSeen - onMessageUnsent - onPeopleAdded - onPersonRemoved - onFriendRequest - onInbox - onTyping - onGamePlayed - onReactionAdded - onReactionRemoved - onBlock - onUnblock - onLiveLocation - onCallStarted - onCallEnded - onUserJoinedCall - onPollCreated - onPollVoted - onPlanCreated - onPlanEnded - onPlanEdited - onPlanDeleted - onPlanParticipation - onQprimer - onChatTimestamp - onBuddylistOverlay - onUnknownMesssageType - onMessageError
This commit is contained in:
@@ -14,7 +14,7 @@ Logging In
|
||||
----------
|
||||
|
||||
Simply create an instance of :class:`Client`. If you have two factor authentication enabled, type the code in the terminal prompt
|
||||
(If you want to supply the code in another fashion, overwrite :func:`Client.on2FACode`)::
|
||||
(If you want to supply the code in another fashion, overwrite :func:`Client.on_2fa_code`)::
|
||||
|
||||
from fbchat import Client
|
||||
from fbchat.models import *
|
||||
@@ -28,10 +28,10 @@ Replace ``<email>`` and ``<password>`` with your email and password respectively
|
||||
|
||||
If you want to change how verbose ``fbchat`` is, change the logging level (in :class:`Client`)
|
||||
|
||||
Throughout your code, if you want to check whether you are still logged in, use :func:`Client.isLoggedIn`.
|
||||
Throughout your code, if you want to check whether you are still logged in, use :func:`Client.is_logged_in`.
|
||||
An example would be to login again if you've been logged out, using :func:`Client.login`::
|
||||
|
||||
if not client.isLoggedIn():
|
||||
if not client.is_logged_in():
|
||||
client.login('<email>', '<password>')
|
||||
|
||||
When you're done using the client, and want to securely logout, use :func:`Client.logout`::
|
||||
@@ -50,8 +50,8 @@ A thread can refer to two things: A Messenger group chat or a single Facebook us
|
||||
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 differentiates between these two internally
|
||||
|
||||
Searching for group chats and finding their ID can be done via. :func:`Client.searchForGroups`,
|
||||
and searching for users is possible via. :func:`Client.searchForUsers`. See :ref:`intro_fetching`
|
||||
Searching for group chats and finding their ID can be done via. :func:`Client.search_for_groups`,
|
||||
and searching for users is possible via. :func:`Client.search_for_users`. See :ref:`intro_fetching`
|
||||
|
||||
You can get your own user ID by using :any:`Client.uid`
|
||||
|
||||
@@ -71,10 +71,10 @@ corresponds to the ID of a single user, and the ID of a group respectively::
|
||||
client.send(Message(text='<message>'), thread_id='<user id>', thread_type=ThreadType.USER)
|
||||
client.send(Message(text='<message>'), thread_id='<group id>', thread_type=ThreadType.GROUP)
|
||||
|
||||
Some functions (e.g. :func:`Client.changeThreadColor`) don't require a thread type, so in these cases you just provide the thread ID::
|
||||
Some functions (e.g. :func:`Client.change_thread_color`) don't require a thread type, so in these cases you just provide the thread ID::
|
||||
|
||||
client.changeThreadColor(ThreadColor.BILOBA_FLOWER, thread_id='<user id>')
|
||||
client.changeThreadColor(ThreadColor.MESSENGER_BLUE, thread_id='<group id>')
|
||||
client.change_thread_color(ThreadColor.BILOBA_FLOWER, thread_id='<user id>')
|
||||
client.change_thread_color(ThreadColor.MESSENGER_BLUE, thread_id='<group id>')
|
||||
|
||||
|
||||
.. _intro_message_ids:
|
||||
@@ -85,12 +85,12 @@ Message IDs
|
||||
Every message you send on Facebook has a unique ID, and every action you do in a thread,
|
||||
like changing a nickname or adding a person, has a unique ID too.
|
||||
|
||||
Some of ``fbchat``'s functions require these ID's, like :func:`Client.reactToMessage`,
|
||||
and some of then provide this ID, like :func:`Client.sendMessage`.
|
||||
Some of ``fbchat``'s functions require these ID's, like :func:`Client.react_to_message`,
|
||||
and some of then provide this ID, like :func:`Client.send`.
|
||||
This snippet shows how to send a message, and then use the returned ID to react to that message with a 😍 emoji::
|
||||
|
||||
message_id = client.send(Message(text='message'), thread_id=thread_id, thread_type=thread_type)
|
||||
client.reactToMessage(message_id, MessageReaction.LOVE)
|
||||
client.react_to_message(message_id, MessageReaction.LOVE)
|
||||
|
||||
|
||||
.. _intro_interacting:
|
||||
@@ -118,10 +118,10 @@ 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.searchForUsers`.
|
||||
You can retrieve a user's ID with :func:`Client.search_for_users`.
|
||||
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.searchForUsers('<name of user>')
|
||||
users = client.search_for_users('<name of user>')
|
||||
user = users[0]
|
||||
print("User's ID: {}".format(user.uid))
|
||||
print("User's name: {}".format(user.name))
|
||||
@@ -140,13 +140,13 @@ Sessions
|
||||
|
||||
``fbchat`` provides functions to retrieve and set the session cookies.
|
||||
This will enable you to store the session cookies in a separate file, so that you don't have to login each time you start your script.
|
||||
Use :func:`Client.getSession` to retrieve the cookies::
|
||||
Use :func:`Client.get_gession` to retrieve the cookies::
|
||||
|
||||
session_cookies = client.getSession()
|
||||
session_cookies = client.get_gession()
|
||||
|
||||
Then you can use :func:`Client.setSession`::
|
||||
Then you can use :func:`Client.set_gession`::
|
||||
|
||||
client.setSession(session_cookies)
|
||||
client.set_gession(session_cookies)
|
||||
|
||||
Or you can set the ``session_cookies`` on your initial login.
|
||||
(If the session cookies are invalid, your email and password will be used to login instead)::
|
||||
@@ -168,12 +168,12 @@ By default, (most) events will just be a `logging.info` statement,
|
||||
meaning it will simply print information to the console when an event happens
|
||||
|
||||
.. note::
|
||||
You can identify the event methods by their ``on`` prefix, e.g. `onMessage`
|
||||
You can identify the event methods by their ``on`` prefix, e.g. ``on_message``
|
||||
|
||||
The event actions can be changed by subclassing the :class:`Client`, and then overwriting the event methods::
|
||||
|
||||
class CustomClient(Client):
|
||||
def onMessage(self, mid, author_id, message_object, thread_id, thread_type, ts, metadata, msg, **kwargs):
|
||||
def on_message(self, mid, author_id, message_object, thread_id, thread_type, ts, metadata, msg, **kwargs):
|
||||
# Do something with message_object here
|
||||
pass
|
||||
|
||||
@@ -182,13 +182,13 @@ The event actions can be changed by subclassing the :class:`Client`, and then ov
|
||||
**Notice:** The following snippet is as equally valid as the previous one::
|
||||
|
||||
class CustomClient(Client):
|
||||
def onMessage(self, message_object, author_id, thread_id, thread_type, **kwargs):
|
||||
def on_message(self, message_object, author_id, thread_id, thread_type, **kwargs):
|
||||
# Do something with message_object here
|
||||
pass
|
||||
|
||||
client = CustomClient('<email>', '<password>')
|
||||
|
||||
The change was in the parameters that our `onMessage` method took: ``message_object`` and ``author_id`` got swapped,
|
||||
The change was in the parameters that our ``on_message`` method took: ``message_object`` and ``author_id`` got swapped,
|
||||
and ``mid``, ``ts``, ``metadata`` and ``msg`` got removed, but the function still works, since we included ``**kwargs``
|
||||
|
||||
.. note::
|
||||
|
@@ -9,7 +9,7 @@ This page will be periodically updated to show missing features and documentatio
|
||||
Missing Functionality
|
||||
---------------------
|
||||
|
||||
- Implement ``Client.searchForMessage``
|
||||
- Implement ``Client.search_for_message``
|
||||
- This will use the GraphQL request API
|
||||
- Implement chatting with pages properly
|
||||
- Write better FAQ
|
||||
|
Reference in New Issue
Block a user