GithubHelp home page GithubHelp logo

facebot's Introduction

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('<USERNAME>', '<PASSWORD>')

###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 a text message
	>>> f.send_person('<USER_ID>', '<BODY>') 
	
	# send message with photo
	>>> f.send_person('<USER_ID>', '<BODY>', pic='http://imgs.xkcd.com/comics/python.png')
	
	# send message with sticker
	>>> f.send_person('<USER_ID>', '<BODY>', sticker='392309754199670')
	
	# send message with like gesture only available in mobile app
	>>> f.send_person('<USER_ID>', '<BODY>', like='l') # large one
	>>> f.send_person('<USER_ID>', '<BODY>', like='m') # medium one
	>>> f.send_person('<USER_ID>', '<BODY>', 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 a text message
	>>> f.send_group('<THREAD_ID>', '<BODY>') 
	
	# send message with photo
	>>> f.send_group('<THREAD_ID>', '<BODY>', pic='http://imgs.xkcd.com/comics/python.png')
	
	# send message with sticker
	>>> f.send_group('<THREAD_ID>', '<BODY>', sticker='392309754199670')
	
	# send message with like gesture only available in mobile app
	>>> f.send_group('<THREAD_ID>', '<BODY>', like='l') # large one
	>>> f.send_group('<THREAD_ID>', '<BODY>', like='m') # medium one
	>>> f.send_group('<THREAD_ID>', '<BODY>', like='s') # small one

###Read the conversation:

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

###Typing:

	# send typing status to the group
	>>> f.group_typing('<THREAD_ID>')

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

###Get access token:

	# default using Graph API Explorer
	>>> f.get_access_token()
	
	# retrieve other app's access token
	>>> f.get_access_token('<APP_ID>')

facebot's People

Contributors

davidyen1124 avatar youweit avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.