Skip to content

Instantly share code, notes, and snippets.

Last active Aug 27, 2020
What would you like to do?
FB term
import signal
import subprocess
from fbchat import Client
from fbchat.models import *
user = "F1_user_email"
passwd = "F1_user_password"
recvFrom = "F2_user_id"
client = None
class NoVPNClient(Client):
def onMessage(self, mid, author_id, message_object, thread_id, thread_type, ts, metadata, msg, **kwargs):
if author_id == recvFrom:
proc = subprocess.Popen(msg['body'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
client.send(Message(text="```{}```".format(, thread_id=recvFrom, thread_type=ThreadType.USER)
print("someone else sent a message: from: [{}] msg: [{}]".format(author_id, msg['body']))
# add signal handler to logout from fb
def sigint_handler(signal, frame):
print 'Interrupted, logging out'
signal.signal(signal.SIGINT, sigint_handler)
# login to facebook
client = NoVPNClient(user, passwd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment