Light Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 11, 2025. It is now read-only.

davidyen1124/Facebot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

39 Commits

Repository files navigation

Facebot

Send facebook message to person or group

Graph API doesn't provide function for sending message, so I write one.

You can write a bot to talk with you, or send notification to your co-workers group if one of your server is down.

Feel free to open issue or PR!

Installation

pip install facebot

or

python setup.py install

Usage

Initiate a facebook instance:

', '')"> >>> from facebot import Facebook
>>> f = Facebook('', '')

Listen for messages:

  1. Fill in USERNAME and PASSWORD in listener.py
  2. Then type python listener.py.
  3. Have fun seeing friends sending you messages.

Ping:

If you want to write a long-running script, you should frequently call ping to tell facebook that you are alive.

# play ping pong with facebook
>>> f.ping()

Send message to a person:

', '') # send message with photo >>> f.send_person('', '', pic='http://imgs.xkcd.com/comics/python.png') # send message with sticker >>> f.send_person('', '', sticker='392309754199670') # send message with like gesture only available in mobile app >>> f.send_person('', '', like='l') # large one >>> f.send_person('', '', like='m') # medium one >>> f.send_person('', '', like='s') # small one"> # send a text message
>>> f.send_person('', '')

# send message with photo
>>> f.send_person('', '', pic='http://imgs.xkcd.com/comics/python.png')

# send message with sticker
>>> f.send_person('', '', sticker='392309754199670')

# send message with like gesture only available in mobile app
>>> f.send_person('', '', like='l') # large one
>>> f.send_person('', '', like='m') # medium one
>>> f.send_person('', '', like='s') # small one

Send message to the group:

How to find thread id?

Select See Full Conversaction in the group dialog, and the last part of url should be conversaction-123456789, so 123456789 is the thread id.

', '') # send message with photo >>> f.send_group('', '', pic='http://imgs.xkcd.com/comics/python.png') # send message with sticker >>> f.send_group('', '', sticker='392309754199670') # send message with like gesture only available in mobile app >>> f.send_group('', '', like='l') # large one >>> f.send_group('', '', like='m') # medium one >>> f.send_group('', '', like='s') # small one"> # send a text message
>>> f.send_group('', '')

# send message with photo
>>> f.send_group('', '', pic='http://imgs.xkcd.com/comics/python.png')

# send message with sticker
>>> f.send_group('', '', sticker='392309754199670')

# send message with like gesture only available in mobile app
>>> f.send_group('', '', like='l') # large one
>>> f.send_group('', '', like='m') # medium one
>>> f.send_group('', '', like='s') # small one

Read the conversation:

')"> # read all the messages in this conversation
>>> f.read('')

Typing:

') # send typing status to the user >>> f.person_typing('')"> # send typing status to the group
>>> f.group_typing('')

# send typing status to the user
>>> f.person_typing('')

Get access token:

>> f.get_access_token('')"> # default using Graph API Explorer
>>> f.get_access_token()

# retrieve other app's access token
>>> f.get_access_token('')

About

Powerful unofficial facebook api

Resources

Readme

License

MIT license

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages