fbchat 0.5.0
pip install fbchat==0.5.0
Newer version available (1.9.7)
Released:
Facebook Chat (Messenger) for Python
Navigation
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: BSD License (BSD License)
- Author: Taehoon Kim; Moreels Pieter-Jan
- Tags facebook , chat , fbchat
Classifiers
- Development Status
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
Project description
Facebook Chat (Messenger) for Python. This project was inspired by facebook-chat-api.
No XMPP or API key is needed. Just use your ID and PASSWORD.
Installation
Simple:
$ pip install fbchat
Example
import fbchat
client = fbchat.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 fbchat
#subclass fbchat.Client and override required methods
class EchoBot(fbchat.Client):
def __init__(self,email, password, debug=True, user_agent=None):
fbchat.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()
Authors
Taehoon Kim / @carpedm20
Project details
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: BSD License (BSD License)
- Author: Taehoon Kim; Moreels Pieter-Jan
- Tags facebook , chat , fbchat
Classifiers
- Development Status
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file fbchat-0.5.0.tar.gz
.
File metadata
- Download URL: fbchat-0.5.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
98d7c191e89d06d3ef598ba1bde1d34f64c80ab2935a8be117b1f674d05b8502
|
|
MD5 |
abe4de321ab936fd37733ff85fc93272
|
|
BLAKE2b-256 |
a69cb1a4ccef7dcb929c1a59f9af1750dfc58426002f9e58a48a9fac6a7e53fe
|