Skip to content

Instantly share code, notes, and snippets.

@VictorNine
Created February 7, 2019 20:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VictorNine/4383070ab52156fae9ee8d7030b28100 to your computer and use it in GitHub Desktop.
Save VictorNine/4383070ab52156fae9ee8d7030b28100 to your computer and use it in GitHub Desktop.
facebook module for matterbridge
import json
import requests
from fbchat import log, Client
# Subclass fbchat.Client and override required methods
class FBListener(Client):
def onMessage(self, author_id, message_object, thread_id, thread_type, **kwargs):
self.markAsDelivered(thread_id, message_object.uid)
self.markAsRead(thread_id)
log.info("{} from {} in {}".format(message_object, thread_id, thread_type.name))
headers = {'content-type': 'application/json'}
payload = {"text": message_object.text,"username":"randomuser","gateway":"gateway1"}
r = requests.post('http://localhost:4242/api/message', data=json.dumps(payload), headers=headers)
client = FBListener("username", "password")
client.listen()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment