FBBack
Facebook Chat (Messenger) for Python. This project was inspired by facebook-chat-api. FBBack (pronunce F-B-Back) was forked from Taehoon Kim (/ @carpedm20)’s fbchat.
No XMPP or API key is needed. Just use your ID and PASSWORD.
Installation
Simple:
$ pip install FBBack
Example
import FBBack
client = FBBack.Client("YOUR_ID", "YOUR_PASSWORD")
Sending a Message
friends = client.getUsers("FRIEND'S NAME") # return a list of names
friend = friends[0]
sent = client.send(friend.uid, "Your Message")
if sent:
print("Message sent successfully!")
# IMAGES
client.sendLocalImage(friend.uid,message='<message text>',image='<path/to/image/file>') # send local image
imgurl = "http://i.imgur.com/LDQ2ITV.jpg"
client.sendRemoteImage(friend.uid,message='<message text>', image=imgurl) # send image from image url
Getting user info from user id
friend1 = client.getUsers('<friend name 1>')[0]
friend2 = client.getUsers('<friend name 2>')[0]
friend1_info = client.getUserInfo(friend1.uid) # returns dict with details
both_info = client.getUserInfo(friend1.uid,friend2.uid) # query both together, returns list of dicts
friend1_name = friend1_info['name']
Getting last messages sent
last_messages = client.getThreadInfo(friend.uid,0)
last_messages.reverse() # messages come in reversed order
for message in last_messages:
print(message.body)
Example Echobot
import FBBack
# Subclass FBBack.Client and override required methods
class EchoBot(FBBack.Client):
def __init__(self, email, password, debug=True, user_agent=None):
FBBack.Client.__init__(self, email, password, debug, user_agent)
def on_message(self, mid, author_id, author_name, message, metadata):
self.markAsDelivered(author_id, mid) #mark delivered
self.markAsRead(author_id) #mark read
print("%s said: %s"%(author_id, message))
#if you are not the author, echo
if str(author_id) != str(self.uid):
self.send(author_id,message)
bot = EchoBot("<email>", "<password>")
bot.listen()
Metadata
Release files for FBBack 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| FBBack-0.1.tar.gz | 10.8 kB | Without provenance | Details for FBBack-0.1.tar.gz |
Release files / FBBack-0.1.tar.gz
| Download URL | FBBack-0.1.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82fccdd0cfd5ac2d176775706f97fb7de7cc6bd5c4c3f29118cc7b5951d0407c
|
|
BLAKE2b-256 checksum How to use checksums |
f5a1013822c4c4d9f41667fd47997ee3a4de945f29f81d333699d82a69c59822
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for FBBack 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.