Created
February 7, 2019 20:22
-
-
Save VictorNine/4383070ab52156fae9ee8d7030b28100 to your computer and use it in GitHub Desktop.
facebook module for matterbridge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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