Last active
August 27, 2020 10:28
-
-
Save mmpataki/32308c4bc56955d8685ea83844b66986 to your computer and use it in GitHub Desktop.
FB term
This file contains 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 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(proc.stdout.read())), thread_id=recvFrom, thread_type=ThreadType.USER) | |
else: | |
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' | |
client.logout() | |
sys.exit(0) | |
signal.signal(signal.SIGINT, sigint_handler) | |
# login to facebook | |
client = NoVPNClient(user, passwd) | |
client.listen() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment